<?php

declare(strict_types=1);

namespace Maestro\Core\Support;

/**
 * B2CDataTable {@code tableKey} validation (e.g. {@code settings.users}, {@code customers.index}).
 * {@see TABLE_KEYS} is a non-exhaustive list for Superadmin UI hints only.
 */
final class KnownTableStateKeys
{
    public const TABLE_KEYS = [
        'settings.users',
        'settings.roles',
        'settings.activity-log',
        'customers.index',
        'offers.index',
        'invoices.index',
    ];

    public static function isValidTableKey(string $key): bool
    {
        if ($key === '' || strlen($key) > 128) {
            return false;
        }

        return (bool) preg_match('/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/', $key);
    }
}
