| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.576 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 6 | public function resolve(DefinitionInterface $definition) |
|
| 21 | { |
||
| 22 | 6 | if (!$definition instanceof ClassDefinition) { |
|
| 23 | $actualType = gettype($definition); |
||
| 24 | $expectedType = ClassDefinition::class; |
||
| 25 | |||
| 26 | throw new InvalidArgumentException("Argument \$definition must be $expectedType, $actualType given"); |
||
| 27 | } |
||
| 28 | |||
| 29 | 6 | $class = $definition->getClass(); |
|
| 30 | |||
| 31 | 6 | if (!class_exists($class)) { |
|
| 32 | NotFoundException::create($class); |
||
| 33 | } |
||
| 34 | |||
| 35 | 6 | $params = $this->getConstructorParams($class); |
|
| 36 | |||
| 37 | 6 | return new $class(...$params); |
|
| 38 | } |
||
| 39 | } |
||
| 40 |