Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | 115 | public function resolve(string $className): RuleHandlerInterface |
|
17 | { |
||
18 | 115 | if (!class_exists($className)) { |
|
19 | 1 | throw new RuleHandlerNotFoundException($className); |
|
20 | } |
||
21 | |||
22 | 114 | if (array_key_exists($className, $this->instances)) { |
|
23 | 35 | return $this->instances[$className]; |
|
24 | } |
||
25 | |||
26 | 102 | $classInstance = new $className(); |
|
27 | |||
28 | 102 | if (!$classInstance instanceof RuleHandlerInterface) { |
|
29 | 1 | throw new RuleHandlerInterfaceNotImplementedException($className); |
|
30 | } |
||
31 | |||
32 | 101 | return $this->instances[$className] = $classInstance; |
|
33 | } |
||
35 |