Item::getVatRate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace byrokrat\billing;
6
7
use byrokrat\amount\Amount;
8
9
/**
10
 * Basic billable implementation
11
 */
12
class Item implements Billable
13
{
14
    /**
15
     * @var string
16
     */
17
    private $description;
18
19
    /**
20
     * @var Amount
21
     */
22
    private $unitCost;
23
24
    /**
25
     * @var int
26
     */
27
    private $units;
28
29
    /**
30
     * @var float
31
     */
32
    private $vat;
33
34
    /**
35
     * Set immutable data at construct
36
     *
37
     * Note that a VAT of 25% is represented as .25
38
     */
39 4
    public function __construct(string $description, Amount $unitCost, int $units = 1, float $vat = .25)
40
    {
41 4
        $this->description = $description;
42 4
        $this->unitCost = $unitCost;
43 4
        $this->units = $units;
44 4
        $this->vat = $vat;
45 4
    }
46
47 1
    public function getBillingDescription(): string
48
    {
49 1
        return $this->description;
50
    }
51
52 1
    public function getCostPerUnit(): Amount
53
    {
54 1
        return $this->unitCost;
55
    }
56
57 1
    public function getNrOfUnits(): int
58
    {
59 1
        return $this->units;
60
    }
61
62 1
    public function getVatRate(): float
63
    {
64 1
        return $this->vat;
65
    }
66
}
67