<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary;

use Illuminate\Support\Str;
use League\Fractal\TransformerAbstract;
use Seka\Portal\Modul\Statistiky\Entities\Zaznam\ValueObjects\UdajePreTypZaznamuPracovisko;
use Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Pracovisko\PocetKontrolAObratuPodlaSubjektuFakturacie\PocetKontrolAObratuPodlaSubjektuFakturacieDataTableBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Pracovisko\PocetKontrolPodlaDruhuAHodnotenia\PocetKontrolPodlaDruhuAHodnoteniaDataTableBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Pracovisko\PocetKontrolPodlaDruhuPalivaAEmisnehoSystemuVozidla\PocetKontrolPodlaDruhuPalivaAEmisnehoSystemuVozidlaDataTableBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Pracovisko\PocetKontrolPodlaKategorieVozidla\PocetKontrolPodlaKategorieVozidlaDataTableBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Pracovisko\PocetKontrolPodlaStavu\PocetKontrolPodlaStavuDataTableBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\TransformerContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\TransformerTrait;

/**
 * Class ZaznamPracoviskoSummaryDataTableTransformer
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary
 */
final class ZaznamPracoviskoSummaryDataTableTransformer extends TransformerAbstract implements TransformerContract
{
    use TransformerTrait;

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return array
     * @throws \Seka\Portal\Modul\Statistiky\Exceptions\NeznamiDruhUdajovZaznamuException
     */
    public function transform(Zaznam $model): array
    {
        $this->checkUdajeType($model, UdajePreTypZaznamuPracovisko::class);

        $out = [];

        foreach (get_class_methods($this) as $method) {
            if (Str::startsWith($method, 'transformUdaje')) {
                $dt = $this->$method($model);
                $out[class_basename($dt)] = $dt;
            }
        }

        return $out;
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    protected function transformUdajePekZoznamPoctuKontrolPodlaStavu(Zaznam $model): DataTableContract
    {
        return PocetKontrolPodlaStavuDataTableBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    protected function transformUdajePekZoznamPoctuKontrolPodlaDruhuAHodnotenia(Zaznam $model): DataTableContract
    {
        return PocetKontrolPodlaDruhuAHodnoteniaDataTableBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    protected function transformUdajePekZoznamPoctuKontrolPodlaKategorieVozidla(Zaznam $model): DataTableContract
    {
        return PocetKontrolPodlaKategorieVozidlaDataTableBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    protected function transformUdajePekZoznamPoctuKontrolAObratuPodlaSubjektuFakturacie(Zaznam $model): DataTableContract
    {
        return PocetKontrolAObratuPodlaSubjektuFakturacieDataTableBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    protected function transformUdajePekZoznamPoctuKontrolPodlaDruhuPalivaAEmisnehoSystemuVozidla(Zaznam $model): DataTableContract
    {
        return PocetKontrolPodlaDruhuPalivaAEmisnehoSystemuVozidlaDataTableBuilder::build($model);
    }
}
