finished default parser
This commit is contained in:
204
src/Domain/Modules/Interpreter/Builder.php
Normal file
204
src/Domain/Modules/Interpreter/Builder.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use XaiCorp\AbcParser\Domain\Core\Author;
|
||||
use XaiCorp\AbcParser\Domain\Core\Composer;
|
||||
use XaiCorp\AbcParser\Domain\Core\Setting;
|
||||
use XaiCorp\AbcParser\Domain\Core\Transcriber;
|
||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||
use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
|
||||
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* @var Tune
|
||||
*/
|
||||
protected $tune;
|
||||
|
||||
/**
|
||||
* @var TuneCollection
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/**
|
||||
* @var Setting
|
||||
*/
|
||||
protected $setting;
|
||||
|
||||
/**
|
||||
* Interpreter constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->collection = new TuneCollection();
|
||||
$this->tune = new Tune([]);
|
||||
$this->setting = new Setting();
|
||||
|
||||
$this->tune->addSetting($this->setting);
|
||||
}
|
||||
|
||||
public function getTune()
|
||||
{
|
||||
return $this->tune;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \XaiCorp\AbcParser\Domain\Core\TuneCollection
|
||||
*/
|
||||
public function getCollection()
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function handleEndOfMusic()
|
||||
{
|
||||
if ($this->tune && empty($this->tune->getTitles())) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->tune->addSetting($this->setting);
|
||||
$this->collection[] = $this->tune;
|
||||
|
||||
$this->tune = new Tune([]);
|
||||
$this->setting = new Setting();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UnsignedIntegerAtom $index
|
||||
* @return $this
|
||||
*/
|
||||
public function setIndex(UnsignedIntegerAtom $index)
|
||||
{
|
||||
$this->tune->setIndex($index);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function appendMusic(StringAtom $musicLine)
|
||||
{
|
||||
$this->setting->addMusicLine($musicLine->getValue());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTitle(StringAtom $title)
|
||||
{
|
||||
$this->tune->addTitle($title->getValue());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKey(StringAtom $key)
|
||||
{
|
||||
$this->setting->setKey($key->getValue());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMeter(StringAtom $key)
|
||||
{
|
||||
$this->setting->setMeter($key->getValue());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAuthor(StringAtom $name)
|
||||
{
|
||||
$author = new Author($name, new EmailAtom(''));
|
||||
$this->tune->addAuthor($author);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addComposer(StringAtom $composerName)
|
||||
{
|
||||
$composer = new Composer($composerName, new EmailAtom(''));
|
||||
$this->tune->addComposer($composer);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTranscriber(StringAtom $transcriberName)
|
||||
{
|
||||
$transcriber = new Transcriber($transcriberName, new EmailAtom(''));
|
||||
$this->setting->addTranscriber($transcriber);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addDiscography(StringAtom $recording)
|
||||
{
|
||||
$this->setting->addRecording($recording->getValue());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addGroup(StringAtom $groupName)
|
||||
{
|
||||
$this->tune->addGroup($groupName->getValue());
|
||||
}
|
||||
|
||||
public function setParts(StringAtom $part)
|
||||
{
|
||||
$this->setting->setPart($part->getValue());
|
||||
}
|
||||
|
||||
public function addSource(StringAtom $source)
|
||||
{
|
||||
$this->setting->addSource($source->getValue());
|
||||
}
|
||||
|
||||
public function addFilename(StringAtom $filename)
|
||||
{
|
||||
$this->setting->addFilename($filename->getValue());
|
||||
}
|
||||
|
||||
public function addHistory(StringAtom $history)
|
||||
{
|
||||
$this->tune->addHistoryLine($history->getValue());
|
||||
}
|
||||
|
||||
public function addRhythm(StringAtom $rhythm)
|
||||
{
|
||||
$this->tune->addRhythm($rhythm->getValue());
|
||||
}
|
||||
|
||||
public function addBook(StringAtom $param)
|
||||
{
|
||||
$this->setting->addBook($param->getValue());
|
||||
}
|
||||
|
||||
public function addWords(StringAtom $param)
|
||||
{
|
||||
$this->setting->addWords($param->getValue());
|
||||
}
|
||||
|
||||
public function addTempo(StringAtom $param)
|
||||
{
|
||||
$this->setting->setTempo($param->getValue());
|
||||
}
|
||||
|
||||
public function addNoteLength(StringAtom $param)
|
||||
{
|
||||
$this->setting->setNoteLength($param->getValue());
|
||||
}
|
||||
|
||||
public function addNote(StringAtom $param)
|
||||
{
|
||||
$this->setting->addNote($param->getValue());
|
||||
}
|
||||
|
||||
public function addOrigin(StringAtom $param)
|
||||
{
|
||||
$this->tune->addOrigin($param->getValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user