Completed
Push — master ( 23b9fd...982873 )
by Joachim
11:42 queued 10:14
created

PaymentLine::getPrice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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