83 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace DesignPatterns\More\EAV;
2015-08-25 10:32:12 +03:00
use SplObjectStorage;
/**
2015-12-21 07:28:20 -05:00
* Class Entity.
*/
class Entity implements ValueAccessInterface
{
/**
2015-08-25 10:32:12 +03:00
* @var SplObjectStorage
*/
2015-08-25 10:32:12 +03:00
private $values;
/**
* @var string
*/
private $name;
2015-08-25 10:32:12 +03:00
public function __construct()
{
$this->values = new SplObjectStorage();
}
/**
2015-08-25 10:32:12 +03:00
* @return SplObjectStorage
*/
public function getValues()
{
return $this->values;
}
/**
2015-08-23 00:55:42 +03:00
* @param ValueInterface $value
2015-12-21 07:28:20 -05:00
*
* @return $this
*/
public function addValue(ValueInterface $value)
{
2015-08-25 10:32:12 +03:00
if (!$this->values->contains($value)) {
$this->values->attach($value);
}
return $this;
}
/**
2015-08-23 00:55:42 +03:00
* @param ValueInterface $value
2015-12-21 07:28:20 -05:00
*
* @return $this
*/
public function removeValue(ValueInterface $value)
{
2015-08-25 10:32:12 +03:00
if ($this->values->contains($value)) {
$this->values->detach($value);
}
return $this;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
2015-12-21 07:28:20 -05:00
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
}