Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Additional | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getPrice | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Alfa\Interview\Context\ValueObject; |
6 | |
7 | use Alfa\Interview\Context\Enum\AdditionalType; |
8 | use Alfa\Interview\Context\Interface\HasPrice; |
9 | |
10 | class Additional implements HasPrice |
11 | { |
12 | public function __construct( |
13 | private readonly AdditionalType $type, |
14 | private readonly HasPrice $previous |
15 | ) { |
16 | } |
17 | |
18 | public function getPrice(): Price |
19 | { |
20 | return $this->previous->getPrice() |
21 | ->add(new Price($this->type->value)); |
22 | } |
23 | } |