Skip to content

Commit

Permalink
refactor: improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Oct 2, 2024
1 parent 2b50d16 commit f919ad8
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ public function calculate(): void
return;
}

$tracked = TriStateService::DISABLED;
if (DeliveryOptions::PACKAGE_TYPE_PACKAGE_SMALL_NAME === $deliveryOptions->packageType
&& CountryCodes::CC_NL !== $this->order->shippingAddress->cc
) {
$tracked = TriStateService::ENABLED;
}

$this->order->deliveryOptions->shipmentOptions->fill([
ShipmentOptions::AGE_CHECK => TriStateService::DISABLED,
ShipmentOptions::DIRECT_RETURN => TriStateService::DISABLED,
Expand All @@ -38,7 +31,20 @@ public function calculate(): void
ShipmentOptions::ONLY_RECIPIENT => TriStateService::DISABLED,
ShipmentOptions::SAME_DAY_DELIVERY => TriStateService::DISABLED,
ShipmentOptions::SIGNATURE => TriStateService::DISABLED,
ShipmentOptions::TRACKED => $tracked,
ShipmentOptions::TRACKED => $this->calculateTracked(),
]);
}

/**
* @return int
*/
private function calculateTracked(): int
{
$isPackageSmall = DeliveryOptions::PACKAGE_TYPE_PACKAGE_SMALL_NAME === $this->order->deliveryOptions->packageType;
$isNotNl = CountryCodes::CC_NL !== $this->order->shippingAddress->cc;

return $isPackageSmall && $isNotNl ?
TriStateService::ENABLED
: TriStateService::DISABLED;
}
}

0 comments on commit f919ad8

Please sign in to comment.