<?php

declare(strict_types=1);

namespace Plugin\tnt_stabila_shop\src\UserInterface\Tables\ErrorTable;

use Plugin\tnt_stabila_shop\src\Abstracts\AbstractTableData;
use Plugin\tnt_stabila_shop\src\Interfaces\TableDataInterface;

class ErrorTableData extends AbstractTableData implements TableDataInterface
{
    /**
     * @param list<string> $header
     * @param list<object> $rows
     */
    public function __construct(array $header, array $rows, string $tplName, ErrorTablePagination $pagination)
    {
        $columns = [];
        foreach ($header as $column) {
            $columns[$column] = $this->niceNameLocalized($column);
        }
        parent::__construct((object)$columns, $rows, $tplName, $pagination);
    }

    public function niceNameLocalized(string $column): string
    {
        return match ($column) {
            'id'              => __('ID'),
            'exceptionType'   => __('Exception Type'),
            'sdkVersion'      => __('SDK Version'),
            'filePath'        => __('File path'),
            'template'        => __('Template'),
            'shopVersion'     => __('Shop Version'),
            'severity'        => __('Severity'),
            'message'         => __('Message'),
            'createDate'      => __('Create Date'),
            'reportLink'      => __('Report Link'),
            'reportMaxDate'   => __('Report Max Date'),
            'totalExecTime'   => __('Total Execution Time'),
            'shopLanguage'    => __('Shop Language'),
            'shopCurrency'    => __('Shop Currency'),
            'cartCount'       => __('Cart Count'),
            'cartItems'       => __('Cart Items'),
            'deliveryCountry' => __('Delivery Country'),
            'invoiceCountry'  => __('Invoice Country'),
            'taxRates'        => __('Tax Rates'),
            'userBrowser'     => __('User Browser'),
            'userID'          => __('User ID'),
            default           => $column,
        };
    }
}
