mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-29 19:20:18 +02:00
42 lines
707 B
PHP
42 lines
707 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\More\EAV;
|
|
|
|
class Entity
|
|
{
|
|
/**
|
|
* @var \SplObjectStorage
|
|
*/
|
|
private $values;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @param string $name
|
|
* @param Value[] $values
|
|
*/
|
|
public function __construct(string $name, $values)
|
|
{
|
|
$this->values = new \SplObjectStorage();
|
|
$this->name = $name;
|
|
|
|
foreach ($values as $value) {
|
|
$this->values->attach($value);
|
|
}
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
$text = [$this->name];
|
|
|
|
foreach ($this->values as $value) {
|
|
$text[] = (string) $value;
|
|
}
|
|
|
|
return join(', ', $text);
|
|
}
|
|
}
|