*/ declare(strict_types=1); namespace oat\tao\model\session\Business\Domain; use IteratorAggregate; use oat\tao\model\session\Business\Contract\SessionCookieAttributeInterface; final class SessionCookieAttributeCollection implements IteratorAggregate { /** @var SessionCookieAttributeInterface[] */ private $attributes = []; public function add(SessionCookieAttributeInterface $attribute): self { $collection = clone $this; $collection->attributes[] = $attribute; return $collection; } /** * @return iterable|SessionCookieAttributeInterface[] */ public function getIterator(): iterable { yield from $this->attributes; } public function __toString(): string { $rawAttributes = []; foreach ($this as $attribute) { $rawAttributes[] = (string)$attribute; } return implode('; ', $rawAttributes); } }