getAttributes(HandlesCommand::class); foreach ($attributes as $attribute) { $instance = $attribute->newInstance(); $commandClass = $instance->commandClass; $this->handlers[$commandClass] = $fullClassName; } } } } } public function getHandlerForCommand($commandName) { if (isset($this->handlers[$commandName])) { $handlerClass = $this->handlers[$commandName]; return new $handlerClass(); } throw new CanNotInvokeHandlerException("No handler found for command: " . $commandName); } }