From 8b749386dfd231b59fd61ea3123fdac88ee42454 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Fri, 4 Mar 2011 17:17:49 +0100 Subject: [PATCH] Implement Predis\Command::__toString(). --- lib/Predis/Command.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Predis/Command.php b/lib/Predis/Command.php index 0e00098d..689acb5d 100644 --- a/lib/Predis/Command.php +++ b/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()); + } }