public function invoke(Request $request, Client $client)
 {
     $command = strtolower($request->getCommand());
     $args = $request->getArgs();
     if (!isset($this->commands[$command])) {
         return $this->serializer->getErrorMessage('ERR Unknown or disabled command \'' . $command . '\'');
     }
     $n = count($args);
     if ($n < $this->commandArgs[$command]) {
         return $this->serializer->getErrorMessage('ERR wrong number of arguments for \'' . $command . '\' command');
     }
     // This doesn't even deserve a proper comment…
     $b = reset($this->commands[$command]);
     if (is_callable(array($b, 'setClient'))) {
         $b->setClient($client);
     }
     try {
         $ret = call_user_func_array($this->commands[$command], $args);
     } catch (Exception $e) {
         return $this->serializer->getErrorMessage($e->getMessage());
     }
     if (isset($this->commandType[$command])) {
         if ($this->commandType[$command] === self::TYPE_STRING_STATUS && is_string($ret)) {
             return $this->serializer->getStatusMessage($ret);
         } elseif ($this->commandType[$command] === self::TYPE_TRUE_STATUS && $ret === true) {
             return $this->serializer->getStatusMessage('OK');
         }
     }
     return $this->serializer->getReplyMessage($ret);
 }
 public function invoke(Request $request, Client $client)
 {
     $command = strtolower($request->getCommand());
     if ($command !== 'auth') {
         // should be after checking number of args:
         return $this->invoker->getSerializer()->getErrorMessage('ERR operation not permitted');
     }
     return $this->invoker->invoke($request, $client);
 }
 public function testGet()
 {
     $model = new Request('GET', array('a'));
     $this->assertEquals('GET', $model->getCommand());
     $this->assertEquals(array('a'), $model->getArgs());
     $this->assertEquals(array('GET', 'a'), $model->getValueNative());
     $this->assertEquals("*2\r\n\$3\r\nGET\r\n\$1\r\na\r\n", $model->getMessageSerialized($this->serializer));
     $reply = $model->getReplyModel();
     $this->assertEquals($model->getValueNative(), $reply->getValueNative());
 }