Change handling of unsupported methods in Predis\Network\WebdisConnection.

This commit is contained in:
Daniele Alessandri
2011-06-08 21:53:54 +02:00
parent e7d2717ee1
commit bc040fae6f
+9 -8
View File
@@ -30,10 +30,6 @@ class WebdisConnection implements IConnectionSingle {
private $_resource;
private $_reader;
private static function throwNotImplementedException($class, $function) {
throw new \RuntimeException("The method $class::$function() is not implemented");
}
public function __construct(IConnectionParameters $parameters) {
$this->_parameters = $parameters;
if ($parameters->scheme !== 'http') {
@@ -49,6 +45,11 @@ class WebdisConnection implements IConnectionSingle {
phpiredis_reader_destroy($this->_reader);
}
private function throwNotSupportedException($function) {
$class = __CLASS__;
throw new \RuntimeException("The method $class::$function() is not supported");
}
private function checkExtensions() {
if (!function_exists('curl_init')) {
throw new ClientException(sprintf(ERR_MSG_EXTENSION, 'curl'));
@@ -118,11 +119,11 @@ class WebdisConnection implements IConnectionSingle {
}
public function writeCommand(ICommand $command) {
self::throwNotImplementedException(__CLASS__, __FUNCTION__);
$this->throwNotSupportedException(__FUNCTION__);
}
public function readResponse(ICommand $command) {
self::throwNotImplementedException(__CLASS__, __FUNCTION__);
$this->throwNotSupportedException(__FUNCTION__);
}
protected function getCommandId(ICommand $command) {
@@ -182,11 +183,11 @@ class WebdisConnection implements IConnectionSingle {
}
public function pushInitCommand(ICommand $command) {
self::throwNotImplementedException(__CLASS__, __FUNCTION__);
$this->throwNotSupportedException(__FUNCTION__);
}
public function read() {
self::throwNotImplementedException(__CLASS__, __FUNCTION__);
$this->throwNotSupportedException(__FUNCTION__);
}
public function __toString() {