mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 18:50:11 +02:00
41 lines
667 B
PHP
41 lines
667 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\More\EAV;
|
|
|
|
class Attribute
|
|
{
|
|
/**
|
|
* @var \SplObjectStorage
|
|
*/
|
|
private $values;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $name;
|
|
|
|
public function __construct(string $name)
|
|
{
|
|
$this->values = new \SplObjectStorage();
|
|
$this->name = $name;
|
|
}
|
|
|
|
public function addValue(Value $value)
|
|
{
|
|
$this->values->attach($value);
|
|
}
|
|
|
|
/**
|
|
* @return \SplObjectStorage
|
|
*/
|
|
public function getValues(): \SplObjectStorage
|
|
{
|
|
return $this->values;
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
return $this->name;
|
|
}
|
|
}
|