Completed
Push — master ( b6e75f...2f94b1 )
by Baldur
02:03
created

LineItem::toArray()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 9
cts 9
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 8
nop 0
crap 4
1
<?php
2
3
namespace LAShowroom\TaxJarBundle\Model\Transaction;
4
5
use LAShowroom\TaxJarBundle\Model\LineItem as BaseLineItem;
6
use Webmozart\Assert\Assert;
7
8
class LineItem extends BaseLineItem
9
{
10
    /**
11
     * @var string
12
     */
13
    private $productIdentifier;
14
15
    /**
16
     * @var string
17
     */
18
    private $description;
19
20
    /**
21
     * @var float
22
     */
23
    private $salesTax;
24
25
    /**
26
     * @return string
27
     */
28 4
    public function getDescription()
29
    {
30 4
        return $this->description;
31
    }
32
33
    /**
34
     * @param string $description
35
     */
36 8
    public function setDescription($description)
37
    {
38 8
        $this->description = mb_strimwidth($description, 0, 255, '...');
39 8
    }
40
41
    /**
42
     * @return string
43
     */
44 2
    public function getProductIdentifier()
45
    {
46 2
        return $this->productIdentifier;
47
    }
48
49
    /**
50
     * @param string $productIdentifier
51
     */
52 6
    public function setProductIdentifier($productIdentifier)
53
    {
54 6
        $this->productIdentifier = $productIdentifier;
55 6
    }
56
57
    /**
58
     * @return float
59
     */
60 2
    public function getSalesTax()
61
    {
62 2
        return $this->salesTax;
63
    }
64
65
    /**
66
     * @param float $salesTax
67
     */
68 6
    public function setSalesTax($salesTax)
69
    {
70 6
        Assert::float($salesTax);
71
72 6
        $this->salesTax = $salesTax;
73 6
    }
74
75 2
    public function toArray()
76
    {
77 2
        $result = parent::toArray();
78
79 2
        if (!empty($this->description)) {
80 2
            $result['description'] = $this->description;
81
        }
82
83 2
        if (!empty($this->productIdentifier)) {
84 2
            $result['product_identifier'] = $this->productIdentifier;
85
        }
86
87 2
        if (!empty($this->salesTax)) {
88 2
            $result['sales_tax'] = $this->salesTax;
89
        }
90
91 2
        return $result;
92
    }
93
}
94