finished default parser
This commit is contained in:
73
src/Domain/Core/Person.php
Normal file
73
src/Domain/Core/Person.php
Normal 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.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user