mirror of
https://github.com/predis/predis.git
synced 2026-08-24 10:49:28 +00:00
22 lines
579 B
PHP
22 lines
579 B
PHP
<?php
|
|
|
|
namespace Predis\Protocols;
|
|
|
|
use Predis\Utils;
|
|
use Predis\MalformedServerResponse;
|
|
use Predis\Network\IConnectionComposable;
|
|
|
|
class ResponseIntegerHandler implements IResponseHandler {
|
|
public function handle(IConnectionComposable $connection, $number) {
|
|
if (is_numeric($number)) {
|
|
return (int) $number;
|
|
}
|
|
if ($number !== 'nil') {
|
|
Utils::onCommunicationException(new MalformedServerResponse(
|
|
$connection, "Cannot parse '$number' as numeric response"
|
|
));
|
|
}
|
|
return null;
|
|
}
|
|
}
|