Skip to content

Commit

Permalink
Merge pull request #7 from utopia-php/fix-qa
Browse files Browse the repository at this point in the history
Fix: Bugs from QA
  • Loading branch information
christyjacob4 authored Nov 8, 2022
2 parents 1137448 + 9edb639 commit 8b14583
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Balancer/Algorithm/RoundRobin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public function run(array $options): ?Option

$option = null;

if (\count($options) === $this->index) {
$option = $options[0];
$this->index = 0;
} else {
if (\array_key_exists($this->index, $options)) {
$option = $options[$this->index];
} else {
$option = $options[0] ?? null;
$this->index = 0;
}

return $option;
Expand Down
4 changes: 4 additions & 0 deletions src/Balancer/Balancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public function run(): ?Option

$options = \array_values($options);

if (\count($options) === 0) {
return null;
}

return $this->algo->run($options);
}
}

0 comments on commit 8b14583

Please sign in to comment.