Rename Predis\Utils to Predis\Helpers.

This commit is contained in:
Daniele Alessandri
2011-04-05 16:37:36 +02:00
parent 4ea8489110
commit 86df741937
17 changed files with 34 additions and 33 deletions
+4 -4
View File
@@ -92,7 +92,7 @@ class Client {
}
public function getClientFor($connectionAlias) {
if (!Utils::isCluster($this->_connection)) {
if (!Helpers::isCluster($this->_connection)) {
throw new ClientException(
'This method is supported only when the client is connected to a cluster of connections'
);
@@ -128,7 +128,7 @@ class Client {
return $this->_connection;
}
$connection = $this->_connection;
$isCluster = Utils::isCluster($connection);
$isCluster = Helpers::isCluster($connection);
return $isCluster ? $connection->getConnectionById($id) : $connection;
}
@@ -146,7 +146,7 @@ class Client {
}
public function executeCommandOnShards(ICommand $command) {
if (Utils::isCluster($this->_connection)) {
if (Helpers::isCluster($this->_connection)) {
$replies = array();
foreach ($this->_connection as $connection) {
$replies[] = $connection->executeCommand($command);
@@ -182,7 +182,7 @@ class Client {
if (isset($options['safe']) && $options['safe'] == true) {
$connection = $this->_connection;
$pipeline = new PipelineContext($this,
Utils::isCluster($connection)
Helpers::isCluster($connection)
? new Pipeline\SafeClusterExecutor($connection)
: new Pipeline\SafeExecutor($connection)
);
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Commands;
use Predis\Utils;
use Predis\Helpers;
class Delete extends Command {
public function getId() {
@@ -10,7 +10,7 @@ class Delete extends Command {
}
public function filterArguments(Array $arguments) {
return Utils::filterArrayArguments($arguments);
return Helpers::filterArrayArguments($arguments);
}
protected function canBeHashed() {
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Commands;
use Predis\Utils;
use Predis\Helpers;
class GetMultiple extends Command {
public function getId() {
@@ -10,7 +10,7 @@ class GetMultiple extends Command {
}
public function filterArguments(Array $arguments) {
return Utils::filterArrayArguments($arguments);
return Helpers::filterArrayArguments($arguments);
}
protected function canBeHashed() {
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Commands;
use Predis\Utils;
use Predis\Helpers;
class SetIntersection extends Command {
public function getId() {
@@ -10,7 +10,7 @@ class SetIntersection extends Command {
}
public function filterArguments(Array $arguments) {
return Utils::filterArrayArguments($arguments);
return Helpers::filterArrayArguments($arguments);
}
protected function canBeHashed() {
@@ -2,8 +2,6 @@
namespace Predis\Commands;
use Predis\Utils;
class SetIntersectionStore extends Command {
public function getId() {
return 'SINTERSTORE';
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Commands;
use Predis\Utils;
use Predis\Helpers;
class Subscribe extends Command {
public function getId() {
@@ -10,7 +10,7 @@ class Subscribe extends Command {
}
public function filterArguments(Array $arguments) {
return Utils::filterArrayArguments($arguments);
return Helpers::filterArrayArguments($arguments);
}
protected function canBeHashed() {
+3 -1
View File
@@ -2,13 +2,15 @@
namespace Predis\Commands;
use Predis\Helpers;
class SubscribeByPattern extends Command {
public function getId() {
return 'PSUBSCRIBE';
}
public function filterArguments(Array $arguments) {
return Utils::filterArrayArguments($arguments);
return Helpers::filterArrayArguments($arguments);
}
protected function canBeHashed() {
@@ -5,7 +5,7 @@ namespace Predis;
use Predis\Network\IConnection;
use Predis\Network\IConnectionCluster;
class Utils {
class Helpers {
public static function isCluster(IConnection $connection) {
return $connection instanceof IConnectionCluster;
}
+2 -2
View File
@@ -14,7 +14,7 @@ class MultiExecContext {
}
private function checkCapabilities(Client $client) {
if (Utils::isCluster($client->getConnection())) {
if (Helpers::isCluster($client->getConnection())) {
throw new ClientException(
'Cannot initialize a MULTI/EXEC context over a cluster of connections'
);
@@ -221,7 +221,7 @@ class MultiExecContext {
// Since a MULTI/EXEC block cannot be initialized over a clustered
// connection, we can safely assume that Predis\Client::getConnection()
// will always return an instance of Predis\Network\IConnectionSingle.
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$this->_client->getConnection(), $message
));
}
+3 -3
View File
@@ -3,7 +3,7 @@
namespace Predis\Network;
use \InvalidArgumentException;
use Predis\Utils;
use Predis\Helpers;
use Predis\IConnectionParameters;
use Predis\ClientException;
use Predis\ProtocolException;
@@ -81,13 +81,13 @@ abstract class ConnectionBase implements IConnectionSingle {
}
protected function onConnectionError($message, $code = null) {
Utils::onCommunicationException(
Helpers::onCommunicationException(
new ConnectionException($this, $message, $code)
);
}
protected function onProtocolError($message) {
Utils::onCommunicationException(
Helpers::onCommunicationException(
new ProtocolException($this, $message)
);
}
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Protocols;
use Predis\Utils;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Network\IConnectionComposable;
@@ -10,7 +10,7 @@ class ResponseBulkHandler implements IResponseHandler {
public function handle(IConnectionComposable $connection, $lengthString) {
$length = (int) $lengthString;
if ($length != $lengthString) {
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$connection, "Cannot parse '$length' as data length"
));
}
@@ -2,7 +2,7 @@
namespace Predis\Protocols;
use Predis\Utils;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Network\IConnectionComposable;
@@ -12,7 +12,7 @@ class ResponseIntegerHandler implements IResponseHandler {
return (int) $number;
}
if ($number !== 'nil') {
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$connection, "Cannot parse '$number' as numeric response"
));
}
@@ -2,7 +2,7 @@
namespace Predis\Protocols;
use Predis\Utils;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Network\IConnectionComposable;
@@ -10,7 +10,7 @@ class ResponseMultiBulkHandler implements IResponseHandler {
public function handle(IConnectionComposable $connection, $lengthString) {
$length = (int) $lengthString;
if ($length != $lengthString) {
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$connection, "Cannot parse '$length' as data length"
));
}
@@ -2,7 +2,7 @@
namespace Predis\Protocols;
use Predis\Utils;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Network\IConnectionComposable;
use Predis\Iterators\MultiBulkResponseSimple;
@@ -11,7 +11,7 @@ class ResponseMultiBulkStreamHandler implements IResponseHandler {
public function handle(IConnectionComposable $connection, $lengthString) {
$length = (int) $lengthString;
if ($length != $lengthString) {
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$connection, "Cannot parse '$length' as data length"
));
}
+2 -1
View File
@@ -2,6 +2,7 @@
namespace Predis\Protocols;
use Predis\Helpers;
use Predis\ResponseError;
use Predis\ResponseQueued;
use Predis\ServerException;
@@ -84,7 +85,7 @@ class TextProtocol implements IProtocolProcessor {
return new ResponseError($errorMessage);
default:
Utils::onCommunicationException(new ProtocolException(
Helpers::onCommunicationException(new ProtocolException(
$connection, "Unknown prefix: '$prefix'"
));
}
+2 -2
View File
@@ -2,7 +2,7 @@
namespace Predis\Protocols;
use Predis\Utils;
use Predis\Helpers;
use Predis\ProtocolException;
use Predis\Network\IConnectionComposable;
@@ -48,6 +48,6 @@ class TextResponseReader implements IResponseReader {
}
private function protocolError(IConnectionComposable $connection, $message) {
Utils::onCommunicationException(new ProtocolException($connection, $message));
Helpers::onCommunicationException(new ProtocolException($connection, $message));
}
}
+1 -1
View File
@@ -31,7 +31,7 @@ class PubSubContext implements \Iterator {
}
private function checkCapabilities(Client $client) {
if (Utils::isCluster($client->getConnection())) {
if (Helpers::isCluster($client->getConnection())) {
throw new ClientException(
'Cannot initialize a PUB/SUB context over a cluster of connections'
);