<?php

declare(strict_types=1);

namespace apexl\Io\modules\tabulator\Collections;

use apexl\Io\modules\tabulator\Interfaces\HasTabulatorViewInterface;
use Arrayy\Arrayy;
use Arrayy\Collection\AbstractCollection;
use Arrayy\TypeCheck\TypeCheckArray;
use Arrayy\TypeCheck\TypeCheckCallback;

/**
 * Holds tabulatable entity CLASS-STRINGS (class-string<HasTabulatorViewInterface>),
 * not instances — route building reads only static metadata, so entities are never
 * constructed at build time. Every added value is validated to be a class-string
 * that implements HasTabulatorViewInterface.
 */
final class HasTabulatorViewInterfaceClassCollection extends AbstractCollection
{
    public function getType()
    {
        return TypeCheckArray::create([
            Arrayy::ARRAYY_HELPER_TYPES_FOR_ALL_PROPERTIES => new TypeCheckCallback(
                static fn($value): bool => is_string($value)
                    && is_a($value, HasTabulatorViewInterface::class, true),
            ),
        ]);
    }
}
