start to add ability to merge tunes
started refactoring tune builders to use string type hint instead of StringAtom
This commit is contained in:
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Application\UseCases;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Collection;
|
use XaiCorp\AbcParser\Domain\Core\Collection;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
@@ -12,19 +13,19 @@ use XaiCorp\AbcParser\Domain\Modules\Interpreter\Interpreter;
|
|||||||
class ImportAbcFile
|
class ImportAbcFile
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builderTemplate;
|
protected $builderTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder $builderTemplate
|
* @param TuneBuilder $builderTemplate
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $builderTemplate)
|
public function __construct(TuneBuilder $builderTemplate)
|
||||||
{
|
{
|
||||||
$this->builderTemplate = $builderTemplate;
|
$this->builderTemplate = $builderTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(Builder $builderTemplate = null)
|
public static function create(TuneBuilder $builderTemplate = null)
|
||||||
{
|
{
|
||||||
$builder = $builderTemplate ?: new Builder();
|
$builder = $builderTemplate ?: new Builder();
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ class Collection extends BaseCollection
|
|||||||
return array_reduce($this->items, $callback, $initial);
|
return array_reduce($this->items, $callback, $initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \XaiCorp\AbcParser\Domain\Core\Collection
|
||||||
|
*/
|
||||||
|
public function unique()
|
||||||
|
{
|
||||||
|
return new self(array_unique($this->items));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \XaiCorp\AbcParser\Domain\Core\Collection $collection
|
* @param \XaiCorp\AbcParser\Domain\Core\Collection $collection
|
||||||
* @return static
|
* @return static
|
||||||
|
|||||||
80
src/Domain/Core/MultivalueAttribute.php
Normal file
80
src/Domain/Core/MultivalueAttribute.php
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace XaiCorp\AbcParser\Domain\Core;
|
||||||
|
|
||||||
|
class MultivalueAttribute
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \XaiCorp\AbcParser\Domain\Core\Collection
|
||||||
|
*/
|
||||||
|
protected $data;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
$this->data = new Collection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $item
|
||||||
|
* @return \XaiCorp\AbcParser\Domain\Core\MultivalueAttribute
|
||||||
|
*/
|
||||||
|
public static function create(string $item)
|
||||||
|
{
|
||||||
|
return (new self())->add($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $items
|
||||||
|
* @return \XaiCorp\AbcParser\Domain\Core\MultivalueAttribute
|
||||||
|
*/
|
||||||
|
public static function createFromArray(array $items)
|
||||||
|
{
|
||||||
|
$attribute = new self();
|
||||||
|
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$attribute->add($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $item
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public function add(string $item)
|
||||||
|
{
|
||||||
|
$this->data = $this->data->push($item)->unique();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param MultivalueAttribute $attribute
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public function merge(MultivalueAttribute $attribute)
|
||||||
|
{
|
||||||
|
$this->data = $this->data
|
||||||
|
->pushArray($attribute->data->toArray())
|
||||||
|
->unique();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function first()
|
||||||
|
{
|
||||||
|
return $this->data->firstOrDefault('');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function toArray()
|
||||||
|
{
|
||||||
|
return $this->data->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,20 @@ class Person implements EntityInterface
|
|||||||
$this->setIdentity($identity);
|
$this->setIdentity($identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param \XaiCorp\AbcParser\Domain\Atoms\EmailAtom $email
|
||||||
|
* @param \Webpatser\Uuid\Uuid|null $identity
|
||||||
|
* @return static
|
||||||
|
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||||
|
*/
|
||||||
|
public static function create(string $name, EmailAtom $email, Uuid $identity = null)
|
||||||
|
{
|
||||||
|
$nameAtom = new StringAtom($name);
|
||||||
|
|
||||||
|
return new static($nameAtom, $email, $identity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this model has the given attribute set.
|
* Checks whether this model has the given attribute set.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class Tune implements EntityInterface
|
|||||||
/**
|
/**
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @return $this
|
* @return $this
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public function addTitle(string $title) : Tune
|
public function addTitle(string $title) : Tune
|
||||||
{
|
{
|
||||||
@@ -278,15 +279,19 @@ class Tune implements EntityInterface
|
|||||||
call_user_func([$this, 'set'.$attribute], $value);
|
call_user_func([$this, 'set'.$attribute], $value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'Authors':
|
||||||
|
call_user_func([$this, 'addAuthor'], $value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->append($attribute, $value);
|
$this->append($attribute, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function append($attribute, array $values)
|
protected function append($attribute, MultivalueAttribute $values)
|
||||||
{
|
{
|
||||||
$method = 'add' . substr($attribute, 0, -1);
|
$method = 'add' . substr($attribute, 0, -1);
|
||||||
foreach ($values as $value) {
|
foreach ($values->toArray() as $value) {
|
||||||
call_user_func([$this, $method], $value);
|
call_user_func([$this, $method], $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,13 +334,18 @@ class Tune implements EntityInterface
|
|||||||
* @param StringAtom $musicLine
|
* @param StringAtom $musicLine
|
||||||
* @return $this
|
* @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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMusic()
|
||||||
|
{
|
||||||
|
return $this->music;
|
||||||
|
}
|
||||||
|
|
||||||
public function merge(Tune $source)
|
public function merge(Tune $source)
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
|
|||||||
172
src/Domain/Core/TuneAttributeArrayBuilder.php
Normal file
172
src/Domain/Core/TuneAttributeArrayBuilder.php
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
namespace XaiCorp\AbcParser\Domain\Core;
|
||||||
|
|
||||||
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
|
use Webpatser\Uuid\Uuid;
|
||||||
|
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
|
||||||
|
class TuneAttributeArrayBuilder implements TuneBuilder
|
||||||
|
{
|
||||||
|
protected $attributes = [];
|
||||||
|
|
||||||
|
public static function create()
|
||||||
|
{
|
||||||
|
return new self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTune(Uuid $identity = null): \XaiCorp\AbcParser\Domain\Core\Tune
|
||||||
|
{
|
||||||
|
return new Tune($this->attributes, $identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function handleEndOfMusic()
|
||||||
|
{
|
||||||
|
// TODO: Implement handleEndOfMusic() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param UnsignedIntegerAtom $param
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIndex(UnsignedIntegerAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
|
{
|
||||||
|
$this->attributes['index'] = $param;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Enzyme\Axiom\Atoms\StringAtom $param
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function appendMusic(StringAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
|
{
|
||||||
|
$index = 'MusicLines';
|
||||||
|
$item = $param->getValue();
|
||||||
|
|
||||||
|
if (!isset($this->attributes[$index])) {
|
||||||
|
$this->attributes[$index] = MultivalueAttribute::create($item);
|
||||||
|
} else {
|
||||||
|
$this->attributes[$index]->add($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTitle(string $title): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
|
{
|
||||||
|
$index = 'Titles';
|
||||||
|
$item = $title;
|
||||||
|
|
||||||
|
if (!isset($this->attributes[$index])) {
|
||||||
|
$this->attributes[$index] = MultivalueAttribute::create($item);
|
||||||
|
} else {
|
||||||
|
$this->attributes[$index]->add($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setKey(StringAtom $key)
|
||||||
|
{
|
||||||
|
// TODO: Implement setKey() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMeter(StringAtom $key)
|
||||||
|
{
|
||||||
|
// TODO: Implement setMeter() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAuthor(string $name): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
|
{
|
||||||
|
$index = 'Authors';
|
||||||
|
$item = Author::create($name, new EmailAtom(''));
|
||||||
|
|
||||||
|
if (!isset($this->attributes[$index])) {
|
||||||
|
$this->attributes[$index] = $item;
|
||||||
|
} else {
|
||||||
|
$this->attributes[$index]->add($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addComposer(StringAtom $composerName)
|
||||||
|
{
|
||||||
|
// TODO: Implement addComposer() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTranscriber(StringAtom $transcriberName)
|
||||||
|
{
|
||||||
|
// TODO: Implement addTranscriber() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addDiscography(StringAtom $recording)
|
||||||
|
{
|
||||||
|
// TODO: Implement addDiscography() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addGroup(StringAtom $groupName)
|
||||||
|
{
|
||||||
|
// TODO: Implement addGroup() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setParts(StringAtom $part)
|
||||||
|
{
|
||||||
|
// TODO: Implement setParts() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSource(StringAtom $source)
|
||||||
|
{
|
||||||
|
// TODO: Implement addSource() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addFilename(StringAtom $filename)
|
||||||
|
{
|
||||||
|
// TODO: Implement addFilename() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addHistory(StringAtom $history)
|
||||||
|
{
|
||||||
|
// TODO: Implement addHistory() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRhythm(StringAtom $rhythm)
|
||||||
|
{
|
||||||
|
// TODO: Implement addRhythm() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addBook(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addBook() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWords(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addWords() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addTempo(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addTempo() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNoteLength(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addNoteLength() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNote(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addNote() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOrigin(StringAtom $param)
|
||||||
|
{
|
||||||
|
// TODO: Implement addOrigin() method.
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/Domain/Core/TuneBuilder.php
Normal file
69
src/Domain/Core/TuneBuilder.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: richard
|
||||||
|
* Date: 06/05/18
|
||||||
|
* Time: 8:16 AM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace XaiCorp\AbcParser\Domain\Core;
|
||||||
|
|
||||||
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
|
use Webpatser\Uuid\Uuid;
|
||||||
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
|
||||||
|
interface TuneBuilder
|
||||||
|
{
|
||||||
|
public function getTune(Uuid $identity = null): \XaiCorp\AbcParser\Domain\Core\Tune;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function handleEndOfMusic();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param UnsignedIntegerAtom $param
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setIndex(UnsignedIntegerAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
|
|
||||||
|
public function appendMusic(StringAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
|
|
||||||
|
public function addTitle(string $title): \XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
|
|
||||||
|
public function setKey(StringAtom $key);
|
||||||
|
|
||||||
|
public function setMeter(StringAtom $key);
|
||||||
|
|
||||||
|
public function addAuthor(string $name): \XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
|
|
||||||
|
public function addComposer(StringAtom $composerName);
|
||||||
|
|
||||||
|
public function addTranscriber(StringAtom $transcriberName);
|
||||||
|
|
||||||
|
public function addDiscography(StringAtom $recording);
|
||||||
|
|
||||||
|
public function addGroup(StringAtom $groupName);
|
||||||
|
|
||||||
|
public function setParts(StringAtom $part);
|
||||||
|
|
||||||
|
public function addSource(StringAtom $source);
|
||||||
|
|
||||||
|
public function addFilename(StringAtom $filename);
|
||||||
|
|
||||||
|
public function addHistory(StringAtom $history);
|
||||||
|
|
||||||
|
public function addRhythm(StringAtom $rhythm);
|
||||||
|
|
||||||
|
public function addBook(StringAtom $param);
|
||||||
|
|
||||||
|
public function addWords(StringAtom $param);
|
||||||
|
|
||||||
|
public function addTempo(StringAtom $param);
|
||||||
|
|
||||||
|
public function addNoteLength(StringAtom $param);
|
||||||
|
|
||||||
|
public function addNote(StringAtom $param);
|
||||||
|
|
||||||
|
public function addOrigin(StringAtom $param);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
|
use Webpatser\Uuid\Uuid;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Author;
|
use XaiCorp\AbcParser\Domain\Core\Author;
|
||||||
@@ -9,10 +10,11 @@ use XaiCorp\AbcParser\Domain\Core\Composer;
|
|||||||
use XaiCorp\AbcParser\Domain\Core\Setting;
|
use XaiCorp\AbcParser\Domain\Core\Setting;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Transcriber;
|
use XaiCorp\AbcParser\Domain\Core\Transcriber;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||||
use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
|
//use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
|
||||||
|
|
||||||
class Builder
|
class Builder implements TuneBuilder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Tune
|
* @var Tune
|
||||||
@@ -50,7 +52,7 @@ class Builder
|
|||||||
$this->tune->addSetting($this->setting);
|
$this->tune->addSetting($this->setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTune()
|
public function getTune(Uuid $identity = null): \XaiCorp\AbcParser\Domain\Core\Tune
|
||||||
{
|
{
|
||||||
return $this->tune;
|
return $this->tune;
|
||||||
}
|
}
|
||||||
@@ -64,7 +66,7 @@ class Builder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this
|
* @return TuneBuilder
|
||||||
*/
|
*/
|
||||||
public function handleEndOfMusic()
|
public function handleEndOfMusic()
|
||||||
{
|
{
|
||||||
@@ -82,26 +84,26 @@ class Builder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UnsignedIntegerAtom $index
|
* @param UnsignedIntegerAtom $param
|
||||||
* @return $this
|
* @return TuneBuilder
|
||||||
*/
|
*/
|
||||||
public function setIndex(UnsignedIntegerAtom $index)
|
public function setIndex(UnsignedIntegerAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
{
|
{
|
||||||
$this->tune->setIndex($index);
|
$this->tune->setIndex($param);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function appendMusic(StringAtom $musicLine)
|
public function appendMusic(StringAtom $param): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
{
|
{
|
||||||
$this->setting->addMusicLine($musicLine->getValue());
|
$this->setting->addMusicLine($param->getValue());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTitle(StringAtom $title)
|
public function addTitle(string $title): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
{
|
{
|
||||||
$this->tune->addTitle($title->getValue());
|
$this->tune->addTitle($title);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -120,9 +122,9 @@ class Builder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addAuthor(StringAtom $name)
|
public function addAuthor(string $name): \XaiCorp\AbcParser\Domain\Core\TuneBuilder
|
||||||
{
|
{
|
||||||
$author = new Author($name, new EmailAtom(''));
|
$author = Author::create($name, new EmailAtom(''));
|
||||||
$this->tune->addAuthor($author);
|
$this->tune->addAuthor($author);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ class DefaultInterpreter extends Interpreter
|
|||||||
$context->next();
|
$context->next();
|
||||||
} while ($context->count() > $context->key());
|
} while ($context->count() > $context->key());
|
||||||
|
|
||||||
// return $this->builder->getTune();
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
||||||
|
|
||||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||||
|
|
||||||
abstract class Interpreter
|
abstract class Interpreter
|
||||||
@@ -11,14 +12,14 @@ abstract class Interpreter
|
|||||||
const LN_FIELD = '/^\w:(.+)$/';
|
const LN_FIELD = '/^\w:(.+)$/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpreter constructor.
|
* Interpreter constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Author implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
@@ -32,7 +33,7 @@ class Author implements Lex
|
|||||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||||
|
|
||||||
if ($key === 'A') {
|
if ($key === 'A') {
|
||||||
$this->builder->addAuthor(new StringAtom($data));
|
$this->builder->addAuthor($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($context);
|
return $next($context);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Book implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Composer implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Discography implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class EndOfTune implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Filename implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Group implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class History implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Index implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class KeySignature implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Meter implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class MusicLine implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class NoteLength implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Notes implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Origin implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Parts implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Rhythm implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Source implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Tempo implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Title implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
@@ -32,7 +33,7 @@ class Title implements Lex
|
|||||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||||
|
|
||||||
if ($key === 'T') {
|
if ($key === 'T') {
|
||||||
$this->builder->addTitle(new StringAtom($data));
|
$this->builder->addTitle($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $next($context);
|
return $next($context);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Transcriber implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
|||||||
|
|
||||||
use Enzyme\Axiom\Atoms\StringAtom;
|
use Enzyme\Axiom\Atoms\StringAtom;
|
||||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||||
|
|
||||||
@@ -11,11 +12,11 @@ class Words implements Lex
|
|||||||
use LineKeyDataTrait;
|
use LineKeyDataTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Builder
|
* @var TuneBuilder
|
||||||
*/
|
*/
|
||||||
protected $builder;
|
protected $builder;
|
||||||
|
|
||||||
public function __construct(Builder $builder)
|
public function __construct(TuneBuilder $builder)
|
||||||
{
|
{
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: richard
|
||||||
|
* Date: 06/05/18
|
||||||
|
* Time: 8:28 AM
|
||||||
|
*/
|
||||||
|
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneAttributeArrayBuilder;
|
||||||
|
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||||
|
|
||||||
|
class TuneAttributeArrayBuilderTest extends \Codeception\Test\Unit
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testSetIndex()
|
||||||
|
{
|
||||||
|
$index = new UnsignedIntegerAtom('14');
|
||||||
|
$builder = new TuneAttributeArrayBuilder();
|
||||||
|
|
||||||
|
$tune = $builder->setIndex($index)->getTune();
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Tune::class, $tune);
|
||||||
|
$this->assertEquals($index->getValue(), $tune->getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAppendMusic()
|
||||||
|
{
|
||||||
|
$music = new \Enzyme\Axiom\Atoms\StringAtom('Abcd|');
|
||||||
|
$builder = new TuneAttributeArrayBuilder();
|
||||||
|
|
||||||
|
$tune = $builder->appendMusic($music)->getTune();
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Tune::class, $tune);
|
||||||
|
$this->assertEquals($music->getValue(), trim($tune->getMusic()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ use XaiCorp\AbcParser\Domain\Core\Author;
|
|||||||
use XaiCorp\AbcParser\Domain\Core\Composer;
|
use XaiCorp\AbcParser\Domain\Core\Composer;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||||
use XaiCorp\AbcParser\Domain\Core\Setting;
|
use XaiCorp\AbcParser\Domain\Core\Setting;
|
||||||
|
use XaiCorp\AbcParser\Domain\Core\TuneAttributeArrayBuilder;
|
||||||
|
|
||||||
class TuneTest extends \PHPUnit_Framework_TestCase
|
class TuneTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@@ -28,17 +29,15 @@ class TuneTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertInstanceOf(Tune::class, $tune);
|
$this->assertInstanceOf(Tune::class, $tune);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanIntializeFromArray()
|
public function testCanInitializeFromArray()
|
||||||
{
|
{
|
||||||
$titles = ['Title'];
|
$titles = ['Title'];
|
||||||
$authors = ['Richard Morgan'];
|
$authors = ['Richard Morgan'];
|
||||||
|
|
||||||
$config = [
|
$tune = TuneAttributeArrayBuilder::create()
|
||||||
'Titles' => $titles,
|
->addTitle($titles[0])
|
||||||
'Authors' => $authors
|
->addAuthor($authors[0])
|
||||||
];
|
->getTune();
|
||||||
|
|
||||||
$tune = new Tune($config);
|
|
||||||
|
|
||||||
$this->assertInstanceOf(Tune::class, $tune);
|
$this->assertInstanceOf(Tune::class, $tune);
|
||||||
$this->assertEquals($tune->getTitles(), $titles);
|
$this->assertEquals($tune->getTitles(), $titles);
|
||||||
@@ -187,17 +186,21 @@ class TuneTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testMergeAddsExtraDataToTune()
|
public function testMergeAddsExtraDataToTune()
|
||||||
{
|
{
|
||||||
$targetTune = new Tune([
|
$targetTune = TuneAttributeArrayBuilder::create()
|
||||||
'titles' => ['target']
|
->addTitle('target')
|
||||||
]);
|
->getTune();
|
||||||
$sourceTune = new Tune([
|
|
||||||
'titles' => ['source']
|
$sourceTune = TuneAttributeArrayBuilder::create()
|
||||||
]);
|
->addTitle('source')
|
||||||
|
->getTune();
|
||||||
|
|
||||||
|
$expected = TuneAttributeArrayBuilder::create()
|
||||||
|
->addTitle('target')
|
||||||
|
->addTitle('source')
|
||||||
|
->getTune($targetTune->identity());
|
||||||
|
|
||||||
$result = $targetTune->merge($sourceTune);
|
$result = $targetTune->merge($sourceTune);
|
||||||
|
|
||||||
$this->assertEquals(new Tune([
|
$this->assertEquals($expected, $result);
|
||||||
'titles' => ['target', 'source']
|
|
||||||
]), $result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user