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 |
||
15 | 36 | public function resolve(string $className): RuleHandlerInterface |
|
16 | { |
||
17 | 36 | if (!class_exists($className)) { |
|
18 | throw new RuleHandlerNotFoundException($className); |
||
19 | } |
||
20 | 36 | if (!array_key_exists($className, $this->instances)) { |
|
21 | 36 | $classInstance = new $className(); |
|
22 | 36 | if (!$classInstance instanceof RuleHandlerInterface) { |
|
23 | 1 | throw new RuleHandlerInterfaceNotImplementedException($className); |
|
24 | } |
||
25 | 35 | return $this->instances[$className] = $classInstance; |
|
26 | } |
||
27 | |||
28 | 8 | return $this->instances[$className]; |
|
29 | } |
||
31 |