<?php

declare(strict_types=1);

namespace apexl\Io\modules\tabulator\Tabulatable\ColumnCallback;

use apexl\Io\modules\tabulator\Interfaces\HasTabulatorViewInterface;
use apexl\Io\modules\tabulator\Interfaces\TabulatableColumnCallback;

final readonly class ImageMultiple implements TabulatableColumnCallback
{
    public function __construct(private ?string $altField, private SimpleField $simpleField) {}

    public function __invoke(HasTabulatorViewInterface $entity, string $field): array
    {
        return [
            'src' => ($this->simpleField)($entity, $field),
            'alt' => $this->altField ? ($this->simpleField)($entity, $this->altField) : '',
        ];
    }
}

