Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Offer
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 addAdditional
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getTotalPrice
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Alfa\Interview\Context\Entity;
6
7use Alfa\Interview\Context\Enum\AdditionalType;
8use Alfa\Interview\Context\Interface\HasPrice;
9use Alfa\Interview\Context\ValueObject\{Additional, Id, Insurance, Price};
10
11class Offer
12{
13    /**
14     * @var array<string, Additional>
15     */
16    private array $additionals = [];
17
18    private HasPrice $item;
19
20    public function __construct(
21        private readonly Id $id,
22        Insurance $insurance
23    ) {
24        $this->item = $insurance;
25    }
26
27    public function addAdditional(AdditionalType $additional): self
28    {
29        $this->item = new Additional($additional, $this->item);
30
31        return $this;
32    }
33
34    public function getTotalPrice(): Price
35    {
36        return $this->item->getPrice();
37    }
38}