diff --git a/src/Paginated.php b/src/Paginated.php index 6146c6d..8cf4b72 100644 --- a/src/Paginated.php +++ b/src/Paginated.php @@ -2,7 +2,7 @@ namespace Phinch; -class Paginated +class Paginated implements \JsonSerializable { /** * Paginated constructor. @@ -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); + } }