mirror of
https://github.com/predis/predis.git
synced 2026-08-25 19:39:39 +00:00
22 lines
585 B
PHP
22 lines
585 B
PHP
<?php
|
|
|
|
namespace Predis\Protocols\Text;
|
|
|
|
use Predis\Helpers;
|
|
use Predis\Protocols\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;
|
|
}
|
|
}
|