コード例 #1
0
 public function testBuildArtistsSimplified()
 {
     $artist1 = (object) ['id' => 'someid', 'name' => 'Avicii', 'href' => 'http://...', 'uri' => 'nonsense:test'];
     $artist2 = clone $artist1;
     $result = $this->valueObjectBuilder->buildArtistsSimplified([$artist1, $artist2]);
     $this->assertCount(2, $result, 'Number of result should equal number of inputted artists');
     $this->assertEquals($artist1->id, $result[0]->getId(), 'Artist id should be set');
     $this->assertEquals($artist1->name, $result[0]->getName(), 'Artist name should be set');
     $this->assertEquals($artist1->uri, $result[0]->getSpotifyUri(), 'Artist uri should be set');
     $this->assertEquals($artist1->href, $result[0]->getSpotifyHref(), 'Artist href should be set');
 }
コード例 #2
0
ファイル: TrackFinder.php プロジェクト: palmfjord/sr-playlist
 /**
  * Search for a track and build the response objects
  *
  * @param string $string
  *
  * @return Track
  */
 public function findTrack(string $string)
 {
     $result = $this->spotifyWebApi->search($string, 'track');
     if (count($result->tracks->items) === 0) {
         throw NoTracksFoundException::emptyResult();
     }
     $firstItem = $result->tracks->items[0];
     $images = $this->valueObjectBuilder->buildImages($firstItem->album->images);
     $album = $this->valueObjectBuilder->buildAlbumSimplified($firstItem->album, $images);
     $artists = $this->valueObjectBuilder->buildArtistsSimplified($firstItem->artists);
     $track = $this->valueObjectBuilder->buildTrack($firstItem, $album, $artists);
     return $track;
 }