The doc comment array<class-string, RuleHandlerInterface> at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in array<class-string, RuleHandlerInterface>.
Loading history...
18
*/
19
private array $instances = [];
20
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();