init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user