finished default parser

This commit is contained in:
2018-04-24 21:11:23 -04:00
parent 8a1c752045
commit 3817394951
39 changed files with 3725 additions and 328 deletions

View File

@@ -0,0 +1,73 @@
<?php
namespace XaiCorp\AbcParser\Domain\Core;
use Enzyme\Axiom\Atoms\StringAtom;
use Webpatser\Uuid\Uuid;
use XaiCorp\AbcParser\Domain\Atoms\EmailAtom;
class Person implements EntityInterface
{
use IdentityTrait;
const TYPE_COMPOSER = 'composer';
const TYPE_AUTHOR = 'author';
/**
* @var StringAtom
*/
protected $name;
/**
* @var EmailAtom
*/
protected $email;
public function __construct(StringAtom $name, EmailAtom $email, Uuid $identity = null)
{
$this->name = $name;
$this->email = $email;
$this->setIdentity($identity);
}
/**
* Checks whether this model has the given attribute set.
*
* @param string $attribute
*
* @return boolean
*/
public function has($attribute)
{
return in_array($attribute, [
'name',
'email',
]);
}
/**
* Get the value associated with the given attribute.
*
* @param string $attribute
*
* @return mixed
*/
public function get($attribute)
{
if (!$this->has($attribute)) {
throw new \Exception('Cannot access attribute on person');
}
return $this->{$attribute};
}
/**
* Get all the attributes associated with this model.
*
* @return array
*/
public function getAll()
{
// TODO: Implement getAll() method.
}
}