<?php

namespace App\Config;

class RolesConfig
{
    public static function roles(): array
    {
        return [
            'admin' => [
                'id' => 142345678901234561,
                'name' => 'Administrator',
                'permissions' => ['auth:*', 'users:read', 'users:update', 'roles:read'],
            ],
            'user' => [
                'id' => 142345678901234564,
                'name' => 'User',
                'permissions' => ['profile:read', 'profile:update'],
            ],
            'service' => [
                'id' => 142345678901234569,
                'name' => 'Service',
                'permissions' => ['tokens:verify', 'jwks:read'],
            ],
        ];
    }

    public static function defaultRoleId(): int
    {
        return self::roles()['user']['id'];
    }

    public static function permissionsForRoleId(int $roleId): array
    {
        foreach (self::roles() as $role) {
            if ((int) $role['id'] === $roleId) {
                return $role['permissions'];
            }
        }

        return [];
    }
}
