Esempio n. 1
0
 /**
  * Retrieves the album with the given identity.
  *
  * @param  AlbumIdentity $identity The identity of the album to retrieve.
  * @return Domain\Entity\Album
  * @throws Domain\Exception\AlbumNotFoundException If no album has the requested identity.
  */
 public function get(AlbumIdentity $identity)
 {
     try {
         $album_raw = $this->spotify_api->getAlbum($identity->getId());
         $album = Album::create($album_raw->id, $album_raw->name);
         foreach ($album_raw->tracks->items as $track) {
             $album->addTrack($this->track_builder->buildTrack($track));
         }
         return $album;
     } catch (NotFoundException $e) {
         throw new AlbumNotFoundException();
     }
 }
Esempio n. 2
0
 private function buildPlaylist($raw_playlist)
 {
     $playlist = Playlist::create($raw_playlist['id'], $raw_playlist['name']);
     if (isset($raw_playlist['tracks'])) {
         foreach ($raw_playlist['tracks'] as $raw_track) {
             $track = new \stdClass();
             $track->id = $raw_track['id'];
             $track->name = $raw_track['name'];
             $playlist->addTrack($this->track_builder->buildTrack($track));
         }
     }
     return $playlist;
 }