Completed
Push — master ( 6a68ad...603d58 )
by Joachim
04:11
created

PaymentLine::setPayment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Loevgaard\Dandomain\Pay\Model;
4
5
use Brick\Math\BigDecimal;
6
7
class PaymentLine
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $productNumber;
13
14
    /**
15
     * @var string
16
     */
17
    protected $name;
18
19
    /**
20
     * @var int
21
     */
22
    protected $quantity;
23
24
    /**
25
     * The price excl vat.
26
     *
27
     * @var float
28
     */
29
    protected $price;
30
31
    /**
32
     * This is the VAT percentage, i.e. 25 for Denmark.
33
     *
34
     * @var int
35
     */
36
    protected $vat;
37
38
    /**
39
     * @var Payment
40
     */
41
    protected $payment;
42
43
    /******************
44
     * Helper methods *
45
     *****************/
46
47
    /**
48
     * @return float
49
     */
50 3
    public function getPriceExclVat(): float
51
    {
52 3
        return $this->getPrice();
53
    }
54
55
    /**
56
     * @return float
57
     */
58 3
    public function getPriceInclVat(): float
59
    {
60 3
        $price = BigDecimal::of($this->getPrice());
61
62
        return $price
63 3
            ->multipliedBy(100 + $this->getVat())
64 3
            ->dividedBy(100, 2)
65 3
            ->toFloat()
66
        ;
67
    }
68
69
    /*********************
70
     * Getters / Setters *
71
     ********************/
72
73
    /**
74
     * @return string
75
     */
76 6
    public function getProductNumber(): string
77
    {
78 6
        return $this->productNumber;
79
    }
80
81
    /**
82
     * @param string $productNumber
83
     *
84
     * @return PaymentLine
85
     */
86 9
    public function setProductNumber(string $productNumber): self
87
    {
88 9
        $this->productNumber = $productNumber;
89
90 9
        return $this;
91
    }
92
93
    /**
94
     * @return string
95
     */
96 6
    public function getName(): string
97
    {
98 6
        return $this->name;
99
    }
100
101
    /**
102
     * @param string $name
103
     *
104
     * @return PaymentLine
105
     */
106 9
    public function setName($name): self
107
    {
108 9
        $this->name = $name;
109
110 9
        return $this;
111
    }
112
113
    /**
114
     * @return int
115
     */
116 6
    public function getQuantity(): int
117
    {
118 6
        return $this->quantity;
119
    }
120
121
    /**
122
     * @param int $quantity
123
     *
124
     * @return PaymentLine
125
     */
126 9
    public function setQuantity($quantity): self
127
    {
128 9
        $this->quantity = $quantity;
129
130 9
        return $this;
131
    }
132
133
    /**
134
     * Returns the price excl vat.
135
     *
136
     * @return float
137
     */
138 6
    public function getPrice(): float
139
    {
140 6
        return $this->price;
141
    }
142
143
    /**
144
     * @param float $price
145
     *
146
     * @return PaymentLine
147
     */
148 9
    public function setPrice($price): self
149
    {
150 9
        $this->price = $price;
151
152 9
        return $this;
153
    }
154
155
    /**
156
     * Returns the VAT percentage.
157
     *
158
     * @return int
159
     */
160 6
    public function getVat(): int
161
    {
162 6
        return $this->vat;
163
    }
164
165
    /**
166
     * @param int $vat
167
     *
168
     * @return PaymentLine
169
     */
170 9
    public function setVat($vat): self
171
    {
172 9
        $this->vat = $vat;
173
174 9
        return $this;
175
    }
176
177
    /**
178
     * @return Payment
179
     */
180 3
    public function getPayment(): Payment
181
    {
182 3
        return $this->payment;
183
    }
184
185
    /**
186
     * @param Payment $payment
187
     *
188
     * @return PaymentLine
189
     */
190 6
    public function setPayment(Payment $payment): self
191
    {
192 6
        $this->payment = $payment;
193
194 6
        return $this;
195
    }
196
}
197