/** * Have the appropriate worker execute a command * * @param Command $command * @return mixed */ public function execute(Command $command) { $worker = $this->getWorker($command->getName()); $args = $command->getArguments(); foreach ($worker->getRequiredParameters() as $param) { if (!array_key_exists($param, $args)) { throw new InvalidArgumentException("Command '" . $command->getName() . "' requires parameter '" . $param . "''"); } } return $worker->execute($args); }
/** * Build a Predis command from a Command object * * @param Command $command * * @return CommandInterface */ private function getPredisCommand($command) { $class = 'Predis\\Command\\' . $command->getName(); /** @var CommandInterface $predis_command */ $predis_command = new $class(); $predis_command->setArguments($command->getArguments()); return $predis_command; }