$couponValidityInformation * @param array $products */ public function __construct( public CouponName $name, public RequestedCouponQuantity $quantity, public Period $diffusion, public MoneyAmount $moneyAmount, public ProcessingCode $processingCode, public CouponValidity $couponValidity, public array $couponValidityInformation, public array $products = [], public ?PrintRules $printRules = null, public ?GS1 $gs1 = null, ?WarningThresholdQuantity $warningThresholdQuantity = null, ) { $money = $this->moneyAmount->value; foreach ($this->couponValidityInformation as $validityInformation) { if (!$validityInformation instanceof CouponValidityInformation) { throw new \DomainException('Coupon validity information must be CouponValidityInformation instances.'); } } if ($money->value < self::MIN_FACE_VALUE_IN_CENTS || $money->value > self::MAX_FACE_VALUE_IN_CENTS) { throw new \DomainException(sprintf( 'Coupon face value must be between 0.01€ and 3.00€, %s given.', $money, )); } if (!$this->hasValidityInformationFor(Country::FRANCE)) { throw new \DomainException('A coupon requires validity information for France.'); } if ($this->gs1 instanceof GS1 && !$this->hasValidityInformationFor(Country::BENELUX)) { throw new \DomainException('A GS1 coupon requires validity information for Benelux.'); } $this->warningThresholdQuantity = $warningThresholdQuantity ?? new WarningThresholdQuantity(self::DEFAULT_WARNING_THRESHOLD_QUANTITY); } private function hasValidityInformationFor(Country $country): bool { foreach ($this->couponValidityInformation as $validityInformation) { if ($validityInformation->forLocale === $country) { return true; } } return false; } }