ldc-arcadia-api/src/Shared/Paginated.php

40 lines
713 B
PHP

<?php
declare(strict_types=1);
namespace Shared;
/** @template T of object */
final readonly class Paginated
{
/** @param T[] $items */
public function __construct(
private readonly Pagination $pagination,
private array $items,
private int $total
) {
}
/** @return T[] */
public function getItems(): array
{
$items = [];
foreach ($this->items as $item) {
/** @var T $item */
$items[] = clone $item;
}
return $items;
}
public function getPagination(): Pagination
{
return $this->pagination;
}
public function getTotal(): int
{
return $this->total;
}
}