<?php

declare(strict_types=1);

namespace App\Business\DataImport\Exports;

use App\Business\DataImport\DataImportTemplateRegistry;
use App\Business\DataImport\Enums\DataImportType;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;

final class DataImportTemplateExport implements FromArray, WithHeadings, WithStrictNullComparison
{
    public function __construct(
        private readonly DataImportType $importType,
    ) {}

    /**
     * @return list<list<string|null>>
     */
    public function array(): array
    {
        return app(DataImportTemplateRegistry::class)->sampleRowsForExport($this->importType);
    }

    /**
     * @return list<string>
     */
    public function headings(): array
    {
        return app(DataImportTemplateRegistry::class)->displayHeadings($this->importType);
    }
}
