Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function resolve(string $className): RuleHandlerInterface |
||
30 | { |
||
31 | if (array_key_exists($className, $this->instances)) { |
||
32 | return $this->instances[$className]; |
||
33 | } |
||
34 | |||
35 | if (!class_exists($className)) { |
||
36 | throw new RuleHandlerNotFoundException($className); |
||
37 | } |
||
38 | |||
39 | if (!is_subclass_of($className, RuleHandlerInterface::class)) { |
||
40 | throw new RuleHandlerInterfaceNotImplementedException($className); |
||
41 | } |
||
42 | |||
43 | return $this->instances[$className] = new $className(); |
||
44 | } |
||
46 |