Rework the API for external protocol processors.

This commit is contained in:
Daniele Alessandri
2013-11-09 14:20:40 +01:00
parent 70a84e1d5a
commit 16d17af577
30 changed files with 178 additions and 275 deletions
@@ -17,8 +17,8 @@ use Predis\Protocol\ProtocolException;
use Predis\Protocol\ResponseHandlerInterface;
/**
* Implements a response handler for integer replies using the standard wire
* protocol defined by Redis.
* Handler for the integer response type of the standard Redis wire protocol.
* It translates the payload an integer or NULL.
*
* @link http://redis.io/topics/protocol
* @author Daniele Alessandri <suppakilla@gmail.com>
@@ -26,21 +26,17 @@ use Predis\Protocol\ResponseHandlerInterface;
class ResponseIntegerHandler implements ResponseHandlerInterface
{
/**
* Handles an integer reply returned by Redis.
*
* @param ComposableConnectionInterface $connection Connection to Redis.
* @param string $number String representation of an integer.
* @return int
* {@inheritdoc}
*/
public function handle(ComposableConnectionInterface $connection, $number)
public function handle(ComposableConnectionInterface $connection, $payload)
{
if (is_numeric($number)) {
return (int) $number;
if (is_numeric($payload)) {
return (int) $payload;
}
if ($number !== 'nil') {
if ($payload !== 'nil') {
CommunicationException::handle(new ProtocolException(
$connection, "Cannot parse '$number' as numeric response"
$connection, "Cannot parse '$payload' as a numeric response"
));
}