mirror of
https://github.com/predis/predis.git
synced 2026-10-12 06:47:28 +00:00
Rename the Predis\Protocols namespace to Predis\Protocol.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Predis\Protocol\Text;
|
||||
|
||||
use Predis\Commands\ICommand;
|
||||
use Predis\Protocol\ICommandSerializer;
|
||||
|
||||
class TextCommandSerializer implements ICommandSerializer {
|
||||
public function serialize(ICommand $command) {
|
||||
$commandId = $command->getId();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user