<?php

namespace App\Modules\HR\Reports\Services;

use App\Modules\HR\Reports\Repositories\OperationsReportRepository;
use App\Modules\HR\Reports\Repositories\WorkforceReportRepository;
use App\Modules\HR\Reports\Support\HrReportKey;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;

class HrReportService
{
    public function __construct(
        private readonly WorkforceReportRepository $workforce,
        private readonly OperationsReportRepository $operations,
    ) {}

    /** @param array<string, mixed> $filters */
    public function paginate(
        int $tenantId,
        HrReportKey $report,
        array $filters,
    ): LengthAwarePaginator {
        if (in_array($report->category(), ['employee', 'performance'], true)) {
            return $this->workforce->paginate($tenantId, $report, $filters);
        }

        return $this->operations->paginate($tenantId, $report, $filters);
    }
}
