Explorar el Código

Implement Predis\Command::__toString().

Daniele Alessandri hace 14 años
padre
commit
8b749386df
Se han modificado 1 ficheros con 11 adiciones y 0 borrados
  1. 11 0
      lib/Predis/Command.php

+ 11 - 0
lib/Predis/Command.php

@@ -62,4 +62,15 @@ abstract class Command implements ICommand {
     public function parseResponse($data) {
         return $data;
     }
+
+    public function __toString() {
+        $reducer = function($acc, $arg) {
+            if (strlen($arg) > 32) {
+                $arg = substr($arg, 0, 32) . '[...]';
+            }
+            $acc .= " $arg";
+            return $acc;
+        };
+        return array_reduce($this->getArguments(), $reducer, $this->getCommandId());
+    }
 }