<?php

declare(strict_types=1);

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

use Seka\Portal\Modul\Statistiky\Entities\Zaznam\Zaznam;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableBuilderContract;
use Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract;

/**
 * Class PocetKontrolSObratomDataTableBuilder
 *
 * @package Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\Technik\PocetKontrolSObratom
 */
final class PocetKontrolSObratomDataTableBuilder implements DataTableBuilderContract
{
    /**
     * @param array $rows
     *
     * @return \Seka\Portal\Modul\Statistiky\Repositories\Eloquent\Transformers\Summary\DataTables\DataTableContract
     */
    public static function buildWithRows(array $rows = []): DataTableContract
    {
        $dataTable = new PocetKontrolSObratomDataTable();

        if (!empty($rows)) {
            foreach ($rows as $row) {
                if (!$row instanceof PocetKontrolSObratomDataTableRow) continue;

                $dataTable->addRow($row);
            }
        }

        return $dataTable;
    }

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