<?php

namespace Balbooa\Component\Forms\Administrator\Helper;

use Balbooa\Component\Forms\Administrator\Exceptions\AccessDeniedException;
use Joomla\CMS\Factory;

class AccessGuard
{
    public static function check(string $permission): void
    {
        if (!self::isAuthorised($permission)) {
            throw new AccessDeniedException();
        }
    }

    public static function isAuthorised(string $permission): bool
    {
        return Factory::getApplication()->getIdentity()->authorise($permission, 'com_baforms');
    }
}
