<?php
/**
 * Canonical map for B6 setDesignConvention across Doors 2 and 3.
 *
 * @package LolaCoreForBricks
 */

declare(strict_types=1);

namespace LolaCoreForBricks;

/**
 * Single registry for design convention write metadata.
 */
final class ConventionAbilityMap
{
    /**
     * @return array<string, array{handler: string, slug: string, label: string, description: string, destructive: bool, idempotent: bool}>
     */
    public static function entries(): array
    {
        return [
            'set_design_convention' => [
                'handler'      => 'setDesignConvention',
                'slug'         => 'lolacore-bricks/set-design-convention',
                'label'        => 'Set Design Convention',
                'description'  => 'Save the Bricks naming convention, variable policy, and protected prefixes for this site. Reports how many existing classes already match.',
                'destructive'  => false,
                'idempotent'   => true,
            ],
        ];
    }

    /**
     * @return array<string, array{requires_confirmation: bool, type: string}>
     */
    public static function doorTwoActions(): array
    {
        $actions = [];
        foreach (array_keys(self::entries()) as $actionId) {
            $actions[$actionId] = [
                'requires_confirmation' => true,
                'type'                  => 'write',
            ];
        }

        return $actions;
    }

    /**
     * @return string[]
     */
    public static function doorThreeSlugs(): array
    {
        return array_values(array_map(
            static fn (array $entry): string => $entry['slug'],
            self::entries()
        ));
    }
}
