<?php

declare(strict_types=1);

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

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

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