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 | |
declare(strict_types=1); | |
final class CustomerName | |
{ | |
private $firstName; | |
private $lastName; | |
public function __construct(string $firstName, string $lastName) |
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 | |
declare(strict_types=1); | |
namespace Tests\Car\Rent; | |
use Car\Rent\DateRangePriceCalculator; | |
class DateRangePriceCalculatorTest extends TestCase | |
{ | |
/** |
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 | |
final class DateRangePriceCalculator | |
{ | |
public function calculate(int $days, int $pricePerDay): int | |
{ | |
return $days * $pricePerDay; | |
} | |
} |
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() |
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 | |
declare(strict_types=1); | |
namespace Car\Rent; | |
final class DayDistanceCalculator | |
{ | |
public function calculate(int $dayPrice, int $distancePrice): int | |
{ | |
return $dayPrice + $distancePrice; |
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 | |
declare(strict_types=1); | |
namespace Car\Rent; | |
final class DistancePriceCalculator | |
{ | |
public function calculate(int $distance, int $pricePerKm): int | |
{ | |
return $distance * $pricePerKm; |
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 | |
declare(strict_types=1); | |
namespace Car\Rent; | |
final class DateRangePriceCalculator | |
{ | |
public function calculate(int $days, int $pricePerDay) :int | |
{ | |
return $days * $pricePerDay; |
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 | |
declare(strict_types=1); | |
namespace Car\Rent; | |
final class PriceCalculator | |
{ | |
private $dateRangePriceCalculator; | |
private $distancePriceCalculator; | |
private $dayDistanceCalculator; |
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 | |
declare(strict_types=1); | |
namespace Tests\Car\Rent; | |
class PriceCalculatorTest extends TestCase | |
{ | |
/** | |
* @test |
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 | |
declare(strict_types=1); | |
namespace Car\Rent; | |
final class PriceCalculator | |
{ | |
public function calculate(CarRental $carRental): int | |
{ |