Receipt   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 31
c 0
b 0
f 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A date() 0 3 1
A __construct() 0 5 1
A identity() 0 3 1
A price() 0 3 1
A product() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\ChargeableApi\Store;
6
7
use Damax\ChargeableApi\Credit;
8
use Damax\ChargeableApi\Identity\Identity;
9
use Damax\ChargeableApi\Product\Product;
10
use DateTimeImmutable;
11
use DateTimeInterface;
12
13
final class Receipt
14
{
15
    private $identity;
16
    private $product;
17
    private $date;
18
19
    public function __construct(Identity $identity, Product $product, DateTimeInterface $date = null)
20
    {
21
        $this->identity = $identity;
22
        $this->product = $product;
23
        $this->date = $date ?? new DateTimeImmutable();
24
    }
25
26
    public function identity(): Identity
27
    {
28
        return $this->identity;
29
    }
30
31
    public function product(): Product
32
    {
33
        return $this->product;
34
    }
35
36
    public function price(): Credit
37
    {
38
        return $this->product->price();
39
    }
40
41
    public function date(): DateTimeInterface
42
    {
43
        return $this->date;
44
    }
45
}
46