Convert monolithic one-file-lib to a proper PSR-0 file tree

This commit is contained in:
Jordi Boggiano
2011-02-21 03:15:49 +01:00
parent 2a78142b28
commit 30f908cd85
183 changed files with 4189 additions and 3385 deletions
@@ -0,0 +1,24 @@
<?php
namespace Predis\Protocols;
use Predis\ICommand;
class TextCommandSerializer implements ICommandSerializer {
public function serialize(ICommand $command) {
$commandId = $command->getCommandId();
$arguments = $command->getArguments();
$cmdlen = strlen($commandId);
$reqlen = count($arguments) + 1;
$buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n";
for ($i = 0; $i < $reqlen - 1; $i++) {
$argument = $arguments[$i];
$arglen = strlen($argument);
$buffer .= "\${$arglen}\r\n{$argument}\r\n";
}
return $buffer;
}
}