LineItem::getUnitPrice()   A
last analyzed

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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace LAShowroom\TaxJarBundle\Model;
4
5
use Webmozart\Assert\Assert;
6
7
class LineItem
8
{
9
    /**
10
     * @var string
11
     */
12
    private $id;
13
14
    /**
15
     * @var string
16
     */
17
    private $quantity;
18
19
    /**
20
     * @var string
21
     */
22
    private $productTaxCode;
23
24
    /**
25
     * @var float
26
     */
27
    private $unitPrice;
28
29
    /**
30
     * @var float
31
     */
32
    private $discount;
33
34
    /**
35
     * @param string $id
36
     * @param string $quantity
37
     * @param string $productTaxCode
38
     * @param float  $unitPrice
39
     * @param float  $discount
40
     */
41 22
    public function __construct($id, $quantity, $productTaxCode, $unitPrice, $discount = 0.0)
42
    {
43 22
        Assert::integer($quantity);
44 22
        Assert::float($unitPrice);
45 22
        Assert::float($discount);
46
47 22
        $this->id = $id;
48 22
        $this->quantity = $quantity;
49 22
        $this->productTaxCode = $productTaxCode;
50 22
        $this->unitPrice = $unitPrice;
51 22
        $this->discount = $discount;
52 22
    }
53
54
    /**
55
     * @return string
56
     */
57 14
    public function getId()
58
    {
59 14
        return $this->id;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 14
    public function getQuantity()
66
    {
67 14
        return $this->quantity;
68
    }
69
70
    /**
71
     * @return string
72
     */
73 14
    public function getProductTaxCode()
74
    {
75 14
        return $this->productTaxCode;
76
    }
77
78
    /**
79
     * @return float
80
     */
81 14
    public function getUnitPrice()
82
    {
83 14
        return $this->unitPrice;
84
    }
85
86
    /**
87
     * @return float
88
     */
89 14
    public function getDiscount()
90
    {
91 14
        return $this->discount;
92
    }
93
94 14
    public function toArray()
95
    {
96
        return [
97 14
            'id' => $this->getId(),
98 14
            'quantity' => $this->getQuantity(),
99 14
            'product_tax_code' => $this->getProductTaxCode(),
100 14
            'unit_price' => $this->getUnitPrice(),
101 14
            'discount' => $this->getDiscount(),
102
        ];
103
    }
104
}
105