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