Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (27 sloc) 723 Bytes
<?php declare(strict_types=1);
namespace Thepixeldeveloper\Sitemap;
use Thepixeldeveloper\Sitemap\Interfaces\VisitorInterface;
abstract class Collection implements VisitorInterface
{
/**
* @var VisitorInterface[]
*/
private $items = [];
public function add(VisitorInterface $value)
{
$type = $this->type();
if ($value instanceof $type) {
$this->items[] = $value;
} else {
throw new \InvalidArgumentException('$value needs to be an instance of ' . $type);
}
}
/**
* @return VisitorInterface[]
*/
public function all(): array
{
return $this->items;
}
abstract public function type(): string;
}
You can’t perform that action at this time.