Skip to content

Commit

Permalink
Improve JSONConverter codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Sep 19, 2024
1 parent 69caebb commit c982bcc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/JsonConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function indentSize(int $indentSize): self
}

/**
* Set a callback to be used on each item before json encode.
* Set a callback to format each item before json encode.
*/
public function formatter(?Closure $formatter): self
{
Expand Down
2 changes: 1 addition & 1 deletion src/JsonConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function it_returns_a_null_object_if_the_collection_is_empty(): void
public function it_can_manipulate_the_record_prior_to_json_encode(): void
{
$converter = JsonConverter::create()
->formatter(fn (array $value) => array_map(strtoupper(...), $value));
->formatter(fn (array $value, int|string $offset): array => array_map(strtoupper(...), $value));

self::assertSame('[{"foo":"BAR"}]', $converter->encode([['foo' => 'bar']]));
}
Expand Down

0 comments on commit c982bcc

Please sign in to comment.