<?php

declare(strict_types=1);

namespace Australcode\Rewards\Domain\Redemption;

defined( 'ABSPATH' ) || exit;

/**
 * Result of evaluating a redemption request: how many points would actually be
 * spent and the resulting discount amount, or why it was rejected. `points` may
 * be lower than requested (clamped to balance / cart / max-percent limits).
 */
final class RedemptionQuote {

	private function __construct(
		public readonly bool $valid,
		public readonly int $points,
		public readonly float $amount,
		public readonly string $reason = '',
	) {
	}

	public static function valid( int $points, float $amount ): self {
		return new self( true, $points, $amount );
	}

	/**
	 * @param string $reason Machine code: redemption_disabled | user_blocked |
	 *                       below_minimum | nothing_to_redeem | zero_amount.
	 */
	public static function invalid( string $reason ): self {
		return new self( false, 0, 0.0, $reason );
	}
}
