mirror of
https://github.com/predis/predis.git
synced 2026-10-15 16:26:48 +00:00
36 lines
862 B
PHP
36 lines
862 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Protocol\Text;
|
|
|
|
use Predis\Helpers;
|
|
use Predis\Protocol\IResponseHandler;
|
|
use Predis\Protocol\ProtocolException;
|
|
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;
|
|
}
|
|
}
|