/** * Check if $this is equal to $b. * * @param Artist $b * @return bool */ public function equals(SpotifyItem $b) { if (!$b instanceof Artist) { return false; } if ($b->getName() != $this->getName()) { return false; } if ($b->getURI() != $this->getURI()) { return false; } $bAlbums = $b->getAlbum(); if (count($bAlbums) != count($this->albums)) { return false; } if (count($this->albums) > 0) { for ($i = 0; $i < count($this->albums); $i++) { if (!$this->albums[$i]->equals($bAlbums[$i])) { 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; }