add merge tune to extract tunes by title
update Tune::merge() and add Tune::equals()
This commit is contained in:
@@ -9,7 +9,7 @@ class Collection extends BaseCollection
|
||||
{
|
||||
/**
|
||||
* @param $initial
|
||||
* @param callable $callback
|
||||
* @param callable($carry, $item) $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function reduce($initial, callable $callback)
|
||||
|
||||
@@ -263,11 +263,9 @@ class Tune implements EntityInterface
|
||||
*/
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->tuneSettings;
|
||||
return $this->tuneSettings ?: [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
@@ -363,8 +361,23 @@ class Tune implements EntityInterface
|
||||
$this->titles = array_merge($this->getTitles(), $source->getTitles());
|
||||
$this->authors = array_merge($this->getAuthors(), $source->getAuthors());
|
||||
$this->composers = array_merge($this->getComposers(), $source->getComposers());
|
||||
$this->groups = array_merge($this->getGroups(), $source->getGroups());
|
||||
$this->history = array_merge($this->getHistory(), $source->getHistory());
|
||||
$this->origins = array_merge($this->getOrigins(), $source->getOrigins());
|
||||
$this->rhythms = array_merge($this->getRhythms(), $source->getRhythms());
|
||||
$this->tuneSettings = array_merge($this->getSettings(), $source->getSettings());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \XaiCorp\AbcParser\Domain\Core\Tune $otherTune
|
||||
* @return bool
|
||||
*/
|
||||
public function equals(Tune $otherTune)
|
||||
{
|
||||
//TODO:
|
||||
return $this->getTitles() === $otherTune->getTitles()
|
||||
&& $this->getRhythms() === $otherTune->getRhythms()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user