<?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\ECharts\EChartSourceContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolAObratuPodlaSubjektuFakturacie\PocetKontrolAObratuPodlaSubjektuFakturacieEChartSourceBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaDruhuAHodnotenia\PocetKontrolPodlaDruhuAHodnoteniaEChartSourceBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaEmisnehoSystemuVozidla\PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSourceBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaKategorieVozidla\PocetKontrolPodlaKategorieVozidlaEChartSourceBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaStavu\PocetKontrolPodlaStavuEChartSourceBuilder;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\TransformerContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\TransformerTrait;

/**
 * Class ZaznamPracoviskoSummaryEChartsDataTransformer
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary
 */
final class ZaznamPracoviskoSummaryEChartsDataTransformer 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, 'transformujUdaje')) {
                $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\ECharts\EChartSourceContract
     */
    protected function transformujUdajeZoznamPoctuKontrolPodlaDruhuAHodnotenia(Zaznam $model): EChartSourceContract
    {
        return PocetKontrolPodlaDruhuAHodnoteniaEChartSourceBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract
     */
    protected function transformujUdajeZoznamPoctuKontrolPodlaStavu(Zaznam $model): EChartSourceContract
    {
        return PocetKontrolPodlaStavuEChartSourceBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract
     */
    protected function transformujUdajeZoznamPoctuKontrolPodlaKategorieVozidla(Zaznam $model): EChartSourceContract
    {
        return PocetKontrolPodlaKategorieVozidlaEChartSourceBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract
     */
    protected function transformujUdajeZoznamPoctuKontrolPodlaEmisnehoSystemuVozidla(Zaznam $model): EChartSourceContract
    {
        return PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSourceBuilder::build($model);
    }

    /**
     * @param \Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam $model
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract
     */
    protected function transformujUdajeZoznamPoctuKontrolAObratuPodlaSubjektuFakturacie(Zaznam $model): EChartSourceContract
    {
        return PocetKontrolAObratuPodlaSubjektuFakturacieEChartSourceBuilder::build($model);
    }
}
