targetClassName = $targetClassName; } /** * @return HandlerInterface * @throws \UnexpectedValueException */ protected function getTarget() { if (is_subclass_of($this->targetClassName, self::DISPATCHER_INTERFACE)) { /** @var HandlerInterface $target */ $target = new $this->targetClassName(); return $target; } else { throw new \UnexpectedValueException("Target class must implement HandlerInterface"); } } }