Skip to content

Commit

Permalink
Applied code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Feb 4, 2025
1 parent 2e86243 commit 5dbe5d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/Relay/PageAwareConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Overblog\GraphQLBundle\Relay\Connection\ConnectionBuilder;
use Overblog\GraphQLBundle\Relay\Connection\ConnectionInterface;
use Overblog\GraphQLBundle\Relay\Connection\PageInfoInterface;
use UnexpectedValueException;

/**
* @phpstan-template T
Expand Down Expand Up @@ -48,15 +49,15 @@ public static function fromConnection(ConnectionInterface|Promise $connection, A
{
$connection = self::resolvePromise(
$connection,
static fn ($resolved) => $resolved instanceof ConnectionInterface,
static fn ($resolved): bool => $resolved instanceof ConnectionInterface,
'Resolved result is not a ConnectionInterface'
);

$return = new self($connection->getEdges(), $connection->getPageInfo());

$totalCount = self::resolvePromise(
$connection->getTotalCount(),
static fn ($resolved) => is_int($resolved) || null === $resolved,
static fn ($resolved): bool => is_int($resolved) || null === $resolved,
'Resolved result is not an int or null'
);

Expand All @@ -82,7 +83,7 @@ private static function resolvePromise(mixed $value, callable $validator, string
$resolvedValue = $promiseAdapter->wait($value);

if (!$validator($resolvedValue)) {
throw new \UnexpectedValueException($errorMessage);
throw new UnexpectedValueException($errorMessage);
}

return $resolvedValue;
Expand Down

0 comments on commit 5dbe5d6

Please sign in to comment.