Files
2026-09-15 10:35:56 +08:00

35 lines
738 B
PHP

<?php
declare(strict_types=1);
namespace Esun\Translation\Model\Entity;
use Esun\Translation\Api\TranslatableEntityInterface;
class EntityPool
{
/**
* @param array<string, TranslatableEntityInterface> $entities
*/
public function __construct(private readonly array $entities = [])
{
}
public function get(string $type): TranslatableEntityInterface
{
if (!isset($this->entities[$type])) {
throw new \InvalidArgumentException(sprintf('Unsupported translation entity type "%s".', $type));
}
return $this->entities[$type];
}
/**
* @return string[]
*/
public function getTypes(): array
{
return array_keys($this->entities);
}
}