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