Skip to content

Commit

Permalink
Merge pull request #3 from denisyukphp/3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
denisyukphp authored Nov 19, 2024
2 parents 1f7c3b1 + e571670 commit dec835d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/tests/ export-ignore
/.Dockerfile export-ignore
/.Makefile export-ignore
/Dockerfile export-ignore
/Makefile export-ignore
6 changes: 3 additions & 3 deletions src/Cluster/ClusterPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(ClusterSet ...$clusterSets)

foreach ($clusterSet->clusterNames as $clusterName) {
if (isset($this->clusterNames[$clusterName])) {
throw new \UnexpectedValueException(sprintf('The cluster "%s" has already been added.', $clusterName)); // @codeCoverageIgnore
throw new \UnexpectedValueException(\sprintf('The cluster "%s" has already been added.', $clusterName)); // @codeCoverageIgnore
}

$this->clusterNames[$clusterName] = $id;
Expand All @@ -42,11 +42,11 @@ public function pick(CollectionInterface $collection, array $context = []): Node
}

if (!\is_string($context['cluster'])) {
throw new \RuntimeException(sprintf('The parameter "cluster" must be as a string, %s given.', get_debug_type($context['cluster']))); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The parameter "cluster" must be as a string, %s given.', get_debug_type($context['cluster']))); // @codeCoverageIgnore
}

if (!isset($this->clusterNames[$context['cluster']])) {
throw new \RuntimeException(sprintf('The cluster "%s" is undefined.', $context['cluster'])); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The cluster "%s" is undefined.', $context['cluster'])); // @codeCoverageIgnore
}

$throttler = $this->throttlers[$this->clusterNames[$context['cluster']]];
Expand Down
8 changes: 4 additions & 4 deletions src/Collection/InMemoryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(array $nodes = [])

foreach ($nodes as $node) {
if ($this->has($node)) {
throw new \InvalidArgumentException(sprintf('All nodes must be unique, "%s" given as duplicate.', $node->getName()));
throw new \InvalidArgumentException(\sprintf('All nodes must be unique, "%s" given as duplicate.', $node->getName()));
}

$this->nodes[] = $node;
Expand All @@ -39,7 +39,7 @@ public function __construct(array $nodes = [])
public function add(NodeInterface $node): self
{
if ($this->has($node)) {
throw new \UnexpectedValueException(sprintf('The node "%s" has been already added.', $node->getName()));
throw new \UnexpectedValueException(\sprintf('The node "%s" has been already added.', $node->getName()));
}

$self = clone $this;
Expand All @@ -52,7 +52,7 @@ public function add(NodeInterface $node): self
public function get(int $key): NodeInterface
{
if (!isset($this->nodes[$key])) {
throw new \OutOfRangeException(sprintf('Can\'t get node at key "%d".', $key));
throw new \OutOfRangeException(\sprintf('Can\'t get node at key "%d".', $key));
}

return $this->nodes[$key];
Expand All @@ -66,7 +66,7 @@ public function has(NodeInterface $node): bool
public function remove(NodeInterface $node): self
{
if (!$this->has($node)) {
throw new \UnexpectedValueException(sprintf('The node "%s" hasn\'t been already added.', $node->getName()));
throw new \UnexpectedValueException(\sprintf('The node "%s" hasn\'t been already added.', $node->getName()));
}

$self = clone $this;
Expand Down
4 changes: 2 additions & 2 deletions src/MultipleThrottler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function pick(CollectionInterface $collection, array $context = []): Node
}

if (!isset($this->throttlers[$context['throttler']])) {
throw new \RuntimeException(sprintf('The throttler "%s" is undefined.', $context['throttler'])); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The throttler "%s" is undefined.', $context['throttler'])); // @codeCoverageIgnore
}

if (!class_exists($context['throttler']) || !is_a($context['throttler'], ThrottlerInterface::class, true)) {
throw new \UnexpectedValueException(sprintf('The throttler must be a class that exists and implements "%s" interface, "%s" given.', ThrottlerInterface::class, get_debug_type($context['throttler']))); // @codeCoverageIgnore
throw new \UnexpectedValueException(\sprintf('The throttler must be a class that exists and implements "%s" interface, "%s" given.', ThrottlerInterface::class, get_debug_type($context['throttler']))); // @codeCoverageIgnore
}

$throttler = $this->throttlers[$context['throttler']];
Expand Down
2 changes: 1 addition & 1 deletion src/RoundRobinThrottler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node
}

if (isset($context['counter']) && !\is_string($context['counter'])) {
throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
}

$counter = $context['counter'] ?? spl_object_hash($collection);
Expand Down
2 changes: 1 addition & 1 deletion src/SmoothWeightedRoundRobinThrottler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node
}

if (isset($context['counter']) && !\is_string($context['counter'])) {
throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
}

$counter = $context['counter'] ?? spl_object_hash($collection);
Expand Down
2 changes: 1 addition & 1 deletion src/WeightedRoundRobinThrottler.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function pick(CollectionInterface $collection, array $context = []): Node
}

if (isset($context['counter']) && !\is_string($context['counter'])) {
throw new \RuntimeException(sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
throw new \RuntimeException(\sprintf('The parameter "counter" must be as a string, %s given.', get_debug_type($context['counter']))); // @codeCoverageIgnore
}

$counter = $context['counter'] ?? spl_object_hash($collection);
Expand Down

0 comments on commit dec835d

Please sign in to comment.