1 | <?php |
||
14 | final class ArtistSearchBuilder |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $query; |
||
20 | |||
21 | private function __construct() |
||
27 | |||
28 | /** |
||
29 | * @return ArtistSearchBuilder |
||
30 | */ |
||
31 | public static function create(): self |
||
32 | { |
||
33 | return new static(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return ArtistSearchBuilder |
||
38 | */ |
||
39 | public function page(int $page): self |
||
40 | { |
||
41 | $this->query['p'] = $page; |
||
42 | |||
43 | return $this; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return ArtistSearchBuilder |
||
48 | */ |
||
49 | public function sort(string $mode): self |
||
50 | { |
||
51 | if (!\in_array($mode, ['sortName', 'relevance'], true)) { |
||
52 | throw new InvalidArgumentException(sprintf('Invalid sort mode given: %s', $mode)); |
||
53 | } |
||
54 | |||
55 | $this->query['sort'] = $mode; |
||
56 | |||
57 | return $this; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @return ArtistSearchBuilder |
||
62 | */ |
||
63 | public function withName(string $name): self |
||
64 | { |
||
65 | $this->query['artistName'] = $name; |
||
66 | |||
67 | return $this; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return ArtistSearchBuilder |
||
72 | */ |
||
73 | public function withMbid(string $mbid): self |
||
79 | |||
80 | /** |
||
81 | * @return ArtistSearchBuilder |
||
82 | */ |
||
83 | public function withTmbid(int $tmid): self |
||
89 | |||
90 | public function getQuery(): array |
||
94 | } |
||
95 |