/** * 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 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; }