Files
abcParser/src/Domain/Modules/Interpreter/Lexicon/Book.php
Richard Morgan 82dc3de079 start to add ability to merge tunes
started refactoring tune builders to use string type hint instead of StringAtom
2018-05-06 10:01:16 -04:00

42 lines
1005 B
PHP

<?php
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
use Enzyme\Axiom\Atoms\StringAtom;
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\Context;
class Book implements Lex
{
use LineKeyDataTrait;
/**
* @var TuneBuilder
*/
protected $builder;
public function __construct(TuneBuilder $builder)
{
$this->builder = $builder;
}
/**
* @param Context $context
* @param \Closure $next
* @return mixed
* @throws \Enzyme\Axiom\Exceptions\AtomException
*/
public function handle(Context $context, \Closure $next)
{
$line = $context->current();
list($key, $data) = $this->getKeyDataFromLine($line);
if ($key === 'B') {
$this->builder->addBook(new StringAtom($data));
}
return $next($context);
}
}