<?php
declare(strict_types=1);
namespace Slivki\Response;
use JsonSerializable;
final class PaginateResponse implements JsonSerializable
{
private iterable $items;
private int $totalCounts;
public function __construct(iterable $items, int $totalCounts)
{
$this->items = $items;
$this->totalCounts = $totalCounts;
}
public function getTotalCounts(): int
{
return $this->totalCounts;
}
public function getItems(): iterable
{
return $this->items;
}
public function jsonSerialize(): array
{
return [
'items' => $this->items,
'total' => $this->totalCounts,
];
}
}