Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function resolve(string $className): RuleHandlerInterface |
||
22 | { |
||
23 | if (!class_exists($className)) { |
||
24 | throw new RuleHandlerNotFoundException($className); |
||
25 | } |
||
26 | |||
27 | if (array_key_exists($className, $this->instances)) { |
||
28 | return $this->instances[$className]; |
||
29 | } |
||
30 | |||
31 | if (!is_subclass_of($className, RuleHandlerInterface::class)) { |
||
32 | throw new RuleHandlerInterfaceNotImplementedException($className); |
||
33 | } |
||
34 | |||
35 | return $this->instances[$className] = new $className(); |
||
36 | } |
||
38 |