/** * Gets a song from Spotify based on the data from SR, or returns track objects with the known values * * @param Song $song * * @return Track */ public function getSongFromSpotify(Song $song) : Track { try { $track = $this->spotifyTrackFinder->findTrack($this->getSearchTermFromSongObject($song)); } catch (NoTracksFoundException $e) { try { $track = $this->spotifyTrackFinder->findTrack($this->getLooseSearchTermFromSongObject($song)); } catch (NoTracksFoundException $e) { // Set to default $artist = new ArtistSimplified(); $artist->setName($song->getArtist()); $track = new Track(); $track->setName($song->getTitle())->setArtists([$artist]); } } return $track; }