Skip to content

Instantly share code, notes, and snippets.

@vanbrabantf
Created April 2, 2021 13:47
Show Gist options
  • Save vanbrabantf/d16f874dafa9e407a40246e78ee5af32 to your computer and use it in GitHub Desktop.
Save vanbrabantf/d16f874dafa9e407a40246e78ee5af32 to your computer and use it in GitHub Desktop.
<?php
public function calculate(CarRental $carRental): int
{
$startDate = $carRental->getStartDate();
$endDate = $carRental->getEndDate();
$days = $startDate->diff($endDate);
$dayPrice = $this->dateRangePriceCalculator->calculate(
$days,
$carRental->getPricePerDay()
);
$distancePrice = $this->distancePriceCalculator->calculate(
$carRental->getDistance(),
$carRental->getPricePerKm()
);
return $this->dayDistanceCalculator->calculate(
$dayPrice,
$distancePrice
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment