<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Technik\PocetKontrolPodlaEmisnehoSystemuVozidla;

use Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceBuilderContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract;

/**
 * Class PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSourceBuilder
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Technik\PocetKontrolPodlaEmisnehoSystemuVozidla
 */
final class PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSourceBuilder implements EChartSourceBuilderContract
{
    /**
     * @param array $items
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceContract
     */
    public static function buildWithItems(array $items = []): EChartSourceContract
    {
        $chartSource = new PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSource();

        if (!empty($items)) {
            foreach ($items as $item) {
                if (!$item instanceof PocetKontrolPodlaEmisnehoSystemuVozidlaEChartSourceItem) continue;

                $chartSource->addItem($item);
            }
        }

        return $chartSource;
    }

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