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