Skip to content

Commit b875a4f

Browse files
committed
feat(config): use built-in method when shuffling nodes
1 parent 7acd49d commit b875a4f

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/Lib/Configuration.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(array $config)
9090

9191
$this->randomizeNodes = $config['randomize_nodes'] ?? true;
9292
if ($this->randomizeNodes) {
93-
$this->shuffleNodes();
93+
shuffle($this->nodes);
9494
}
9595

9696
$nearestNode = $config['nearest_node'] ?? null;
@@ -247,18 +247,4 @@ public function getClient(): ClientInterface | HttpMethodsClient
247247
}
248248
return $this->client;
249249
}
250-
251-
/**
252-
* Shuffles the nodes array using Fisher-Yates algorithm
253-
*/
254-
private function shuffleNodes(): void
255-
{
256-
$count = count($this->nodes);
257-
for ($i = $count - 1; $i > 0; $i--) {
258-
$j = random_int(0, $i);
259-
$temp = $this->nodes[$i];
260-
$this->nodes[$i] = $this->nodes[$j];
261-
$this->nodes[$j] = $temp;
262-
}
263-
}
264250
}

0 commit comments

Comments
 (0)