<?php
/**
 * Gate_Block — immutable block decision returned by a gate rule.
 *
 * @package TrustLens
 * @since   1.2.2
 */

defined( 'ABSPATH' ) || exit;

final class TrustLens_Gate_Block {

	public string $rule_id;
	public string $reason_code;
	public string $user_message;
	public int $http_status;
	public int $retry_after_seconds;

	public function __construct(
		string $rule_id,
		string $reason_code,
		string $user_message,
		int $http_status = 429,
		int $retry_after_seconds = 0
	) {
		$this->rule_id             = $rule_id;
		$this->reason_code         = $reason_code;
		$this->user_message        = $user_message;
		$this->http_status         = $http_status;
		$this->retry_after_seconds = $retry_after_seconds;
	}

	public function to_wp_error(): WP_Error {
		return new WP_Error(
			$this->reason_code,
			$this->user_message,
			array(
				'status'      => $this->http_status,
				'retry_after' => $this->retry_after_seconds,
			)
		);
	}
}
