ldc-mesbr-app/src/Shared/ValueObjects/Pagination/Paginated.php
2026-10-12 17:07:56 +02:00

40 lines
728 B
PHP

<?php
declare(strict_types=1);
namespace Shared\ValueObjects\Pagination;
/** @template T of object */
final readonly class Paginated
{
/** @param T[] $items */
public function __construct(
private 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;
}
}