소스 검색

Implement Predis\Command::__toString().

Daniele Alessandri 15 년 전
부모
커밋
8b749386df
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  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());
+    }
 }