Browse Source

Minor code styling adjustments.

Daniele Alessandri 12 years ago
parent
commit
d5bd28958a

+ 7 - 2
lib/Predis/Cluster/Distributor/HashRing.php

@@ -53,7 +53,11 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
     {
     {
         // In case of collisions in the hashes of the nodes, the node added
         // In case of collisions in the hashes of the nodes, the node added
         // last wins, thus the order in which nodes are added is significant.
         // last wins, thus the order in which nodes are added is significant.
-        $this->nodes[] = array('object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT);
+        $this->nodes[] = array(
+            'object' => $node,
+            'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT
+        );
+
         $this->reset();
         $this->reset();
     }
     }
 
 
@@ -70,6 +74,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
             if ($this->nodes[$i]['object'] === $node) {
             if ($this->nodes[$i]['object'] === $node) {
                 array_splice($this->nodes, $i, 1);
                 array_splice($this->nodes, $i, 1);
                 $this->reset();
                 $this->reset();
+
                 break;
                 break;
             }
             }
         }
         }
@@ -166,7 +171,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
      */
      */
     protected function getNodeHash($nodeObject)
     protected function getNodeHash($nodeObject)
     {
     {
-        if ($this->nodeHashCallback === null) {
+        if (!isset($this->nodeHashCallback)) {
             return (string) $nodeObject;
             return (string) $nodeObject;
         }
         }
 
 

+ 2 - 1
lib/Predis/Cluster/Distributor/KetamaRing.php

@@ -55,6 +55,7 @@ class KetamaRing extends HashRing
     public function hash($value)
     public function hash($value)
     {
     {
         $hash = unpack('V', md5($value, true));
         $hash = unpack('V', md5($value, true));
+
         return $hash[1];
         return $hash[1];
     }
     }
 
 
@@ -63,7 +64,7 @@ class KetamaRing extends HashRing
      */
      */
     protected function wrapAroundStrategy($upper, $lower, $ringKeysCount)
     protected function wrapAroundStrategy($upper, $lower, $ringKeysCount)
     {
     {
-        // Binary search for the first item in _ringkeys with a value greater
+        // Binary search for the first item in ringkeys with a value greater
         // or equal to the key. If no such item exists, return the first item.
         // or equal to the key. If no such item exists, return the first item.
         return $lower < $ringKeysCount ? $lower : 0;
         return $lower < $ringKeysCount ? $lower : 0;
     }
     }

+ 3 - 1
lib/Predis/Cluster/PredisStrategy.php

@@ -192,7 +192,9 @@ class PredisStrategy implements StrategyInterface
         }
         }
 
 
         if (!is_callable($callback)) {
         if (!is_callable($callback)) {
-            throw new \InvalidArgumentException("Callback must be a valid callable object or NULL");
+            throw new \InvalidArgumentException(
+                "Callback must be a valid callable object or NULL"
+            );
         }
         }
 
 
         $this->commands[$commandID] = $callback;
         $this->commands[$commandID] = $callback;