Conditions | 4 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.0218 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 61 | public function resolve(string $className): RuleHandlerInterface |
|
21 | { |
||
22 | 61 | if (!class_exists($className)) { |
|
23 | 1 | throw new RuleHandlerNotFoundException($className); |
|
24 | } |
||
25 | 60 | if (!array_key_exists($className, $this->instances)) { |
|
26 | 1 | $classInstance = new $className(); |
|
27 | 1 | if (!$classInstance instanceof RuleHandlerInterface) { |
|
28 | 1 | throw new RuleHandlerInterfaceNotImplementedException($className); |
|
29 | } |
||
30 | return $this->instances[$className] = $classInstance; |
||
31 | } |
||
32 | |||
33 | 59 | return $this->instances[$className]; |
|
34 | } |
||
36 |