<?php

declare(strict_types=1);

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

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 PocetKontrolPodlaDruhuEChartSourceBuilder
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Technik\PocetKontrolPodlaDruhu
 */
final class PocetKontrolPodlaDruhuEChartSourceBuilder 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 PocetKontrolPodlaDruhuEChartSource();

        if (!empty($items)) {
            foreach ($items as $item) {
                if (!$item instanceof PocetKontrolPodlaDruhuEChartSourceItem) 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 PocetKontrolPodlaDruhuEChartSource();
    }
}
