Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be70c4e400 | |||
| 1130f9a22f | |||
| fb619dccbf | |||
| 348d17cdd3 | |||
| 2cdf7dd1cf | |||
| a530e8fd78 |
0
.env-testing
Normal file → Executable file
0
.env-testing
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
33
Jenkinsfile
vendored
Executable file
33
Jenkinsfile
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
pipeline {
|
||||
environment {
|
||||
WORKDIR = './'
|
||||
DOCKER_HOST = 'dkhost:2376'
|
||||
}
|
||||
|
||||
agent { label 'docker' }
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '2'))
|
||||
}
|
||||
triggers {
|
||||
cron('@weekly')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('prepare') {
|
||||
steps {
|
||||
checkout scm
|
||||
sh 'docker-compose run --rm composer install'
|
||||
sh 'ls'
|
||||
}
|
||||
}
|
||||
|
||||
stage('test') {
|
||||
steps {
|
||||
dir(WORKDIR) {
|
||||
//sh "DOCKER_HOST=${DOCKER_HOST} docker-compose -f docker-compose.prod.yml pull"
|
||||
sh "docker-compose run --rm tests"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
axiom_src/Atoms/AtomInterface.php
Normal file
13
axiom_src/Atoms/AtomInterface.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Atoms;
|
||||
|
||||
interface AtomInterface
|
||||
{
|
||||
/**
|
||||
* Get the underlying value associated with this atom.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue();
|
||||
}
|
||||
29
axiom_src/Atoms/IntegerAtom.php
Normal file
29
axiom_src/Atoms/IntegerAtom.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Atoms;
|
||||
|
||||
use Enzyme\Axiom\Exceptions\AtomException;
|
||||
|
||||
class IntegerAtom implements AtomInterface
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
if ($this->isInvalidOrFloat($value)) {
|
||||
throw new AtomException(get_class($this), $value);
|
||||
}
|
||||
|
||||
$this->value = (int)$value;
|
||||
}
|
||||
|
||||
protected function isInvalidOrFloat($value)
|
||||
{
|
||||
return is_numeric($value) === false || is_float($value) === true;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
24
axiom_src/Atoms/StringAtom.php
Normal file
24
axiom_src/Atoms/StringAtom.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Atoms;
|
||||
|
||||
use Enzyme\Axiom\Exceptions\AtomException;
|
||||
|
||||
class StringAtom implements AtomInterface
|
||||
{
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
if (is_string($value) === false) {
|
||||
throw new AtomException(get_class($this), $value);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
33
axiom_src/Bags/ArrayBag.php
Normal file
33
axiom_src/Bags/ArrayBag.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Bags;
|
||||
|
||||
class ArrayBag implements BagInterface
|
||||
{
|
||||
protected $store;
|
||||
|
||||
public function __construct(array $store)
|
||||
{
|
||||
$this->store = $store;
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return $this->store[$key];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->store[$key])
|
||||
&& array_key_exists($key, $this->store);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->store;
|
||||
}
|
||||
}
|
||||
32
axiom_src/Bags/BagInterface.php
Normal file
32
axiom_src/Bags/BagInterface.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Bags;
|
||||
|
||||
interface BagInterface
|
||||
{
|
||||
/**
|
||||
* Get the value associated with the given key. If the key does not
|
||||
* exist, return null instead.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key);
|
||||
|
||||
/**
|
||||
* Get all the key/value pairs for this bag.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll();
|
||||
|
||||
/**
|
||||
* Check whether there is a value associated with the given key.
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($key);
|
||||
}
|
||||
13
axiom_src/Exceptions/AtomException.php
Normal file
13
axiom_src/Exceptions/AtomException.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Exceptions;
|
||||
|
||||
class AtomException extends AxiomException
|
||||
{
|
||||
public function __construct($class, $value)
|
||||
{
|
||||
parent::__construct(
|
||||
"The atom [{$class}] could not process the value [{$value}]."
|
||||
);
|
||||
}
|
||||
}
|
||||
10
axiom_src/Exceptions/AxiomException.php
Normal file
10
axiom_src/Exceptions/AxiomException.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AxiomException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
28
axiom_src/Factories/FactoryInterface.php
Normal file
28
axiom_src/Factories/FactoryInterface.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Factories;
|
||||
|
||||
use Enzyme\Axiom\Bags\BagInterface;
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
|
||||
interface FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Make a new model given the data provided.
|
||||
*
|
||||
* @param BagInterface $data
|
||||
*
|
||||
* @return \Enzyme\Axiom\Models\ModelInterface
|
||||
*/
|
||||
public function make(BagInterface $data);
|
||||
|
||||
/**
|
||||
* Update the model provided with the given data.
|
||||
*
|
||||
* @param ModelInterface $model
|
||||
* @param BagInterface $data
|
||||
*
|
||||
* @return \Enzyme\Axiom\Models\ModelInterface
|
||||
*/
|
||||
public function update(ModelInterface $model, BagInterface $data);
|
||||
}
|
||||
38
axiom_src/Models/ModelInterface.php
Normal file
38
axiom_src/Models/ModelInterface.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Models;
|
||||
|
||||
interface ModelInterface
|
||||
{
|
||||
/**
|
||||
* Get the unique identity for this mode.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function identity();
|
||||
|
||||
/**
|
||||
* Checks whether this model has the given attribute set.
|
||||
*
|
||||
* @param string $attribute
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function has($attribute);
|
||||
|
||||
/**
|
||||
* Get the value associated with the given attribute.
|
||||
*
|
||||
* @param string $attribute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($attribute);
|
||||
|
||||
/**
|
||||
* Get all the attributes associated with this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll();
|
||||
}
|
||||
27
axiom_src/Recipients/OnCreateRecipientInterface.php
Normal file
27
axiom_src/Recipients/OnCreateRecipientInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Recipients;
|
||||
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
use Enzyme\Axiom\Reports\ReportInterface;
|
||||
|
||||
interface OnCreateRecipientInterface
|
||||
{
|
||||
/**
|
||||
* Called when the creation of a model was a success.
|
||||
*
|
||||
* @param ModelInterface $model The newly created model.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onCreateSuccess(ModelInterface $model);
|
||||
|
||||
/**
|
||||
* Called when the creation of a model was a failure.
|
||||
*
|
||||
* @param ReportInterface $report The failure report.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onCreateFailure(ReportInterface $report);
|
||||
}
|
||||
27
axiom_src/Recipients/OnDeleteRecipientInterface.php
Normal file
27
axiom_src/Recipients/OnDeleteRecipientInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Recipients;
|
||||
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
use Enzyme\Axiom\Reports\ReportInterface;
|
||||
|
||||
interface OnDeleteRecipientInterface
|
||||
{
|
||||
/**
|
||||
* Called when the deletion of a model was a success.
|
||||
*
|
||||
* @param ModelInterface $model A shell copy of the deleted model.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onDeleteSuccess(ModelInterface $model);
|
||||
|
||||
/**
|
||||
* Called when the deletion of a model was a failure.
|
||||
*
|
||||
* @param ReportInterface $report The failure report.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onDeleteFailure(ReportInterface $report);
|
||||
}
|
||||
27
axiom_src/Recipients/OnUpdateRecipientInterface.php
Normal file
27
axiom_src/Recipients/OnUpdateRecipientInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Recipients;
|
||||
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
use Enzyme\Axiom\Reports\ReportInterface;
|
||||
|
||||
interface OnUpdateRecipientInterface
|
||||
{
|
||||
/**
|
||||
* Called when the modification of a model was a success.
|
||||
*
|
||||
* @param ModelInterface $model The updated model.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onUpdateSuccess(ModelInterface $model);
|
||||
|
||||
/**
|
||||
* Called when the modification of a model was a failure.
|
||||
*
|
||||
* @param ReportInterface $report The failure report.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function onUpdateFailure(ReportInterface $report);
|
||||
}
|
||||
8
axiom_src/Reports/FailureReport.php
Normal file
8
axiom_src/Reports/FailureReport.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Reports;
|
||||
|
||||
class FailureReport extends SimpleReport
|
||||
{
|
||||
//
|
||||
}
|
||||
27
axiom_src/Reports/ReportInterface.php
Normal file
27
axiom_src/Reports/ReportInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Reports;
|
||||
|
||||
interface ReportInterface
|
||||
{
|
||||
/**
|
||||
* Get the human readable message associated with this report.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage();
|
||||
|
||||
/**
|
||||
* Whether this report has additional details.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasDetails();
|
||||
|
||||
/**
|
||||
* Get the additional details associated with this report.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDetails();
|
||||
}
|
||||
30
axiom_src/Reports/SimpleReport.php
Normal file
30
axiom_src/Reports/SimpleReport.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Reports;
|
||||
|
||||
class SimpleReport implements ReportInterface
|
||||
{
|
||||
protected $message;
|
||||
protected $details;
|
||||
|
||||
public function __construct($message, $details = [])
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function hasDetails()
|
||||
{
|
||||
return count($this->details) > 0;
|
||||
}
|
||||
|
||||
public function getDetails()
|
||||
{
|
||||
return $this->details;
|
||||
}
|
||||
}
|
||||
56
axiom_src/Repositories/InMemoryRepository.php
Normal file
56
axiom_src/Repositories/InMemoryRepository.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Repositories;
|
||||
|
||||
use Enzyme\Axiom\Atoms\AtomInterface;
|
||||
use Enzyme\Axiom\Bags\BagInterface;
|
||||
use Enzyme\Axiom\Factories\FactoryInterface;
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
|
||||
class InMemoryRepository implements RepositoryInterface
|
||||
{
|
||||
protected $factory;
|
||||
protected $store;
|
||||
|
||||
public function __construct(FactoryInterface $factory)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
$this->store = [];
|
||||
}
|
||||
|
||||
public function add(ModelInterface $model)
|
||||
{
|
||||
$this->store[$model->identity()] = $model;
|
||||
}
|
||||
|
||||
public function removeById(AtomInterface $id)
|
||||
{
|
||||
if ($this->has($id)) {
|
||||
unset($this->store[$id->getValue()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function has(AtomInterface $id)
|
||||
{
|
||||
return isset($this->store[$id->getValue()])
|
||||
&& array_key_exists($id->getValue(), $this->store);
|
||||
}
|
||||
|
||||
public function update(ModelInterface $model, BagInterface $data)
|
||||
{
|
||||
$updated_model = $this->factory->update($model, $data);
|
||||
$this->store[$model->identity()] = $updated_model;
|
||||
}
|
||||
|
||||
public function getById(AtomInterface $id)
|
||||
{
|
||||
return $this->has($id)
|
||||
? $this->store[$id->getValue()]
|
||||
: null;
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->store;
|
||||
}
|
||||
}
|
||||
61
axiom_src/Repositories/RepositoryInterface.php
Normal file
61
axiom_src/Repositories/RepositoryInterface.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Enzyme\Axiom\Repositories;
|
||||
|
||||
use Enzyme\Axiom\Atoms\AtomInterface;
|
||||
use Enzyme\Axiom\Bags\BagInterface;
|
||||
use Enzyme\Axiom\Models\ModelInterface;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Add the given model to the repository.
|
||||
*
|
||||
* @param ModelInterface $model
|
||||
*/
|
||||
public function add(ModelInterface $model);
|
||||
|
||||
/**
|
||||
* Remove the model with the given ID from the repository.
|
||||
*
|
||||
* @param AtomInterface $id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeById(AtomInterface $id);
|
||||
|
||||
/**
|
||||
* Update the given model with the supplied data.
|
||||
*
|
||||
* @param ModelInterface $model
|
||||
* @param BagInterface $data
|
||||
*
|
||||
* @return \Enzyme\Axiom\Models\ModelInterface
|
||||
*/
|
||||
public function update(ModelInterface $model, BagInterface $data);
|
||||
|
||||
/**
|
||||
* Get the model associated with the given ID.
|
||||
*
|
||||
* @param AtomInterface $id
|
||||
*
|
||||
* @return \Enzyme\Axiom\Models\ModelInterface
|
||||
*/
|
||||
public function getById(AtomInterface $id);
|
||||
|
||||
/**
|
||||
* Get all models from this repository.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll();
|
||||
|
||||
/**
|
||||
* Check whether this repository has a model associated with the given ID.
|
||||
*
|
||||
* @param AtomInterface $id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function has(AtomInterface $id);
|
||||
}
|
||||
37
axiom_tests/Atoms/IntegerAtomTest.php
Normal file
37
axiom_tests/Atoms/IntegerAtomTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Atoms\IntegerAtom;
|
||||
|
||||
class IntegerAtomTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_atom_stores_correct_base_value()
|
||||
{
|
||||
$expected = 5;
|
||||
$atom = new IntegerAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
|
||||
$expected = 25;
|
||||
$atom = new IntegerAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
|
||||
$expected = PHP_INT_MAX;
|
||||
$atom = new IntegerAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function test_atom_throws_exception_when_initialised_with_invalid_value()
|
||||
{
|
||||
new IntegerAtom('foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function test_atom_throws_exception_when_initialised_with_floating_value()
|
||||
{
|
||||
new IntegerAtom(100.5);
|
||||
}
|
||||
}
|
||||
29
axiom_tests/Atoms/StringAtomTest.php
Normal file
29
axiom_tests/Atoms/StringAtomTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
|
||||
class StringAtomTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_atom_stores_correct_base_value()
|
||||
{
|
||||
$expected = 'Foo Bar';
|
||||
$atom = new StringAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
|
||||
$expected = '25';
|
||||
$atom = new StringAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
|
||||
$expected = '';
|
||||
$atom = new StringAtom($expected);
|
||||
$this->assertEquals($expected, $atom->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function test_atom_throws_exception_when_initialised_with_invalid_value()
|
||||
{
|
||||
new StringAtom(5);
|
||||
}
|
||||
}
|
||||
34
axiom_tests/Bags/ArrayBagTest.php
Normal file
34
axiom_tests/Bags/ArrayBagTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Bags\ArrayBag;
|
||||
|
||||
class ArrayBagTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_bag_stores_value_as_expected()
|
||||
{
|
||||
$expected = 'Bar';
|
||||
$bag = new ArrayBag(['foo' => $expected]);
|
||||
$this->assertEquals($expected, $bag->get('foo'));
|
||||
}
|
||||
|
||||
public function test_bag_returns_null_for_unknown_key()
|
||||
{
|
||||
$expected = null;
|
||||
$bag = new ArrayBag(['foo' => 'bar']);
|
||||
$this->assertEquals($expected, $bag->get('PHP'));
|
||||
}
|
||||
|
||||
public function test_bag_stores_values_as_expected()
|
||||
{
|
||||
$expected = ['foo' => 'Bar', 'PHP' => 'Rulez'];
|
||||
$bag = new ArrayBag($expected);
|
||||
$this->assertEquals($expected, $bag->getAll());
|
||||
}
|
||||
|
||||
public function test_bag_reports_stored_value_as_expected()
|
||||
{
|
||||
$expected = true;
|
||||
$bag = new ArrayBag(['foo' => 'bar']);
|
||||
$this->assertEquals($expected, $bag->has('foo'));
|
||||
}
|
||||
}
|
||||
96
axiom_tests/Console/ConfigTest.php
Normal file
96
axiom_tests/Console/ConfigTest.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Console\Config;
|
||||
use Enzyme\Freckle\Dot;
|
||||
use Mockery as m;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
class ConfigTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
}
|
||||
|
||||
public function test_config_returns_early_when_file_does_not_exist()
|
||||
{
|
||||
$file = 'fake.yaml';
|
||||
$file_dispatch = m::mock(
|
||||
'Enzyme\Parrot\File[exists]',
|
||||
function ($mock) use ($file) {
|
||||
$mock
|
||||
->shouldReceive('exists')
|
||||
->with($file)
|
||||
->times(1)
|
||||
->andReturn(false);
|
||||
}
|
||||
);
|
||||
|
||||
$config = new Config(new Parser, $file_dispatch, new Dot);
|
||||
$config->parse($file);
|
||||
}
|
||||
|
||||
public function test_config_stores_correct_values_from_valid_yaml_file()
|
||||
{
|
||||
$file = 'fake.yaml';
|
||||
$contents = "repositories:\n";
|
||||
$contents .= " - location: ~/Code/Acme/src/Repos\n";
|
||||
$contents .= " - namespace: Acme\Repos\n";
|
||||
$file_dispatch = m::mock(
|
||||
'Enzyme\Parrot\File[exists,getContents]',
|
||||
function ($mock) use ($file, $contents) {
|
||||
$mock
|
||||
->shouldReceive('exists')
|
||||
->with($file)
|
||||
->times(1)
|
||||
->andReturn(true);
|
||||
$mock
|
||||
->shouldReceive('getContents')
|
||||
->with($file)
|
||||
->times(1)
|
||||
->andReturn($contents);
|
||||
}
|
||||
);
|
||||
|
||||
$config = new Config(new Parser, $file_dispatch, new Dot);
|
||||
$config->parse($file);
|
||||
$expected = '~/Code/Acme/src/Repos';
|
||||
$actual = $config->get('repositories.location');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function test_config_throws_exception_on_bad_yaml_parse()
|
||||
{
|
||||
$file = 'fake.yaml';
|
||||
$parser = m::mock(
|
||||
'Symfony\Component\Yaml\Parser[parse]',
|
||||
function ($mock) {
|
||||
$mock
|
||||
->shouldReceive('parse')
|
||||
->andThrow(new InvalidArgumentException('oops'));
|
||||
}
|
||||
);
|
||||
$file_dispatch = m::mock(
|
||||
'Enzyme\Parrot\File[exists,getContents]',
|
||||
function ($mock) use ($file) {
|
||||
$mock
|
||||
->shouldReceive('exists')
|
||||
->with($file)
|
||||
->times(1)
|
||||
->andReturn(true);
|
||||
$mock
|
||||
->shouldReceive('getContents')
|
||||
->with($file)
|
||||
->times(1)
|
||||
->andReturn('bad');
|
||||
}
|
||||
);
|
||||
|
||||
$config = new Config($parser, $file_dispatch, new Dot);
|
||||
$config->parse($file);
|
||||
}
|
||||
}
|
||||
33
axiom_tests/Reports/SimpleReportTest.php
Normal file
33
axiom_tests/Reports/SimpleReportTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Reports\SimpleReport;
|
||||
|
||||
class SimpleReportTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_report_stores_message_as_expected()
|
||||
{
|
||||
$expected = 'Something went wrong.';
|
||||
$report = new SimpleReport($expected);
|
||||
$this->assertEquals($expected, $report->getMessage());
|
||||
}
|
||||
|
||||
public function test_report_stores_details_as_expected()
|
||||
{
|
||||
$expected = ['tests' => 'required'];
|
||||
$report = new SimpleReport('Foo Bar went pear shaped.', $expected);
|
||||
$this->assertEquals($expected, $report->getDetails());
|
||||
}
|
||||
|
||||
public function test_report_reports_details_as_expected()
|
||||
{
|
||||
$expected = true;
|
||||
$report = new SimpleReport(
|
||||
'It went pear shaped again.', ['tests' => 'required']
|
||||
);
|
||||
$this->assertEquals($expected, $report->hasDetails());
|
||||
|
||||
$expected = false;
|
||||
$report = new SimpleReport('Foo Bar went pear shaped.');
|
||||
$this->assertEquals($expected, $report->hasDetails());
|
||||
}
|
||||
}
|
||||
79
axiom_tests/Repositories/InMemoryRepositoryTest.php
Normal file
79
axiom_tests/Repositories/InMemoryRepositoryTest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Enzyme\Axiom\Atoms\IntegerAtom;
|
||||
use Enzyme\Axiom\Bags\ArrayBag;
|
||||
use Enzyme\Axiom\Repositories\InMemoryRepository;
|
||||
use Mockery as m;
|
||||
|
||||
class InMemoryRepositoryTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function tearDown()
|
||||
{
|
||||
m::close();
|
||||
}
|
||||
|
||||
public function test_repository_stores_models_as_expected()
|
||||
{
|
||||
$identity = 0;
|
||||
$factory = m::mock('Enzyme\Axiom\Factories\FactoryInterface');
|
||||
$model = m::mock('Enzyme\Axiom\Models\ModelInterface', function ($mock) use ($identity) {
|
||||
$mock->shouldReceive('identity')->once()->andReturn($identity);
|
||||
});
|
||||
|
||||
$repo = new InMemoryRepository($factory);
|
||||
$repo->add($model);
|
||||
|
||||
// Let's make sure the repo reports the new model as existing.
|
||||
$expected = true;
|
||||
$this->assertEquals($expected, $repo->has(new IntegerAtom($identity)));
|
||||
|
||||
// And make sure it returns the new model as expected.
|
||||
$expected = $model;
|
||||
$this->assertEquals($expected, $repo->getById(new IntegerAtom($identity)));
|
||||
|
||||
// And that the new model is the only model currently associated with this repo.
|
||||
$expected = [$model];
|
||||
$this->assertEquals($expected, $repo->getAll());
|
||||
}
|
||||
|
||||
public function test_repository_removes_models_as_expected()
|
||||
{
|
||||
$identity = 0;
|
||||
$factory = m::mock('Enzyme\Axiom\Factories\FactoryInterface');
|
||||
$model = m::mock('Enzyme\Axiom\Models\ModelInterface', function ($mock) use ($identity) {
|
||||
$mock->shouldReceive('identity')->once()->andReturn($identity);
|
||||
});
|
||||
|
||||
$repo = new InMemoryRepository($factory);
|
||||
$repo->add($model);
|
||||
$repo->removeById(new IntegerAtom($identity));
|
||||
|
||||
// Let's make sure the repo reports the model as non-existent.
|
||||
$expected = false;
|
||||
$this->assertEquals($expected, $repo->has(new IntegerAtom($identity)));
|
||||
|
||||
// And make sure it returns null if the model is requested.
|
||||
$expected = null;
|
||||
$this->assertEquals($expected, $repo->getById(new IntegerAtom($identity)));
|
||||
|
||||
// And that the new model is not currently associated with this repo's collection.
|
||||
$expected = [];
|
||||
$this->assertEquals($expected, $repo->getAll());
|
||||
}
|
||||
|
||||
public function test_repository_delegates_updates_to_factory_dependency_as_expected()
|
||||
{
|
||||
$identity = 0;
|
||||
$model = m::mock('Enzyme\Axiom\Models\ModelInterface', function ($mock) use ($identity) {
|
||||
$mock->shouldReceive('identity')->andReturn($identity);
|
||||
});
|
||||
$bag = new ArrayBag([]);
|
||||
$factory = m::mock('Enzyme\Axiom\Factories\FactoryInterface', function ($mock) use ($model, $bag) {
|
||||
$mock->shouldReceive('update')->once()->with($model, $bag)->andReturn($model);
|
||||
});
|
||||
|
||||
$repo = new InMemoryRepository($factory);
|
||||
$repo->add($model);
|
||||
$repo->update($model, $bag);
|
||||
}
|
||||
}
|
||||
56
axiom_tests/phpunit.xml
Normal file
56
axiom_tests/phpunit.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
|
||||
backupGlobals="true"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
cacheTokens="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
forceCoversAnnotation="false"
|
||||
mapTestClassNameToCoveredClassName="false"
|
||||
printerClass="PHPUnit_TextUI_ResultPrinter"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
stopOnIncomplete="false"
|
||||
stopOnSkipped="false"
|
||||
stopOnRisky="false"
|
||||
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
|
||||
timeoutForSmallTests="1"
|
||||
timeoutForMediumTests="10"
|
||||
timeoutForLargeTests="60"
|
||||
verbose="true">
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">console</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<testsuites>
|
||||
<testsuite name="Console Test Suite">
|
||||
<directory>tests/Console</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Atoms Test Suite">
|
||||
<directory>tests/Atoms</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Bags Test Suite">
|
||||
<directory>tests/Bags</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Reports Test Suite">
|
||||
<directory>tests/Reports</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Repositories Test Suite">
|
||||
<directory>tests/Repositories</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
14
codeception.yml
Normal file → Executable file
14
codeception.yml
Normal file → Executable file
@@ -12,10 +12,10 @@ settings:
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
#modules:
|
||||
# config:
|
||||
# Db:
|
||||
# dsn: ''
|
||||
# user: ''
|
||||
# password: ''
|
||||
# dump: tests/_data/dump.sql
|
||||
|
||||
29
composer.json
Normal file → Executable file
29
composer.json
Normal file → Executable file
@@ -10,20 +10,22 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"zackkitzmiller/tiny": "^1.2",
|
||||
"webpatser/laravel-uuid": "^2.0",
|
||||
"enzyme/axiom": "^4.2",
|
||||
"enzyme/freckle": "^0.3.0",
|
||||
"illuminate/database": "^5.5",
|
||||
"php": ">=7.2",
|
||||
"enzyme/collection": "^1.0",
|
||||
"illuminate/Pipeline": "^5.5",
|
||||
"league/pipeline": "^0.3.0",
|
||||
"php-deal/framework": "^0.4.1"
|
||||
"enzyme/freckle": "^0.3.0",
|
||||
"enzyme/parrot": "^0.0.2",
|
||||
"icanboogie/inflector": "^1.4",
|
||||
"illuminate/database": "^7.0",
|
||||
"illuminate/pipeline": "^7.0",
|
||||
"league/pipeline": "^1.0",
|
||||
"php-deal/framework": "^0.4.1",
|
||||
"webpatser/laravel-uuid": "^3.0",
|
||||
"zackkitzmiller/tiny": "^1.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"XaiCorp\\AbcParser\\": "src/"
|
||||
"XaiCorp\\AbcParser\\": "src/",
|
||||
"Enzyme\\Axiom\\": "axiom_src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@@ -33,9 +35,10 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^2.4",
|
||||
"squizlabs/php_codesniffer": "^3.1",
|
||||
"codeception/codeception": "^4.1",
|
||||
"codeception/module-asserts": "^1.2",
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpmd/phpmd": "^2.6",
|
||||
"mockery/mockery": "^1.0"
|
||||
"squizlabs/php_codesniffer": "^3.2"
|
||||
}
|
||||
}
|
||||
|
||||
6145
composer.lock
generated
Normal file → Executable file
6145
composer.lock
generated
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
0
database/migrations/.gitkeep
Normal file → Executable file
0
database/migrations/.gitkeep
Normal file → Executable file
2
database/migrations/2014_10_12_000000_create_users_table.php
Normal file → Executable file
2
database/migrations/2014_10_12_000000_create_users_table.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
|
||||
2
database/migrations/2014_10_12_100000_create_password_resets_table.php
Normal file → Executable file
2
database/migrations/2014_10_12_100000_create_password_resets_table.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
|
||||
2
database/migrations/2015_11_07_012716_create_parseabc_tables.php
Normal file → Executable file
2
database/migrations/2015_11_07_012716_create_parseabc_tables.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateParseabcTables extends Migration
|
||||
{
|
||||
|
||||
2
database/migrations/2016_03_06_021725_create_jobs_table.php
Normal file → Executable file
2
database/migrations/2016_03_06_021725_create_jobs_table.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
|
||||
2
database/migrations/2016_03_06_021806_create_failed_jobs_table.php
Normal file → Executable file
2
database/migrations/2016_03_06_021806_create_failed_jobs_table.php
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateFailedJobsTable extends Migration
|
||||
{
|
||||
|
||||
18
docker-compose.yml
Normal file → Executable file
18
docker-compose.yml
Normal file → Executable file
@@ -1,17 +1,21 @@
|
||||
version: '2'
|
||||
version: '3'
|
||||
services:
|
||||
|
||||
parser:
|
||||
image: abc-api/api:latest
|
||||
tests:
|
||||
image: dkregistry.xai-corp.net:5000/xaicorp/php:7.3-dev
|
||||
volumes:
|
||||
- .:/var/www
|
||||
- .:/opt/project
|
||||
entrypoint:
|
||||
- vendor/bin/codecept
|
||||
command:
|
||||
- run
|
||||
|
||||
parser-composer:
|
||||
image: composer/composer:alpine
|
||||
composer:
|
||||
image: dkregistry.xai-corp.net:5000/xaicorp/composer:7.2
|
||||
volumes:
|
||||
- .:/app
|
||||
- ~/.ssh:/root/.ssh
|
||||
- .:/opt/project
|
||||
# - ~/.ssh:/root/.ssh
|
||||
entrypoint:
|
||||
- composer
|
||||
command:
|
||||
|
||||
0
src/Application/Boundary/PersonMapper.php
Normal file → Executable file
0
src/Application/Boundary/PersonMapper.php
Normal file → Executable file
0
src/Application/PersonFactory.php
Normal file → Executable file
0
src/Application/PersonFactory.php
Normal file → Executable file
0
src/Application/PersonRepository.php
Normal file → Executable file
0
src/Application/PersonRepository.php
Normal file → Executable file
0
src/Application/UseCases/ExtractTuneFromCollection.php
Normal file → Executable file
0
src/Application/UseCases/ExtractTuneFromCollection.php
Normal file → Executable file
0
src/Application/UseCases/ImportAbcFile.php
Normal file → Executable file
0
src/Application/UseCases/ImportAbcFile.php
Normal file → Executable file
3
src/Domain/Atoms/EmailAtom.php
Normal file → Executable file
3
src/Domain/Atoms/EmailAtom.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
namespace XaiCorp\AbcParser\Domain\Atoms;
|
||||
|
||||
use Enzyme\Axiom\Atoms\AtomInterface;
|
||||
use Exception;
|
||||
|
||||
class EmailAtom implements AtomInterface
|
||||
{
|
||||
@@ -26,7 +27,7 @@ class EmailAtom implements AtomInterface
|
||||
private function validateEmail($value)
|
||||
{
|
||||
if (!$this->isValid($value)) {
|
||||
throw new \Exception('Not a valid email');
|
||||
throw new Exception('Not a valid email');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
0
src/Domain/Atoms/UnsignedIntegerAtom.php
Normal file → Executable file
0
src/Domain/Atoms/UnsignedIntegerAtom.php
Normal file → Executable file
0
src/Domain/Boundary/PersonFactory.php
Normal file → Executable file
0
src/Domain/Boundary/PersonFactory.php
Normal file → Executable file
0
src/Domain/Boundary/PersonRepository.php
Normal file → Executable file
0
src/Domain/Boundary/PersonRepository.php
Normal file → Executable file
0
src/Domain/Core/AttributeTrait.php
Normal file → Executable file
0
src/Domain/Core/AttributeTrait.php
Normal file → Executable file
0
src/Domain/Core/Author.php
Normal file → Executable file
0
src/Domain/Core/Author.php
Normal file → Executable file
0
src/Domain/Core/Collection.php
Normal file → Executable file
0
src/Domain/Core/Collection.php
Normal file → Executable file
0
src/Domain/Core/Composer.php
Normal file → Executable file
0
src/Domain/Core/Composer.php
Normal file → Executable file
0
src/Domain/Core/EntityInterface.php
Normal file → Executable file
0
src/Domain/Core/EntityInterface.php
Normal file → Executable file
0
src/Domain/Core/IdentityTrait.php
Normal file → Executable file
0
src/Domain/Core/IdentityTrait.php
Normal file → Executable file
0
src/Domain/Core/MultivalueAttribute.php
Normal file → Executable file
0
src/Domain/Core/MultivalueAttribute.php
Normal file → Executable file
3
src/Domain/Core/Person.php
Normal file → Executable file
3
src/Domain/Core/Person.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
namespace XaiCorp\AbcParser\Domain\Core;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use Exception;
|
||||
use Webpatser\Uuid\Uuid;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
|
||||
|
||||
@@ -69,7 +70,7 @@ class Person implements EntityInterface
|
||||
public function get($attribute)
|
||||
{
|
||||
if (!$this->has($attribute)) {
|
||||
throw new \Exception('Cannot access attribute on person');
|
||||
throw new Exception('Cannot access attribute on person');
|
||||
}
|
||||
|
||||
return $this->{$attribute};
|
||||
|
||||
2
src/Domain/Core/Setting.php
Normal file → Executable file
2
src/Domain/Core/Setting.php
Normal file → Executable file
@@ -2,8 +2,6 @@
|
||||
namespace XaiCorp\AbcParser\Domain\Core;
|
||||
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
|
||||
class Setting
|
||||
{
|
||||
use IdentityTrait;
|
||||
|
||||
0
src/Domain/Core/Transcriber.php
Normal file → Executable file
0
src/Domain/Core/Transcriber.php
Normal file → Executable file
4
src/Domain/Core/Tune.php
Normal file → Executable file
4
src/Domain/Core/Tune.php
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Core;
|
||||
|
||||
use Enzyme\Axiom\Atoms\IntegerAtom;
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use Illuminate\Support\Arr;
|
||||
use Webpatser\Uuid\Uuid;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
|
||||
@@ -82,7 +82,7 @@ class Tune implements EntityInterface
|
||||
|
||||
public function getETag()
|
||||
{
|
||||
return md5(implode(';', array_flatten([
|
||||
return md5(implode(';', Arr::flatten([
|
||||
$this->getTitles(),
|
||||
$this->getAuthors(),
|
||||
$this->getComposers(),
|
||||
|
||||
0
src/Domain/Core/TuneAttributeArrayBuilder.php
Normal file → Executable file
0
src/Domain/Core/TuneAttributeArrayBuilder.php
Normal file → Executable file
0
src/Domain/Core/TuneBuilder.php
Normal file → Executable file
0
src/Domain/Core/TuneBuilder.php
Normal file → Executable file
0
src/Domain/Core/TuneCollection.php
Normal file → Executable file
0
src/Domain/Core/TuneCollection.php
Normal file → Executable file
1
src/Domain/Modules/Interpreter/Builder.php
Normal file → Executable file
1
src/Domain/Modules/Interpreter/Builder.php
Normal file → Executable file
@@ -12,6 +12,7 @@ use XaiCorp\AbcParser\Domain\Core\Transcriber;
|
||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||
|
||||
//use XaiCorp\AbcParser\Models\Laravel5\TuneSetting;
|
||||
|
||||
class Builder implements TuneBuilder
|
||||
|
||||
0
src/Domain/Modules/Interpreter/Context.php
Normal file → Executable file
0
src/Domain/Modules/Interpreter/Context.php
Normal file → Executable file
2
src/Domain/Modules/Interpreter/DefaultInterpreter.php
Normal file → Executable file
2
src/Domain/Modules/Interpreter/DefaultInterpreter.php
Normal file → Executable file
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon\Author;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon\Book;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon\Composer;
|
||||
|
||||
1
src/Domain/Modules/Interpreter/Interpreter.php
Normal file → Executable file
1
src/Domain/Modules/Interpreter/Interpreter.php
Normal file → Executable file
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter;
|
||||
|
||||
use XaiCorp\AbcParser\Domain\Core\Tune;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneCollection;
|
||||
|
||||
|
||||
0
src/Domain/Modules/Interpreter/InterpreterPipeline.php
Normal file → Executable file
0
src/Domain/Modules/Interpreter/InterpreterPipeline.php
Normal file → Executable file
8
src/Domain/Modules/Interpreter/Lexicon/Author.php
Normal file → Executable file
8
src/Domain/Modules/Interpreter/Lexicon/Author.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Author implements Lex
|
||||
@@ -27,10 +25,10 @@ class Author implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'A') {
|
||||
$this->builder->addAuthor($data);
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Book.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Book.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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
|
||||
@@ -27,10 +26,10 @@ class Book implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'B') {
|
||||
$this->builder->addBook(new StringAtom($data));
|
||||
|
||||
8
src/Domain/Modules/Interpreter/Lexicon/Composer.php
Normal file → Executable file
8
src/Domain/Modules/Interpreter/Lexicon/Composer.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Composer implements Lex
|
||||
@@ -27,10 +25,10 @@ class Composer implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'C') {
|
||||
$this->builder->addComposer($data);
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Discography.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Discography.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Discography implements Lex
|
||||
@@ -27,10 +26,10 @@ class Discography implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'D') {
|
||||
$this->builder->addDiscography(new StringAtom($data));
|
||||
|
||||
6
src/Domain/Modules/Interpreter/Lexicon/EndOfTune.php
Normal file → Executable file
6
src/Domain/Modules/Interpreter/Lexicon/EndOfTune.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class EndOfTune implements Lex
|
||||
@@ -27,7 +25,7 @@ class EndOfTune implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
// list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Filename.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Filename.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Filename implements Lex
|
||||
@@ -27,10 +26,10 @@ class Filename implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'F'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Group.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Group.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Group implements Lex
|
||||
@@ -27,10 +26,10 @@ class Group implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'G') {
|
||||
$this->builder->addGroup(new StringAtom($data));
|
||||
|
||||
10
src/Domain/Modules/Interpreter/Lexicon/History.php
Normal file → Executable file
10
src/Domain/Modules/Interpreter/Lexicon/History.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class History implements Lex
|
||||
@@ -28,10 +26,10 @@ class History implements Lex
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
* @throws \Enzyme\Collection\CollectionException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'H'
|
||||
&& $context->isState($context::MODE_TUNE_HEADER)
|
||||
@@ -57,7 +55,7 @@ class History implements Lex
|
||||
private function nextLineNotHistory(Context $context)
|
||||
{
|
||||
$nextLine = $context->get($context->key() + 1);
|
||||
list($key, $data) = $this->getKeyDataFromLine($nextLine);
|
||||
[$key, $data] = $this->getKeyDataFromLine($nextLine);
|
||||
return $key !== '';
|
||||
}
|
||||
}
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Index.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Index.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use Closure;
|
||||
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 Index implements Lex
|
||||
@@ -21,10 +20,10 @@ class Index implements Lex
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'X') {
|
||||
$context->setStateInTuneHeader();
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/KeySignature.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/KeySignature.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 KeySignature implements Lex
|
||||
@@ -27,10 +26,10 @@ class KeySignature implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($context->getState() === $context::MODE_TUNE_HEADER && $key === 'K') {
|
||||
$this->builder->setKey(new StringAtom($data));
|
||||
|
||||
0
src/Domain/Modules/Interpreter/Lexicon/Lex.php
Normal file → Executable file
0
src/Domain/Modules/Interpreter/Lexicon/Lex.php
Normal file → Executable file
0
src/Domain/Modules/Interpreter/Lexicon/LineKeyDataTrait.php
Normal file → Executable file
0
src/Domain/Modules/Interpreter/Lexicon/LineKeyDataTrait.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Meter.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Meter.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Meter implements Lex
|
||||
@@ -27,10 +26,10 @@ class Meter implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'M'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
|
||||
8
src/Domain/Modules/Interpreter/Lexicon/MusicLine.php
Normal file → Executable file
8
src/Domain/Modules/Interpreter/Lexicon/MusicLine.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class MusicLine implements Lex
|
||||
@@ -27,10 +25,10 @@ class MusicLine implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($context->getState() === $context::MODE_TUNE_BODY
|
||||
&& $key !== 'K'
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/NoteLength.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/NoteLength.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 NoteLength implements Lex
|
||||
@@ -27,10 +26,10 @@ class NoteLength implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'L') {
|
||||
$this->builder->addNoteLength(new StringAtom($data));
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Notes.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Notes.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Notes implements Lex
|
||||
@@ -27,10 +26,10 @@ class Notes implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'N') {
|
||||
$this->builder->addNote(new StringAtom($data));
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Origin.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Origin.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Origin implements Lex
|
||||
@@ -27,10 +26,10 @@ class Origin implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'O') {
|
||||
$this->builder->addOrigin(new StringAtom($data));
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Parts.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Parts.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Parts implements Lex
|
||||
@@ -27,10 +26,10 @@ class Parts implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'P'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Rhythm.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Rhythm.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Rhythm implements Lex
|
||||
@@ -27,10 +26,10 @@ class Rhythm implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'R'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Source.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Source.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Source implements Lex
|
||||
@@ -27,10 +26,10 @@ class Source implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'S'
|
||||
&& $context->getState() === $context::MODE_TUNE_HEADER
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Tempo.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Tempo.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Tempo implements Lex
|
||||
@@ -27,10 +26,10 @@ class Tempo implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'Q') {
|
||||
$this->builder->addTempo(new StringAtom($data));
|
||||
|
||||
8
src/Domain/Modules/Interpreter/Lexicon/Title.php
Normal file → Executable file
8
src/Domain/Modules/Interpreter/Lexicon/Title.php
Normal file → Executable file
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Enzyme\Axiom\Atoms\StringAtom;
|
||||
use XaiCorp\AbcParser\Domain\Atoms\UnsignedIntegerAtom;
|
||||
use Closure;
|
||||
use XaiCorp\AbcParser\Domain\Core\TuneBuilder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder;
|
||||
use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context;
|
||||
|
||||
class Title implements Lex
|
||||
@@ -27,10 +25,10 @@ class Title implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'T') {
|
||||
$this->builder->addTitle($data);
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Transcriber.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Transcriber.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Transcriber implements Lex
|
||||
@@ -27,10 +26,10 @@ class Transcriber implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'Z') {
|
||||
$this->builder->addTranscriber(new StringAtom($data));
|
||||
|
||||
7
src/Domain/Modules/Interpreter/Lexicon/Words.php
Normal file → Executable file
7
src/Domain/Modules/Interpreter/Lexicon/Words.php
Normal file → Executable file
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Domain\Modules\Interpreter\Lexicon;
|
||||
|
||||
use Closure;
|
||||
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 Words implements Lex
|
||||
@@ -27,10 +26,10 @@ class Words implements Lex
|
||||
* @return mixed
|
||||
* @throws \Enzyme\Axiom\Exceptions\AtomException
|
||||
*/
|
||||
public function handle(Context $context, \Closure $next)
|
||||
public function handle(Context $context, Closure $next)
|
||||
{
|
||||
$line = $context->current();
|
||||
list($key, $data) = $this->getKeyDataFromLine($line);
|
||||
[$key, $data] = $this->getKeyDataFromLine($line);
|
||||
|
||||
if ($key === 'W') {
|
||||
$this->builder->addWords(new StringAtom($data));
|
||||
|
||||
0
src/Interfaces/Builder.php
Normal file → Executable file
0
src/Interfaces/Builder.php
Normal file → Executable file
0
src/Interfaces/Exporter.php
Normal file → Executable file
0
src/Interfaces/Exporter.php
Normal file → Executable file
0
src/Interfaces/Manipulator.php
Normal file → Executable file
0
src/Interfaces/Manipulator.php
Normal file → Executable file
2
src/Traits/ValidationTrait.php
Normal file → Executable file
2
src/Traits/ValidationTrait.php
Normal file → Executable file
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace XaiCorp\AbcParser\Traits;
|
||||
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
Trait ValidationTrait
|
||||
{
|
||||
|
||||
4
tests/_bootstrap.php
Normal file → Executable file
4
tests/_bootstrap.php
Normal file → Executable file
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
||||
|
||||
use Codeception\Util\Autoload;
|
||||
|
||||
include_once 'vendor/autoload.php';
|
||||
\Codeception\Util\Autoload::addNamespace('Tests', codecept_root_dir().'tests/unit');
|
||||
Autoload::addNamespace('Tests', codecept_root_dir() . 'tests/unit');
|
||||
|
||||
0
tests/_data/abc/jigs.abc
Normal file → Executable file
0
tests/_data/abc/jigs.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_1.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_1.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_2.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_2.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_3.abc
Normal file → Executable file
0
tests/_data/abc/valid_abc_3.abc
Normal file → Executable file
0
tests/_data/dump.sql
Normal file → Executable file
0
tests/_data/dump.sql
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user