Skip to content

Commit

Permalink
Add JSON serialization for Paginated returns
Browse files Browse the repository at this point in the history
  • Loading branch information
hotmeteor committed Sep 6, 2022
1 parent b5e768e commit b7ffd9c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Paginated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Phinch;

class Paginated
class Paginated implements \JsonSerializable
{
/**
* Paginated constructor.
Expand Down Expand Up @@ -43,4 +43,15 @@ public function results(): array

return array_shift($data);
}

/**
* @return false|mixed|string
*/
public function jsonSerialize(): mixed
{
return json_encode([
'results' => $this->results(),
'meta' => $this->meta(),
], JSON_PRETTY_PRINT);
}
}

0 comments on commit b7ffd9c

Please sign in to comment.