| Total Complexity | 7 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 93.75% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class PluginFactoryManager |
||
| 13 | { |
||
| 14 | /** @var array<string, PluginFactory> */ |
||
| 15 | private array $factories; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param array<string, PluginFactory> $factories |
||
| 19 | 3 | */ |
|
| 20 | public function __construct(array $factories = []) |
||
| 21 | 3 | { |
|
| 22 | 3 | foreach ($factories as $alias => $factory) { |
|
| 23 | $this->add($alias, $factory); |
||
| 24 | 3 | } |
|
| 25 | } |
||
| 26 | 3 | ||
| 27 | public function add(string $alias, PluginFactory $factory): void |
||
| 28 | 3 | { |
|
| 29 | 3 | $this->factories[$alias] = $factory; |
|
| 30 | } |
||
| 31 | 1 | ||
| 32 | public function has(string $alias): bool |
||
| 33 | 1 | { |
|
| 34 | return array_key_exists($alias, $this->factories); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return array<string, PluginFactory> |
||
| 39 | 1 | */ |
|
| 40 | public function all(): array |
||
| 41 | 1 | { |
|
| 42 | return $this->factories; |
||
| 43 | } |
||
| 44 | 1 | ||
| 45 | public function getFactory(string $alias): PluginFactory |
||
| 54 | } |
||
| 55 | } |
||
| 56 |