| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public function getPart(string $parentClass, string $name): Document\AbstractPart |
||
| 20 | { |
||
| 21 | $className = $parentClass . '\\' . $name; |
||
| 22 | if (!$this->container->has($className)) { |
||
| 23 | throw new DomainException('Entity does not exists: ' . $name); |
||
| 24 | } |
||
| 25 | |||
| 26 | try { |
||
| 27 | $instance = $this->container->get($className); |
||
| 28 | } catch (ContainerExceptionInterface $ex) { |
||
| 29 | throw new DomainException('Entity cannot be initialized: ' . $name, 0, $ex); |
||
| 30 | } |
||
| 31 | |||
| 32 | if ($instance instanceof Document\AbstractPart) { |
||
| 33 | return $instance; |
||
| 34 | } |
||
| 35 | |||
| 36 | throw new DomainException('Entity is not an instance of AbstractPart: ' . $name); |
||
| 37 | } |
||
| 39 |