*/ public const DEFAULT_STEP_NAMES = [ 'service', 'extras', 'location', 'agent', 'datetime', 'details', 'cart', 'payment', 'confirmation', ]; /** * Constructor. * * @param int $form_id Form id (0 = default). * @param list $step_names Ordered step names (empty = default). * @param bool $cart_enabled Cart step enabled. * @param int $eligible_location_count Eligible locations. * @param int $eligible_agent_count Eligible agents. * @param int $available_extras_count Priced extras available. * @param bool $any_gateway_configured At least one payment gateway. * @param bool $pay_on_site_only Only pay-on-site enabled. * @param bool $deposit_required Selected service needs deposit. * @param bool $service_requires_prepayment Service requires prepayment. * @param bool $global_prepayment_required Global setting requires prepayment. * @param bool $global_prepayment_disabled Global setting skips payment. * @param array $settings Opaque form settings. */ public function __construct( private readonly int $form_id = 0, private readonly array $step_names = [], private readonly bool $cart_enabled = true, private readonly int $eligible_location_count = 0, private readonly int $eligible_agent_count = 0, private readonly int $available_extras_count = 0, private readonly bool $any_gateway_configured = false, private readonly bool $pay_on_site_only = true, private readonly bool $deposit_required = false, private readonly bool $service_requires_prepayment = false, private readonly bool $global_prepayment_required = false, private readonly bool $global_prepayment_disabled = false, private readonly array $settings = [], ) {} /** * Default configuration. */ public static function defaults(): self { return new self(); } /** * Form id. */ public function form_id(): int { return $this->form_id; } /** * Configured step names, falling back to the default nine. * * @return list */ public function step_names(): array { if ( [] === $this->step_names ) { return self::DEFAULT_STEP_NAMES; } return array_values( $this->step_names ); } /** * Cart enabled. */ public function cart_enabled(): bool { return $this->cart_enabled; } /** * Eligible location count. */ public function eligible_location_count(): int { return $this->eligible_location_count; } /** * Eligible agent count. */ public function eligible_agent_count(): int { return $this->eligible_agent_count; } /** * Available extras count. */ public function available_extras_count(): int { return $this->available_extras_count; } /** * Any gateway configured. */ public function any_gateway_configured(): bool { return $this->any_gateway_configured; } /** * Pay on site only. */ public function pay_on_site_only(): bool { return $this->pay_on_site_only; } /** * Deposit required. */ public function deposit_required(): bool { return $this->deposit_required; } /** * Service requires prepayment. */ public function service_requires_prepayment(): bool { return $this->service_requires_prepayment; } /** * Global prepayment required. */ public function global_prepayment_required(): bool { return $this->global_prepayment_required; } /** * Global prepayment disabled (skip payment). */ public function global_prepayment_disabled(): bool { return $this->global_prepayment_disabled; } /** * Opaque settings. * * @return array */ public function settings(): array { return $this->settings; } /** * Clone with updated eligibility counts / payment flags. * * @param int|null $locations Locations. * @param int|null $agents Agents. * @param int|null $extras Extras. * @param bool|null $deposit Deposit required. * @param bool|null $service_prepay Service prepay. */ public function with_eligibility( ?int $locations = null, ?int $agents = null, ?int $extras = null, ?bool $deposit = null, ?bool $service_prepay = null ): self { return new self( $this->form_id, $this->step_names, $this->cart_enabled, $locations ?? $this->eligible_location_count, $agents ?? $this->eligible_agent_count, $extras ?? $this->available_extras_count, $this->any_gateway_configured, $this->pay_on_site_only, $deposit ?? $this->deposit_required, $service_prepay ?? $this->service_requires_prepayment, $this->global_prepayment_required, $this->global_prepayment_disabled, $this->settings, ); } }