Minor code styling adjustments.

This commit is contained in:
Daniele Alessandri
2013-12-10 21:58:53 +01:00
parent 95b9f63cab
commit d5bd28958a
3 changed files with 12 additions and 4 deletions
+7 -2
View File
@@ -53,7 +53,11 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
{
// 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.
$this->nodes[] = array('object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT);
$this->nodes[] = array(
'object' => $node,
'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT
);
$this->reset();
}
@@ -70,6 +74,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
if ($this->nodes[$i]['object'] === $node) {
array_splice($this->nodes, $i, 1);
$this->reset();
break;
}
}
@@ -166,7 +171,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface
*/
protected function getNodeHash($nodeObject)
{
if ($this->nodeHashCallback === null) {
if (!isset($this->nodeHashCallback)) {
return (string) $nodeObject;
}
@@ -55,6 +55,7 @@ class KetamaRing extends HashRing
public function hash($value)
{
$hash = unpack('V', md5($value, true));
return $hash[1];
}
@@ -63,7 +64,7 @@ class KetamaRing extends HashRing
*/
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.
return $lower < $ringKeysCount ? $lower : 0;
}
+3 -1
View File
@@ -192,7 +192,9 @@ class PredisStrategy implements StrategyInterface
}
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;