<?php

declare(strict_types=1);

namespace PpPhp\Core\IconManager;

final class IconCollection
{
    /**
     * @var IconDefinition[]
     */
    private array $icons = [];

    public function add(IconDefinition $icon): void
    {
        $this->icons[$icon->name] = $icon;
    }

    /**
     * @return IconDefinition[]
     */
    public function all(): array
    {
        return array_values($this->icons);
    }

    public function find(string $name): ?IconDefinition
    {
        return $this->icons[$name] ?? null;
    }

    public function count(): int
    {
        return count($this->icons);
    }
}
