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