Browse Source

Slightly change interface for connection factories.

Daniele Alessandri 11 years ago
parent
commit
acd29ec076

+ 1 - 1
lib/Predis/Client.php

@@ -108,7 +108,7 @@ class Client implements ClientInterface
                 $replication = isset($options->replication) && $options->replication;
                 $connection = $options->{$replication ? 'replication' : 'cluster'};
 
-                $options->connections->createAggregated($connection, $parameters);
+                $options->connections->aggregate($connection, $parameters);
 
                 return $connection;
             }

+ 1 - 3
lib/Predis/Connection/ConnectionFactory.php

@@ -128,13 +128,11 @@ class ConnectionFactory implements ConnectionFactoryInterface
     /**
      * {@inheritdoc}
      */
-    public function createAggregated(AggregatedConnectionInterface $connection, Array $parameters)
+    public function aggregate(AggregatedConnectionInterface $connection, Array $parameters)
     {
         foreach ($parameters as $node) {
             $connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node));
         }
-
-        return $connection;
     }
 
     /**

+ 2 - 3
lib/Predis/Connection/ConnectionFactoryInterface.php

@@ -43,11 +43,10 @@ interface ConnectionFactoryInterface
     public function create($parameters);
 
     /**
-     * Prepares an aggregation of connection objects.
+     * Aggregates single connections into an aggregate connection instance.
      *
      * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class.
      * @param array $parameters List of parameters for each connection object.
-     * @return AggregatedConnectionInterface
      */
-    public function createAggregated(AggregatedConnectionInterface $cluster, Array $parameters);
+    public function aggregate(AggregatedConnectionInterface $cluster, Array $parameters);
 }

+ 2 - 2
tests/Predis/ClientTest.php

@@ -173,7 +173,7 @@ class ClientTest extends StandardTestCase
         $cluster = new PredisCluster();
 
         $factory = new ConnectionFactory();
-        $factory->createAggregated($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001'));
+        $factory->aggregate($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001'));
 
         $client = new Client($cluster);
 
@@ -189,7 +189,7 @@ class ClientTest extends StandardTestCase
         $replication = new MasterSlaveReplication();
 
         $factory = new ConnectionFactory();
-        $factory->createAggregated($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
+        $factory->aggregate($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
 
         $client = new Client($replication);
 

+ 4 - 4
tests/Predis/Connection/ConnectionFactoryTest.php

@@ -304,7 +304,7 @@ class ConnectionFactoryTest extends StandardTestCase
         $factory->expects($this->never())
                 ->method('create');
 
-        $factory->createAggregated($cluster, array(new $connectionClass(), new $connectionClass()));
+        $factory->aggregate($cluster, array(new $connectionClass(), new $connectionClass()));
     }
 
     /**
@@ -326,7 +326,7 @@ class ConnectionFactoryTest extends StandardTestCase
                     return new $connectionClass;
                 }));
 
-        $factory->createAggregated($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass()));
+        $factory->aggregate($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass()));
     }
 
     /**
@@ -340,7 +340,7 @@ class ConnectionFactoryTest extends StandardTestCase
         $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'));
         $factory->expects($this->never())->method('create');
 
-        $factory->createAggregated($cluster, array());
+        $factory->aggregate($cluster, array());
     }
 
     /**
@@ -363,7 +363,7 @@ class ConnectionFactoryTest extends StandardTestCase
                 }));
 
         $nodes = array('tcp://127.0.0.1:7001?password=foo', 'tcp://127.0.0.1:7002?password=bar');
-        $factory->createAggregated($cluster, $nodes);
+        $factory->aggregate($cluster, $nodes);
     }