> */ public const CAPABILITIES = array( 'get_site_inventory' => GetSiteInventory::class, 'get_plugin_details' => GetPluginDetails::class, 'get_action_scheduler_summary' => GetActionSchedulerSummary::class, 'get_failed_actions' => GetFailedActions::class, 'get_recent_operational_errors' => GetRecentOperationalErrors::class, 'get_order_state' => GetOrderState::class, 'get_subscription_state' => GetSubscriptionState::class, 'get_webhook_summary' => GetWebhookSummary::class, 'get_recent_changes' => GetRecentChanges::class, 'get_runtime_summary' => GetRuntimeSummary::class, ); public function __construct( private Settings $settings ) {} public function has( string $name ): bool { return isset( self::CAPABILITIES[ $name ] ); } public function permitted( string $name ): bool { if ( ! $this->has( $name ) ) { return false; } $allow = $this->settings->capability_allowlist(); return $allow === array() || in_array( $name, $allow, true ); } public function make( string $name ): CapabilityInterface { if ( ! $this->has( $name ) ) { throw new \InvalidArgumentException( 'unknown_capability' ); } $class = self::CAPABILITIES[ $name ]; return new $class( $this->settings ); } /** @param array $params */ public static function int_param( array $params, string $key, int $default, int $min, int $max ): int { if ( ! array_key_exists( $key, $params ) ) { return $default; } if ( ! is_numeric( $params[ $key ] ) ) { throw new \InvalidArgumentException( esc_html( "invalid_param:$key" ) ); } $v = (int) $params[ $key ]; if ( $v < $min || $v > $max ) { throw new \InvalidArgumentException( esc_html( "out_of_range:$key" ) ); } return $v; } }