start to add ability to merge tunes

started refactoring tune builders to use string type hint instead of StringAtom
This commit is contained in:
2018-05-06 10:01:16 -04:00
parent 655a04a501
commit 82dc3de079
34 changed files with 505 additions and 87 deletions

View File

@@ -124,6 +124,7 @@ class Tune implements EntityInterface
/**
* @param string $title
* @return $this
* @deprecated
*/
public function addTitle(string $title) : Tune
{
@@ -278,15 +279,19 @@ class Tune implements EntityInterface
call_user_func([$this, 'set'.$attribute], $value);
break;
case 'Authors':
call_user_func([$this, 'addAuthor'], $value);
break;
default:
$this->append($attribute, $value);
}
}
protected function append($attribute, array $values)
protected function append($attribute, MultivalueAttribute $values)
{
$method = 'add' . substr($attribute, 0, -1);
foreach ($values as $value) {
foreach ($values->toArray() as $value) {
call_user_func([$this, $method], $value);
}
}
@@ -329,13 +334,18 @@ class Tune implements EntityInterface
* @param StringAtom $musicLine
* @return $this
*/
public function appendMusicLine(string $musicLine)
public function addMusicLine(string $musicLine)
{
$this->music .= $musicLine->getValue() . PHP_EOL;
$this->music .= $musicLine . PHP_EOL;
return $this;
}
public function getMusic()
{
return $this->music;
}
public function merge(Tune $source)
{
//TODO