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

Summary::setTotalTax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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