Files
predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php
T
2011-06-04 15:45:01 +02:00

23 lines
613 B
PHP

<?php
namespace Predis\Protocol\Text;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Protocol\IResponseHandler;
use Predis\Network\IConnectionComposable;
class ResponseIntegerHandler implements IResponseHandler {
public function handle(IConnectionComposable $connection, $number) {
if (is_numeric($number)) {
return (int) $number;
}
if ($number !== 'nil') {
Helpers::onCommunicationException(new ProtocolException(
$connection, "Cannot parse '$number' as numeric response"
));
}
return null;
}
}