<?php

namespace AIPT\Api\Constants;

/**
 * Shared rate-limit constants used by RateLimitTrait and BulkGenerator controllers.
 *
 * Filter names are public API as of v2.6.0 — do NOT rename them.
 *
 * @package AIPT\Api\Constants
 * @since   2.6.0
 */
class RateLimitConstants {

    /**
     * Default maximum requests per window for BulkGenerator controllers (via RateLimitTrait).
     *
     * Filter: aipt_rate_limit_default_max_requests
     *
     * @since 2.6.0
     * @var int
     */
    public const DEFAULT_MAX_REQUESTS = 700;

    /**
     * Default window duration in seconds for BulkGenerator controllers (via RateLimitTrait).
     *
     * Filter: aipt_rate_limit_default_window_seconds
     *
     * @since 2.6.0
     * @var int
     */
    public const DEFAULT_WINDOW_SECONDS = 300;

    /**
     * Maximum requests per window for the Standard (legacy) bulk generator.
     *
     * @since 2.6.0
     * @var int
     */
    public const STANDARD_MAX_REQUESTS = 700;

    /**
     * Window duration in seconds for the Standard (legacy) bulk generator.
     *
     * @since 2.6.0
     * @var int
     */
    public const STANDARD_WINDOW_SECONDS = 300;

    /**
     * Get the effective default maximum requests per window.
     *
     * @since 2.6.0
     * @return int
     */
    public static function defaultMaxRequests(): int {
        /**
         * Filter the default maximum requests per rate-limit window for BulkGenerator controllers.
         *
         * @since 2.6.0
         * @param int $requests Default maximum requests.
         */
        $value = (int) apply_filters( 'aipt_rate_limit_default_max_requests', self::DEFAULT_MAX_REQUESTS );
        return $value >= 1 ? $value : self::DEFAULT_MAX_REQUESTS;
    }

    /**
     * Get the effective default window duration in seconds.
     *
     * @since 2.6.0
     * @return int
     */
    public static function defaultWindowSeconds(): int {
        /**
         * Filter the default rate-limit window duration in seconds for BulkGenerator controllers.
         *
         * @since 2.6.0
         * @param int $seconds Default window duration in seconds.
         */
        $value = (int) apply_filters( 'aipt_rate_limit_default_window_seconds', self::DEFAULT_WINDOW_SECONDS );
        return $value >= 1 ? $value : self::DEFAULT_WINDOW_SECONDS;
    }
}
