| @@ 32-49 (lines=18) @@ | ||
| 29 | $this->client = $client; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function getTopArtists(int $limit = 50, int $page = 1): array |
|
| 33 | { |
|
| 34 | $response = $this->client->unsignedCall('chart.getTopArtists', [ |
|
| 35 | 'limit' => $limit, |
|
| 36 | 'page' => $page, |
|
| 37 | ]); |
|
| 38 | ||
| 39 | if (!isset($response['artists']['artist'])) { |
|
| 40 | return []; |
|
| 41 | } |
|
| 42 | ||
| 43 | return ApiHelper::mapList( |
|
| 44 | static function ($data) { |
|
| 45 | return ArtistInfo::fromApi($data); |
|
| 46 | }, |
|
| 47 | $response['artists']['artist'] |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function getTopTags(int $limit = 50, int $page = 1): array |
|
| 52 | { |
|
| @@ 51-68 (lines=18) @@ | ||
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function getTopTags(int $limit = 50, int $page = 1): array |
|
| 52 | { |
|
| 53 | $response = $this->client->unsignedCall('chart.getTopTags', [ |
|
| 54 | 'limit' => $limit, |
|
| 55 | 'page' => $page, |
|
| 56 | ]); |
|
| 57 | ||
| 58 | if (!isset($response['tags']['tag'])) { |
|
| 59 | return []; |
|
| 60 | } |
|
| 61 | ||
| 62 | return ApiHelper::mapList( |
|
| 63 | static function ($data) { |
|
| 64 | return Tag::fromApi($data); |
|
| 65 | }, |
|
| 66 | $response['tags']['tag'] |
|
| 67 | ); |
|
| 68 | } |
|
| 69 | ||
| 70 | public function getTopTracks(int $limit = 50, int $page = 1): array |
|
| 71 | { |
|
| @@ 70-87 (lines=18) @@ | ||
| 67 | ); |
|
| 68 | } |
|
| 69 | ||
| 70 | public function getTopTracks(int $limit = 50, int $page = 1): array |
|
| 71 | { |
|
| 72 | $response = $this->client->unsignedCall('chart.getTopTracks', [ |
|
| 73 | 'limit' => $limit, |
|
| 74 | 'page' => $page, |
|
| 75 | ]); |
|
| 76 | ||
| 77 | if (!isset($response['tracks']['track'])) { |
|
| 78 | return []; |
|
| 79 | } |
|
| 80 | ||
| 81 | return ApiHelper::mapList( |
|
| 82 | static function ($data) { |
|
| 83 | return Song::fromApi($data); |
|
| 84 | }, |
|
| 85 | $response['tracks']['track'] |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| @@ 31-49 (lines=19) @@ | ||
| 28 | $this->client = $client; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function getTopArtists(string $country, int $limit = 50, int $page = 1): array |
|
| 32 | { |
|
| 33 | $response = $this->client->unsignedCall('geo.getTopArtists', [ |
|
| 34 | 'country' => $country, |
|
| 35 | 'limit' => $limit, |
|
| 36 | 'page' => $page, |
|
| 37 | ]); |
|
| 38 | ||
| 39 | if (!isset($response['topartists']['artist'])) { |
|
| 40 | return []; |
|
| 41 | } |
|
| 42 | ||
| 43 | return ApiHelper::mapList( |
|
| 44 | static function ($data) { |
|
| 45 | return Artist::fromApi($data); |
|
| 46 | }, |
|
| 47 | $response['topartists']['artist'] |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function getTopTracks(string $country, string $location = null, $limit = 50, int $page = 1): array |
|
| 52 | { |
|
| @@ 30-48 (lines=19) @@ | ||
| 27 | $this->client = $client; |
|
| 28 | } |
|
| 29 | ||
| 30 | public function getArtists(string $user, int $limit = 50, int $page = 1): array |
|
| 31 | { |
|
| 32 | $response = $this->client->unsignedCall('library.getArtists', [ |
|
| 33 | 'user' => $user, |
|
| 34 | 'limit' => $limit, |
|
| 35 | 'page' => $page, |
|
| 36 | ]); |
|
| 37 | ||
| 38 | if (!isset($response['artists']['artist'])) { |
|
| 39 | return []; |
|
| 40 | } |
|
| 41 | ||
| 42 | return ApiHelper::mapList( |
|
| 43 | static function ($data) { |
|
| 44 | return ArtistInfo::fromApi($data); |
|
| 45 | }, |
|
| 46 | $response['artists']['artist'] |
|
| 47 | ); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||