Add checking when adding a stage class string
This commit is contained in:
@ -22,7 +22,13 @@ class OptionsStageBuilder
|
||||
public function add(string|OptionsStageInterface $stageClass): self
|
||||
{
|
||||
if (is_string($stageClass)) {
|
||||
if (new \ReflectionClass($stageClass)->implementsInterface(OptionsStageInterface::class)) {
|
||||
$this->stages[] = $this->bag->get($stageClass);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Stage must be an instance of OptionsStageInterface, %s given', get_debug_type($stage))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->stages[] = $stageClass;
|
||||
}
|
||||
|
Reference in New Issue
Block a user