| @@ 12-115 (lines=104) @@ | ||
| 9 | ||
| 10 | namespace Core23\SetlistFm\Model; |
|
| 11 | ||
| 12 | final class ArtistSearchResult |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var Artist[] |
|
| 16 | */ |
|
| 17 | private $result; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $page; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var int |
|
| 26 | */ |
|
| 27 | private $pageSize; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var int |
|
| 31 | */ |
|
| 32 | private $totalSize; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Artist[] $result |
|
| 36 | * @param int $page |
|
| 37 | * @param int $pageSize |
|
| 38 | * @param int $totalSize |
|
| 39 | */ |
|
| 40 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 41 | { |
|
| 42 | $this->result = $result; |
|
| 43 | $this->page = $page; |
|
| 44 | $this->pageSize = $pageSize; |
|
| 45 | $this->totalSize = $totalSize; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return Artist[] |
|
| 50 | */ |
|
| 51 | public function getResult(): array |
|
| 52 | { |
|
| 53 | return $this->result; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function getPage(): int |
|
| 60 | { |
|
| 61 | return $this->page; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getPageSize(): int |
|
| 68 | { |
|
| 69 | return $this->pageSize; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return int |
|
| 74 | */ |
|
| 75 | public function getTotalSize(): int |
|
| 76 | { |
|
| 77 | return $this->totalSize; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return int |
|
| 82 | */ |
|
| 83 | public function getLastPage(): int |
|
| 84 | { |
|
| 85 | return (int) floor($this->totalSize / $this->pageSize); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return ArtistSearchResult |
|
| 90 | */ |
|
| 91 | public static function createEmpty(): self |
|
| 92 | { |
|
| 93 | return new self([], 0, 0, 0); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param array $response |
|
| 98 | * |
|
| 99 | * @return ArtistSearchResult |
|
| 100 | */ |
|
| 101 | public static function fromApi(array $response): self |
|
| 102 | { |
|
| 103 | return new self( |
|
| 104 | array_map( |
|
| 105 | static function ($data) { |
|
| 106 | return Artist::fromApi($data); |
|
| 107 | }, |
|
| 108 | $response['artist'] |
|
| 109 | ), |
|
| 110 | (int) $response['page'], |
|
| 111 | (int) $response['itemsPerPage'], |
|
| 112 | (int) $response['total'] |
|
| 113 | ); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 12-115 (lines=104) @@ | ||
| 9 | ||
| 10 | namespace Core23\SetlistFm\Model; |
|
| 11 | ||
| 12 | final class CitySearchResult |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var City[] |
|
| 16 | */ |
|
| 17 | private $result; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $page; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var int |
|
| 26 | */ |
|
| 27 | private $pageSize; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var int |
|
| 31 | */ |
|
| 32 | private $totalSize; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param City[] $result |
|
| 36 | * @param int $page |
|
| 37 | * @param int $pageSize |
|
| 38 | * @param int $totalSize |
|
| 39 | */ |
|
| 40 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 41 | { |
|
| 42 | $this->result = $result; |
|
| 43 | $this->page = $page; |
|
| 44 | $this->pageSize = $pageSize; |
|
| 45 | $this->totalSize = $totalSize; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return City[] |
|
| 50 | */ |
|
| 51 | public function getResult(): array |
|
| 52 | { |
|
| 53 | return $this->result; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function getPage(): int |
|
| 60 | { |
|
| 61 | return $this->page; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getPageSize(): int |
|
| 68 | { |
|
| 69 | return $this->pageSize; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return int |
|
| 74 | */ |
|
| 75 | public function getTotalSize(): int |
|
| 76 | { |
|
| 77 | return $this->totalSize; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return int |
|
| 82 | */ |
|
| 83 | public function getLastPage(): int |
|
| 84 | { |
|
| 85 | return (int) floor($this->totalSize / $this->pageSize); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return CitySearchResult |
|
| 90 | */ |
|
| 91 | public static function createEmpty(): self |
|
| 92 | { |
|
| 93 | return new self([], 0, 0, 0); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param array $response |
|
| 98 | * |
|
| 99 | * @return CitySearchResult |
|
| 100 | */ |
|
| 101 | public static function fromApi(array $response): self |
|
| 102 | { |
|
| 103 | return new self( |
|
| 104 | array_map( |
|
| 105 | static function ($data) { |
|
| 106 | return City::fromApi($data); |
|
| 107 | }, |
|
| 108 | $response['cities'] |
|
| 109 | ), |
|
| 110 | (int) $response['page'], |
|
| 111 | (int) $response['itemsPerPage'], |
|
| 112 | (int) $response['total'] |
|
| 113 | ); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 12-115 (lines=104) @@ | ||
| 9 | ||
| 10 | namespace Core23\SetlistFm\Model; |
|
| 11 | ||
| 12 | final class CountrySearchResult |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var Country[] |
|
| 16 | */ |
|
| 17 | private $result; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $page; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var int |
|
| 26 | */ |
|
| 27 | private $pageSize; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var int |
|
| 31 | */ |
|
| 32 | private $totalSize; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Country[] $result |
|
| 36 | * @param int $page |
|
| 37 | * @param int $pageSize |
|
| 38 | * @param int $totalSize |
|
| 39 | */ |
|
| 40 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 41 | { |
|
| 42 | $this->result = $result; |
|
| 43 | $this->page = $page; |
|
| 44 | $this->pageSize = $pageSize; |
|
| 45 | $this->totalSize = $totalSize; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return Country[] |
|
| 50 | */ |
|
| 51 | public function getResult(): array |
|
| 52 | { |
|
| 53 | return $this->result; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function getPage(): int |
|
| 60 | { |
|
| 61 | return $this->page; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getPageSize(): int |
|
| 68 | { |
|
| 69 | return $this->pageSize; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return int |
|
| 74 | */ |
|
| 75 | public function getTotalSize(): int |
|
| 76 | { |
|
| 77 | return $this->totalSize; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return int |
|
| 82 | */ |
|
| 83 | public function getLastPage(): int |
|
| 84 | { |
|
| 85 | return (int) floor($this->totalSize / $this->pageSize); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return CountrySearchResult |
|
| 90 | */ |
|
| 91 | public static function createEmpty(): self |
|
| 92 | { |
|
| 93 | return new self([], 0, 0, 0); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param array $response |
|
| 98 | * |
|
| 99 | * @return CountrySearchResult |
|
| 100 | */ |
|
| 101 | public static function fromApi(array $response): self |
|
| 102 | { |
|
| 103 | return new self( |
|
| 104 | array_map( |
|
| 105 | static function ($data) { |
|
| 106 | return Country::fromApi($data); |
|
| 107 | }, |
|
| 108 | $response['country'] |
|
| 109 | ), |
|
| 110 | (int) $response['page'], |
|
| 111 | (int) $response['itemsPerPage'], |
|
| 112 | (int) $response['total'] |
|
| 113 | ); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 12-115 (lines=104) @@ | ||
| 9 | ||
| 10 | namespace Core23\SetlistFm\Model; |
|
| 11 | ||
| 12 | final class SetlistSearchResult |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var Setlist[] |
|
| 16 | */ |
|
| 17 | private $result; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $page; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var int |
|
| 26 | */ |
|
| 27 | private $pageSize; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var int |
|
| 31 | */ |
|
| 32 | private $totalSize; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Setlist[] $result |
|
| 36 | * @param int $page |
|
| 37 | * @param int $pageSize |
|
| 38 | * @param int $totalSize |
|
| 39 | */ |
|
| 40 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 41 | { |
|
| 42 | $this->result = $result; |
|
| 43 | $this->page = $page; |
|
| 44 | $this->pageSize = $pageSize; |
|
| 45 | $this->totalSize = $totalSize; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return Setlist[] |
|
| 50 | */ |
|
| 51 | public function getResult(): array |
|
| 52 | { |
|
| 53 | return $this->result; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function getPage(): int |
|
| 60 | { |
|
| 61 | return $this->page; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getPageSize(): int |
|
| 68 | { |
|
| 69 | return $this->pageSize; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return int |
|
| 74 | */ |
|
| 75 | public function getTotalSize(): int |
|
| 76 | { |
|
| 77 | return $this->totalSize; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return int |
|
| 82 | */ |
|
| 83 | public function getLastPage(): int |
|
| 84 | { |
|
| 85 | return (int) floor($this->totalSize / $this->pageSize); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return SetlistSearchResult |
|
| 90 | */ |
|
| 91 | public static function createEmpty(): self |
|
| 92 | { |
|
| 93 | return new self([], 0, 0, 0); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param array $response |
|
| 98 | * |
|
| 99 | * @return SetlistSearchResult |
|
| 100 | */ |
|
| 101 | public static function fromApi(array $response): self |
|
| 102 | { |
|
| 103 | return new self( |
|
| 104 | array_map( |
|
| 105 | static function ($data) { |
|
| 106 | return Setlist::fromApi($data); |
|
| 107 | }, |
|
| 108 | $response['setlist'] |
|
| 109 | ), |
|
| 110 | (int) $response['page'], |
|
| 111 | (int) $response['itemsPerPage'], |
|
| 112 | (int) $response['total'] |
|
| 113 | ); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| @@ 12-115 (lines=104) @@ | ||
| 9 | ||
| 10 | namespace Core23\SetlistFm\Model; |
|
| 11 | ||
| 12 | final class VenueSearchResult |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var Venue[] |
|
| 16 | */ |
|
| 17 | private $result; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $page; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var int |
|
| 26 | */ |
|
| 27 | private $pageSize; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var int |
|
| 31 | */ |
|
| 32 | private $totalSize; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Venue[] $result |
|
| 36 | * @param int $page |
|
| 37 | * @param int $pageSize |
|
| 38 | * @param int $totalSize |
|
| 39 | */ |
|
| 40 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 41 | { |
|
| 42 | $this->result = $result; |
|
| 43 | $this->page = $page; |
|
| 44 | $this->pageSize = $pageSize; |
|
| 45 | $this->totalSize = $totalSize; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @return Venue[] |
|
| 50 | */ |
|
| 51 | public function getResult(): array |
|
| 52 | { |
|
| 53 | return $this->result; |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @return int |
|
| 58 | */ |
|
| 59 | public function getPage(): int |
|
| 60 | { |
|
| 61 | return $this->page; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return int |
|
| 66 | */ |
|
| 67 | public function getPageSize(): int |
|
| 68 | { |
|
| 69 | return $this->pageSize; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @return int |
|
| 74 | */ |
|
| 75 | public function getTotalSize(): int |
|
| 76 | { |
|
| 77 | return $this->totalSize; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @return int |
|
| 82 | */ |
|
| 83 | public function getLastPage(): int |
|
| 84 | { |
|
| 85 | return (int) floor($this->totalSize / $this->pageSize); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @return VenueSearchResult |
|
| 90 | */ |
|
| 91 | public static function createEmpty(): self |
|
| 92 | { |
|
| 93 | return new self([], 0, 0, 0); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @param array $response |
|
| 98 | * |
|
| 99 | * @return VenueSearchResult |
|
| 100 | */ |
|
| 101 | public static function fromApi(array $response): self |
|
| 102 | { |
|
| 103 | return new self( |
|
| 104 | array_map( |
|
| 105 | static function ($data) { |
|
| 106 | return Venue::fromApi($data); |
|
| 107 | }, |
|
| 108 | $response['venue'] |
|
| 109 | ), |
|
| 110 | (int) $response['page'], |
|
| 111 | (int) $response['itemsPerPage'], |
|
| 112 | (int) $response['total'] |
|
| 113 | ); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||