diff --git a/CHANGELOG.md b/CHANGELOG.md index 447a3b96..f36fef2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ v1.0.0 (201x-xx-xx) - `Predis\Command\AbstractCommand` is now `Predis\Command\Command` - `Predis\Command\ScriptedCommand` is now `Predis\Command\ScriptCommand` +- Dropped `Predis\Command\Command::__toString()` (see issue #151). + - Renamed `Predis\Connection\ConnectionInterface::writeCommand()` into `writeRequest()` for consistency with its counterpart, `readResponse()`. diff --git a/lib/Predis/Command/Command.php b/lib/Predis/Command/Command.php index 09d24a42..40d9e434 100644 --- a/lib/Predis/Command/Command.php +++ b/lib/Predis/Command/Command.php @@ -94,38 +94,6 @@ abstract class Command implements CommandInterface return $data; } - /** - * Helper function used to reduce a list of arguments to a string. - * - * @param string $accumulator Temporary string. - * @param string $argument Current argument. - * @return string - */ - protected function toStringArgumentReducer($accumulator, $argument) - { - if (strlen($argument) > 32) { - $argument = substr($argument, 0, 32) . '[...]'; - } - - $accumulator .= " $argument"; - - return $accumulator; - } - - /** - * Returns a partial string representation of the command with its arguments. - * - * @return string - */ - public function __toString() - { - return array_reduce( - $this->getArguments(), - array($this, 'toStringArgumentReducer'), - $this->getId() - ); - } - /** * Normalizes the arguments array passed to a Redis command. * diff --git a/tests/Predis/Command/CommandTest.php b/tests/Predis/Command/CommandTest.php index d31f0647..f19610e9 100644 --- a/tests/Predis/Command/CommandTest.php +++ b/tests/Predis/Command/CommandTest.php @@ -117,38 +117,6 @@ class CommandTest extends PredisTestCase $this->assertNull($command->getHash()); } - /** - * @group disconnected - */ - public function testToString() - { - $expected = 'SET key value'; - $arguments = array('key', 'value'); - - $command = $this->getMockForAbstractClass('Predis\Command\Command'); - $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); - - $command->setRawArguments($arguments); - - $this->assertEquals($expected, (string) $command); - } - - /** - * @group disconnected - */ - public function testToStringWithLongArguments() - { - $expected = 'SET key abcdefghijklmnopqrstuvwxyz012345[...]'; - $arguments = array('key', 'abcdefghijklmnopqrstuvwxyz0123456789'); - - $command = $this->getMockForAbstractClass('Predis\Command\Command'); - $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); - - $command->setRawArguments($arguments); - - $this->assertEquals($expected, (string) $command); - } - /** * @group disconnected */