Completed
Push — master ( 308de5...6bfaa4 )
by Hannes
03:47 queued 02:10
created

SimpleItem::getNrOfUnits()   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
Metric Value
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
declare(strict_types=1);
4
5
namespace byrokrat\billing;
6
7
use byrokrat\amount\Amount;
8
9
/**
10
 * Basic billable implementation
11
 */
12
class SimpleItem 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 Amount
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 5
    public function __construct(string $description, Amount $unitCost, int $units = 1, Amount $vat = null)
40
    {
41 5
        $this->description = $description;
42 5
        $this->unitCost = $unitCost;
43 5
        $this->units = $units;
44 5
        $this->vat = $vat ?: new Amount('.25');
45 5
    }
46
47 2
    public function getBillingDescription(): string
48
    {
49 2
        return $this->description;
50
    }
51
52 2
    public function getCostPerUnit(): Amount
53
    {
54 2
        return $this->unitCost;
55
    }
56
57 2
    public function getNrOfUnits(): int
58
    {
59 2
        return $this->units;
60
    }
61
62 2
    public function getVatRate(): Amount
63
    {
64 2
        return $this->vat;
65
    }
66
}
67