<?php

declare(strict_types=1);

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

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

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