| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 2.0185 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 4 | public function resolve(DefinitionInterface $definition) |
|
| 19 | { |
||
| 20 | 4 | $class = $definition->getValue(); |
|
| 21 | |||
| 22 | 4 | if (class_exists($class)) { |
|
| 23 | 4 | $params = $this->getConstructorParams($class); |
|
|
|
|||
| 24 | |||
| 25 | 4 | return new $class(...$params); |
|
| 26 | } |
||
| 27 | |||
| 28 | throw NotFoundException::create($class); |
||
| 29 | } |
||
| 30 | } |
||
| 31 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.