<?php

declare(strict_types=1);

namespace apexl\Io\modules\user\services;

use apexl\Io\modules\user\interfaces\PermissionInterface;
use JsonSerializable;

/**
 * One entry in the permission registry — the enum case plus its admin-UI labels.
 * Serialises as {name, group}: the exact shape the registry has always emitted.
 */
final readonly class RegisteredPermission implements JsonSerializable
{
    public function __construct(
        public PermissionInterface $permission,
        public string $name,
        public string $group = 'General',
    ) {}

    /** @return array{name: string, group: string} */
    public function jsonSerialize(): array
    {
        return ['name' => $this->name, 'group' => $this->group];
    }
}
