| Total Complexity | 10 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 7 | #[Package('core')] |
||
| 8 | class ElasticsearchRegistry |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @internal |
||
| 12 | * |
||
| 13 | * @param AbstractElasticsearchDefinition[] $definitions |
||
| 14 | */ |
||
| 15 | public function __construct(private readonly iterable $definitions) |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return AbstractElasticsearchDefinition[] |
||
| 21 | */ |
||
| 22 | public function getDefinitions(): iterable |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return iterable<string> |
||
| 29 | */ |
||
| 30 | public function getDefinitionNames(): iterable |
||
| 31 | { |
||
| 32 | $names = []; |
||
| 33 | |||
| 34 | foreach ($this->getDefinitions() as $definition) { |
||
| 35 | $names[] = $definition->getEntityDefinition()->getEntityName(); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $names; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function get(string $entityName): ?AbstractElasticsearchDefinition |
||
| 42 | { |
||
| 43 | foreach ($this->getDefinitions() as $definition) { |
||
| 44 | if ($definition->getEntityDefinition()->getEntityName() === $entityName) { |
||
| 45 | return $definition; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | return null; |
||
| 50 | } |
||
| 51 | |||
| 52 | public function has(string $entityName): bool |
||
| 61 | } |
||
| 62 | } |
||
| 63 |