Completed
Branch develop (a0a623)
by Romain
02:33
created

Summary   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 81
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setSubtotal() 0 6 1
A setShippingCost() 0 6 1
A setTotalTax() 0 6 1
A jsonSerialize() 0 11 1
1
<?php
2
namespace Kerox\Messenger\Message\Attachment\Template\Receipt;
3
4
class Summary implements \JsonSerializable
5
{
6
7
    /**
8
     * @var float
9
     */
10
    protected $subtotal;
11
12
    /**
13
     * @var float
14
     */
15
    protected $shippingCost;
16
17
    /**
18
     * @var float
19
     */
20
    protected $totalTax;
21
22
    /**
23
     * @var float
24
     */
25
    protected $totalCost;
26
27
    /**
28
     * Summary constructor.
29
     *
30
     * @param float $totalCost
31
     */
32
    public function __construct(float $totalCost)
33
    {
34
        $this->totalCost = $totalCost;
35
    }
36
37
    /**
38
     * @param float $subtotal
39
     * @return Summary
40
     */
41
    public function setSubtotal(float $subtotal): Summary
42
    {
43
        $this->subtotal = $subtotal;
44
45
        return $this;
46
    }
47
48
    /**
49
     * @param float $shippingCost
50
     * @return Summary
51
     */
52
    public function setShippingCost(float $shippingCost): Summary
53
    {
54
        $this->shippingCost = $shippingCost;
55
56
        return $this;
57
    }
58
59
    /**
60
     * @param float $totalTax
61
     * @return Summary
62
     */
63
    public function setTotalTax(float $totalTax): Summary
64
    {
65
        $this->totalTax = $totalTax;
66
67
        return $this;
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function jsonSerialize(): array
74
    {
75
        $json = [
76
            'subtotal' => $this->subtotal,
77
            'shipping_cost' => $this->shippingCost,
78
            'total_tax' => $this->totalTax,
79
            'total_cost' => $this->totalCost,
80
        ];
81
82
        return array_filter($json);
83
    }
84
}
85