<?php

declare(strict_types=1);

namespace App\Administration\Application\Query\GetStudentsImageRights;

use App\Administration\Application\Dto\PaginatedResult;

final readonly class GetStudentsImageRightsQuery
{
    public int $page;
    public int $limit;
    public ?string $search;

    public function __construct(
        public string $tenantId,
        public ?string $status = null,
        int $page = PaginatedResult::DEFAULT_PAGE,
        int $limit = PaginatedResult::DEFAULT_LIMIT,
        ?string $search = null,
    ) {
        $this->page = max(1, $page);
        $this->limit = max(1, min(PaginatedResult::MAX_LIMIT, $limit));
        $this->search = $search !== null ? mb_substr(trim($search), 0, PaginatedResult::MAX_SEARCH_LENGTH) : null;
    }
}
