<?php
/**
 * Allowed and forbidden Bricks page-setting keys.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks\Support;

/**
 * Page settings live in `_bricks_page_settings`. Template conditions stay in B11.
 */
final class PageSettingsKeys
{
    /**
     * @var string[]
     */
    private const FORBIDDEN = [
        'templateConditions',
        'customScriptsHeader',
        'customScriptsBodyHeader',
        'customScriptsBodyFooter',
        'apply',
    ];

    /**
     * @return string[]
     */
    public static function forbidden(): array
    {
        return self::FORBIDDEN;
    }

    public static function isForbidden(string $key): bool
    {
        $base = strtolower((string) explode(':', $key, 2)[0]);

        foreach (self::FORBIDDEN as $forbidden) {
            if (strtolower($forbidden) === $base) {
                return true;
            }
        }

        return false;
    }

    public static function isCssKey(string $key): bool
    {
        return str_starts_with($key, 'customCss');
    }
}
