Created
April 2, 2021 13:47
-
-
Save vanbrabantf/d16f874dafa9e407a40246e78ee5af32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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