started refactoring tune builders to use string type hint instead of StringAtom
42 lines
1005 B
PHP
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);
|
|
}
|
|
}
|