<?php

declare(strict_types=1);

namespace PpPhp\Core\Registry\Support;

class RegistryCollection implements \IteratorAggregate, \Countable
{
    public function __construct(private array $items = []) {}
    public function add(string $key, object $item): void
    {
        $this->items[$key] = $item;
    }
    public function all(): array
    {
        return $this->items;
    }
    public function getIterator(): \Traversable
    {
        return new \ArrayIterator($this->items);
    }
    public function count(): int
    {
        return count($this->items);
    }
}
