<?php // phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase, WordPress.Files.FileName.InvalidClassFileName
/**
 * Value object for resolved wholesale minimum order requirements.
 *
 * @package Autoship\Domain\WholesalePricing
 * @since   2.13.0
 */

namespace Autoship\Domain\WholesalePricing;

/**
 * Immutable value object representing resolved wholesale minimum order requirements.
 *
 * Encapsulates the minimum quantity, minimum price, and conditional logic
 * resolved from site-wide, per-role, and per-user wholesale settings.
 *
 * @package Autoship\Domain\WholesalePricing
 * @since   2.13.0
 */
final class WholesaleRequirements {

	/**
	 * Minimum order quantity, or null if not set.
	 *
	 * @var int|null
	 */
	private ?int $minimum_order_items;

	/**
	 * Minimum order subtotal, or null if not set.
	 *
	 * @var float|null
	 */
	private ?float $minimum_order_price;

	/**
	 * Conditional logic operator: 'and' or 'or'.
	 *
	 * @var string
	 */
	private string $conditional_logic;

	/**
	 * Constructor.
	 *
	 * @param int|null   $minimum_order_items Minimum order quantity.
	 * @param float|null $minimum_order_price Minimum order subtotal.
	 * @param string     $conditional_logic   Logic operator ('and' or 'or').
	 */
	public function __construct( ?int $minimum_order_items, ?float $minimum_order_price, string $conditional_logic = 'and' ) {
		$this->minimum_order_items = $minimum_order_items;
		$this->minimum_order_price = $minimum_order_price;
		$this->conditional_logic   = $conditional_logic;
	}

	/**
	 * Check if a quantity requirement is set.
	 *
	 * @return bool
	 */
	public function has_quantity_requirement(): bool {
		return null !== $this->minimum_order_items && $this->minimum_order_items > 0;
	}

	/**
	 * Check if a price requirement is set.
	 *
	 * @return bool
	 */
	public function has_price_requirement(): bool {
		return null !== $this->minimum_order_price && $this->minimum_order_price > 0;
	}

	/**
	 * Get the minimum order quantity.
	 *
	 * @return int|null
	 */
	public function get_minimum_order_items(): ?int {
		return $this->minimum_order_items;
	}

	/**
	 * Get the minimum order subtotal.
	 *
	 * @return float|null
	 */
	public function get_minimum_order_price(): ?float {
		return $this->minimum_order_price;
	}

	/**
	 * Get the conditional logic operator.
	 *
	 * @return string
	 */
	public function get_conditional_logic(): string {
		return $this->conditional_logic;
	}
}
