| @@ 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 | */ |
|
| 37 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 38 | { |
|
| 39 | $this->result = $result; |
|
| 40 | $this->page = $page; |
|
| 41 | $this->pageSize = $pageSize; |
|
| 42 | $this->totalSize = $totalSize; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return Artist[] |
|
| 47 | */ |
|
| 48 | public function getResult(): array |
|
| 49 | { |
|
| 50 | return $this->result; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function getPage(): int |
|
| 54 | { |
|
| 55 | return $this->page; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getPageSize(): int |
|
| 59 | { |
|
| 60 | return $this->pageSize; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function getTotalSize(): int |
|
| 64 | { |
|
| 65 | return $this->totalSize; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getLastPage(): int |
|
| 69 | { |
|
| 70 | return (int) ceil($this->totalSize / $this->pageSize); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return ArtistSearchResult |
|
| 75 | */ |
|
| 76 | public static function createEmpty(): self |
|
| 77 | { |
|
| 78 | return new self([], 0, 0, 0); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return ArtistSearchResult |
|
| 83 | */ |
|
| 84 | public static function fromApi(array $response): self |
|
| 85 | { |
|
| 86 | return new self( |
|
| 87 | array_map( |
|
| 88 | static function ($data) { |
|
| 89 | return Artist::fromApi($data); |
|
| 90 | }, |
|
| 91 | $response['artist'] |
|
| 92 | ), |
|
| 93 | (int) $response['page'], |
|
| 94 | (int) $response['itemsPerPage'], |
|
| 95 | (int) $response['total'] |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 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 | */ |
|
| 37 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 38 | { |
|
| 39 | $this->result = $result; |
|
| 40 | $this->page = $page; |
|
| 41 | $this->pageSize = $pageSize; |
|
| 42 | $this->totalSize = $totalSize; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return City[] |
|
| 47 | */ |
|
| 48 | public function getResult(): array |
|
| 49 | { |
|
| 50 | return $this->result; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function getPage(): int |
|
| 54 | { |
|
| 55 | return $this->page; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getPageSize(): int |
|
| 59 | { |
|
| 60 | return $this->pageSize; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function getTotalSize(): int |
|
| 64 | { |
|
| 65 | return $this->totalSize; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getLastPage(): int |
|
| 69 | { |
|
| 70 | return (int) ceil($this->totalSize / $this->pageSize); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return CitySearchResult |
|
| 75 | */ |
|
| 76 | public static function createEmpty(): self |
|
| 77 | { |
|
| 78 | return new self([], 0, 0, 0); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return CitySearchResult |
|
| 83 | */ |
|
| 84 | public static function fromApi(array $response): self |
|
| 85 | { |
|
| 86 | return new self( |
|
| 87 | array_map( |
|
| 88 | static function ($data) { |
|
| 89 | return City::fromApi($data); |
|
| 90 | }, |
|
| 91 | $response['cities'] |
|
| 92 | ), |
|
| 93 | (int) $response['page'], |
|
| 94 | (int) $response['itemsPerPage'], |
|
| 95 | (int) $response['total'] |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 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 | */ |
|
| 37 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 38 | { |
|
| 39 | $this->result = $result; |
|
| 40 | $this->page = $page; |
|
| 41 | $this->pageSize = $pageSize; |
|
| 42 | $this->totalSize = $totalSize; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return Country[] |
|
| 47 | */ |
|
| 48 | public function getResult(): array |
|
| 49 | { |
|
| 50 | return $this->result; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function getPage(): int |
|
| 54 | { |
|
| 55 | return $this->page; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getPageSize(): int |
|
| 59 | { |
|
| 60 | return $this->pageSize; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function getTotalSize(): int |
|
| 64 | { |
|
| 65 | return $this->totalSize; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getLastPage(): int |
|
| 69 | { |
|
| 70 | return (int) ceil($this->totalSize / $this->pageSize); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return CountrySearchResult |
|
| 75 | */ |
|
| 76 | public static function createEmpty(): self |
|
| 77 | { |
|
| 78 | return new self([], 0, 0, 0); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return CountrySearchResult |
|
| 83 | */ |
|
| 84 | public static function fromApi(array $response): self |
|
| 85 | { |
|
| 86 | return new self( |
|
| 87 | array_map( |
|
| 88 | static function ($data) { |
|
| 89 | return Country::fromApi($data); |
|
| 90 | }, |
|
| 91 | $response['country'] |
|
| 92 | ), |
|
| 93 | (int) $response['page'], |
|
| 94 | (int) $response['itemsPerPage'], |
|
| 95 | (int) $response['total'] |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 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 | */ |
|
| 37 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 38 | { |
|
| 39 | $this->result = $result; |
|
| 40 | $this->page = $page; |
|
| 41 | $this->pageSize = $pageSize; |
|
| 42 | $this->totalSize = $totalSize; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return Setlist[] |
|
| 47 | */ |
|
| 48 | public function getResult(): array |
|
| 49 | { |
|
| 50 | return $this->result; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function getPage(): int |
|
| 54 | { |
|
| 55 | return $this->page; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getPageSize(): int |
|
| 59 | { |
|
| 60 | return $this->pageSize; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function getTotalSize(): int |
|
| 64 | { |
|
| 65 | return $this->totalSize; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getLastPage(): int |
|
| 69 | { |
|
| 70 | return (int) ceil($this->totalSize / $this->pageSize); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return SetlistSearchResult |
|
| 75 | */ |
|
| 76 | public static function createEmpty(): self |
|
| 77 | { |
|
| 78 | return new self([], 0, 0, 0); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return SetlistSearchResult |
|
| 83 | */ |
|
| 84 | public static function fromApi(array $response): self |
|
| 85 | { |
|
| 86 | return new self( |
|
| 87 | array_map( |
|
| 88 | static function ($data) { |
|
| 89 | return Setlist::fromApi($data); |
|
| 90 | }, |
|
| 91 | $response['setlist'] |
|
| 92 | ), |
|
| 93 | (int) $response['page'], |
|
| 94 | (int) $response['itemsPerPage'], |
|
| 95 | (int) $response['total'] |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 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 | */ |
|
| 37 | private function __construct(array $result, int $page, int $pageSize, int $totalSize) |
|
| 38 | { |
|
| 39 | $this->result = $result; |
|
| 40 | $this->page = $page; |
|
| 41 | $this->pageSize = $pageSize; |
|
| 42 | $this->totalSize = $totalSize; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return Venue[] |
|
| 47 | */ |
|
| 48 | public function getResult(): array |
|
| 49 | { |
|
| 50 | return $this->result; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function getPage(): int |
|
| 54 | { |
|
| 55 | return $this->page; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function getPageSize(): int |
|
| 59 | { |
|
| 60 | return $this->pageSize; |
|
| 61 | } |
|
| 62 | ||
| 63 | public function getTotalSize(): int |
|
| 64 | { |
|
| 65 | return $this->totalSize; |
|
| 66 | } |
|
| 67 | ||
| 68 | public function getLastPage(): int |
|
| 69 | { |
|
| 70 | return (int) ceil($this->totalSize / $this->pageSize); |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @return VenueSearchResult |
|
| 75 | */ |
|
| 76 | public static function createEmpty(): self |
|
| 77 | { |
|
| 78 | return new self([], 0, 0, 0); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return VenueSearchResult |
|
| 83 | */ |
|
| 84 | public static function fromApi(array $response): self |
|
| 85 | { |
|
| 86 | return new self( |
|
| 87 | array_map( |
|
| 88 | static function ($data) { |
|
| 89 | return Venue::fromApi($data); |
|
| 90 | }, |
|
| 91 | $response['venue'] |
|
| 92 | ), |
|
| 93 | (int) $response['page'], |
|
| 94 | (int) $response['itemsPerPage'], |
|
| 95 | (int) $response['total'] |
|
| 96 | ); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||