| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Metadata extends AbstractContainer |
||
| 12 | { |
||
| 13 | public function __construct( |
||
| 14 | protected AbstractContainer $container, |
||
| 15 | protected array|null $metadataConfig, |
||
| 16 | ) { |
||
| 17 | } |
||
| 18 | |||
| 19 | public function getContainer(): AbstractContainer |
||
| 20 | { |
||
| 21 | return $this->container; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** @throws Error */ |
||
| 25 | public function get(string $id): Entity |
||
| 26 | { |
||
| 27 | if ($this->has($id)) { |
||
| 28 | return parent::get($id); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (! isset($this->metadataConfig[$id])) { |
||
| 32 | throw new Error( |
||
| 33 | 'Entity ' . $id . ' is not mapped in the metadata', |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $this->build(Entity::class, $id, $this->metadataConfig[$id]); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getMetadataConfig(): array|null |
||
| 43 | } |
||
| 44 | } |
||
| 45 |