Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Calculator | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
calculate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Alfa\Interview\Context\Service; |
6 | |
7 | use Alfa\Interview\Context\Entity\Offer; |
8 | use Alfa\Interview\Context\Factory\OfferFactory; |
9 | |
10 | class Calculator |
11 | { |
12 | public function __construct( |
13 | private readonly OfferFactory $offerFactory |
14 | ) { |
15 | } |
16 | |
17 | /** |
18 | * @param array<int, string> $additionals |
19 | */ |
20 | public function calculate(string $insuranceType, array $additionals): int |
21 | { |
22 | $offer = $this->offerFactory->create($insuranceType, ...$additionals); |
23 | |
24 | return $offer->getTotalPrice()->ammount; |
25 | } |
26 | } |