| @@ 49-63 (lines=15) @@ | ||
| 46 | * |
|
| 47 | * @return Artist[] |
|
| 48 | */ |
|
| 49 | public function parseResponse(array $response, MusicBrainz $brainz) |
|
| 50 | { |
|
| 51 | $artists = array(); |
|
| 52 | if (isset($response['artist'])) { |
|
| 53 | foreach ($response['artist'] as $artist) { |
|
| 54 | $artists[] = new Artist($artist, $brainz); |
|
| 55 | } |
|
| 56 | } elseif (isset($response['artists'])) { |
|
| 57 | foreach ($response['artists'] as $artist) { |
|
| 58 | $artists[] = new Artist($artist, $brainz); |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| 62 | return $artists; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| @@ 62-81 (lines=20) @@ | ||
| 59 | * @throws \MusicBrainz\Exception |
|
| 60 | * @return array |
|
| 61 | */ |
|
| 62 | public function parseResponse(array $response, MusicBrainz $brainz) |
|
| 63 | { |
|
| 64 | $recordings = array(); |
|
| 65 | ||
| 66 | if (isset($response['recording'])) { |
|
| 67 | foreach ($response['recording'] as $recording) { |
|
| 68 | $recordings[] = new Recording($recording, $brainz); |
|
| 69 | } |
|
| 70 | } elseif (isset($response['recordings'])) { |
|
| 71 | foreach ($response['recordings'] as $recording) { |
|
| 72 | $recordings[] = new Recording($recording, $brainz); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | if (empty($recordings)) { |
|
| 77 | throw new Exception('No search results found'); |
|
| 78 | } |
|
| 79 | ||
| 80 | return $recordings; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| @@ 65-79 (lines=15) @@ | ||
| 62 | * |
|
| 63 | * @return array |
|
| 64 | */ |
|
| 65 | public function parseResponse(array $response, MusicBrainz $brainz) |
|
| 66 | { |
|
| 67 | $releases = array(); |
|
| 68 | if (isset($response['release'])) { |
|
| 69 | foreach ($response['release'] as $release) { |
|
| 70 | $releases[] = new Release($release, $brainz); |
|
| 71 | } |
|
| 72 | } elseif (isset($response['releases'])) { |
|
| 73 | foreach ($response['releases'] as $release) { |
|
| 74 | $releases[] = new Release($release, $brainz); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | return $releases; |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||