<?php

declare(strict_types=1);

namespace App\Domain\Shared\Application\Response;

use App\Domain\Shared\Domain\Contract\ResponseInterface;
use App\Domain\Shared\Domain\Model\Job;

readonly class JobListResponse implements ResponseInterface
{
    /**
     * @param Job[] $items
     */
    public function __construct(
        public array $items,
        public int $total,
        public int $page,
        public int $limit,
        public int $pages
    ) {
    }

    public static function fromJobs(array $jobs, int $total, int $page, int $limit): self
    {
        return new self(
            items: $jobs,
            total: $total,
            page: $page,
            limit: $limit,
            pages: (int) ceil($total / $limit)
        );
    }
}
