Conditions | 3 |
Paths | 2 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3.0261 |
Changes | 0 |
1 | <?php |
||
18 | 2 | public function resolve($definition) |
|
19 | { |
||
20 | 2 | $factoryClass = $definition->getValue(); |
|
|
|||
21 | 2 | $factoryInterface = FactoryInterface::class; |
|
22 | 2 | $interfaces = class_implements($factoryClass); |
|
23 | |||
24 | 2 | if (empty($interfaces) || !in_array($factoryInterface, $interfaces, true)) { |
|
25 | throw new ContainerException("$factoryClass must implement $factoryInterface"); |
||
26 | } |
||
27 | |||
28 | 2 | return (new $factoryClass)($this->getContainer()); |
|
29 | } |
||
30 | } |
||
31 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: