Skip to content

Commit

Permalink
Handle nullable data in transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
xHeaven committed Jan 24, 2025
1 parent 2523b17 commit 6d668a1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/GraphQLClientTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@

readonly class GraphQLClientTransformer
{
/**
* @param array<mixed, mixed> $data
*/
public function __construct(private array $data) {}
public function __construct(private ?array $data) {}

/**
* @return array<mixed, mixed>
*/
public function toArray(): array
public function toArray(): ?array
{
return $this->data;
}

public function toFluent(): Fluent
{
return fluent($this->data);
return fluent($this->data ?? []);
}

public function toCollection(): Collection
Expand Down

0 comments on commit 6d668a1

Please sign in to comment.