/** * Check if $this is equal to $b. * * @param Track $b * @return bool */ public function equals(SpotifyItem $b) { if (!$b instanceof Track) { return false; } if ($this->getURI() != $b->getURI()) { return false; } if (!is_array($this->getArtist())) { if (!$this->getArtist()->equals($b->getArtist())) { return false; } } else { $bArtists = $b->getArtist(); for ($i = 0; $i < count($this->artist); $i++) { if (!$this->artist[$i]->equals($bArtists[i])) { return false; } } } if (!$this->getAlbum()->equals($b->getAlbum())) { return false; } return true; }
/** * Check if $this is equal to $b. * * @param Album $b * @return bool */ public function equals(SpotifyItem $b) { if (!$b instanceof Album) { return false; } if ($b->getURI() != $this->getURI() || $b->getName() != $this->getName()) { return false; } if ($b->getArtist() != null && $this->getArtist() != null && !$this->getArtist()->equals($b->getArtist())) { return false; } $bTracks = $b->getTracks(); if (count($this->tracks) != count($bTracks)) { return false; } if (count($this->tracks) > 0) { for ($i = 0; $i < count($this->tracks); $i++) { if (!$this->tracks[$i]->equals($bTracks[$i])) { return false; } } } return true; }