<?php

namespace Licenzo\Policies;

use Licenzo\Framework\Auth\BasePolicy;
use Licenzo\Framework\Http\Request;

/**
 * Admin Policy - Requires admin capabilities
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class AdminPolicy extends BasePolicy
{
    /**
     * Error message for authorization failures.
     */
    protected string $defaultMessage = 'Access denied. Administrator privileges required.';

    /**
     * Required WordPress capabilities.
     */
    protected array $requiredCapabilities = ['manage_options'];

    /**
     * Authorize the request.
     */
    public function authorize(Request $request, ...$arguments): bool
    {
        // Must be logged in
        if (!$this->isLoggedIn()) {
            return false;
        }

        // Must have admin capabilities
        return $this->checkCapabilities();
    }
}
