Skip to content

Commit

Permalink
Introduce and use enum for Tags
Browse files Browse the repository at this point in the history
  • Loading branch information
pavog committed Dec 4, 2024
1 parent 39fd7c5 commit 914ebcc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Client/HangarAPIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getProjects(ProjectSearchOptions $options = new ProjectSearchOpt
null,
$options->getLicense(),
$options->getVersion(),
$options->getTag(),
$options->getTag()?->value,
);

return new ProjectList($this, $result, $options);
Expand Down
11 changes: 6 additions & 5 deletions lib/Client/Options/ProjectSearch/ProjectSearchOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Aternos\HangarApi\Client\Options\Platform;
use Aternos\HangarApi\Client\Options\ProjectCategory;
use Aternos\HangarApi\Client\Options\Tag;
use Aternos\HangarApi\Model\RequestPagination;

/**
Expand All @@ -24,7 +25,7 @@ class ProjectSearchOptions
protected ?string $query = null;
protected ?string $license = null;
protected ?string $version = null;
protected ?string $tag = null;
protected ?Tag $tag = null;

public function __construct()
{
Expand Down Expand Up @@ -270,18 +271,18 @@ public function setVersion(?string $version): static
}

/**
* @return string|null
* @return Tag|null
*/
public function getTag(): ?string
public function getTag(): ?Tag
{
return $this->tag;
}

/**
* @param string|null $tag
* @param Tag|null $tag
* @return $this
*/
public function setTag(?string $tag): static
public function setTag(?Tag $tag): static
{
$this->tag = $tag;
return $this;
Expand Down
10 changes: 10 additions & 0 deletions lib/Client/Options/Tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aternos\HangarApi\Client\Options;

enum Tag: string
{
case ADDON = 'ADDON';
case LIBRARY = 'LIBRARY';
case SUPPORTS_FOLIA = 'SUPPORTS_FOLIA';
}

0 comments on commit 914ebcc

Please sign in to comment.