<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaStavu;

use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceAbstract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceItemContract;

/**
 * Class PocetKontrolPodlaStavuEChartSource
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\Pracovisko\PocetKontrolPodlaStavu
 */
final class PocetKontrolPodlaStavuEChartSource extends EChartSourceAbstract
{
    /**
     * @param \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\ECharts\EChartSourceItemContract $sourceItem
     *
     * @return $this
     */
    public function addItem(EChartSourceItemContract $sourceItem): self
    {
        if (!empty($this->items)) {
            foreach ($this->items as $existItem) {
                $existItem->incrementData($sourceItem->stavyEmisnychKontrol());
            }
        } else {
            $this->items[] = $sourceItem;
        }

        return $this;
    }
}
