Completed
Push — master ( 9621c0...4bb787 )
by Tobias
01:47
created

TaxSetting::toArray()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
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
declare(strict_types=1);
4
5
namespace Billogram\Model\Setting;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class TaxSetting implements CreatableFromArray
13
{
14
    /**
15
     * @var bool
16
     */
17
    private $isVatRegistered;
18
19
    /**
20
     * @var bool
21
     */
22
    private $hasFskatt;
23
24
    /**
25
     * @var string
26
     */
27
    private $vatNo;
28
29
    /**
30
     * @return bool
31
     */
32
    public function isVatRegistered(): bool
33
    {
34
        return $this->isVatRegistered;
35
    }
36
37
    /**
38
     * @param bool $isVatRegistered
39
     *
40
     * @return TaxSetting
41
     */
42
    public function withIsVatRegistered(bool $isVatRegistered)
43
    {
44
        $new = clone $this;
45
        $new->isVatRegistered = $isVatRegistered;
46
47
        return $new;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    public function isHasFskatt(): bool
54
    {
55
        return $this->hasFskatt;
56
    }
57
58
    /**
59
     * @param bool $hasFskatt
60
     *
61
     * @return TaxSetting
62
     */
63
    public function withHasFskatt(bool $hasFskatt)
64
    {
65
        $new = clone $this;
66
        $new->hasFskatt = $hasFskatt;
67
68
        return $new;
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74
    public function getVatNo()
75
    {
76
        return $this->vatNo;
77
    }
78
79
    /**
80
     * @param $vatNo
81
     *
82
     * @return TaxSetting
83
     */
84
    public function withVatNo($vatNo)
85
    {
86
        $new = clone $this;
87
        $new->vatNo = $vatNo;
88
89
        return $new;
90
    }
91
92
    /**
93
     * Create an API response object from the HTTP response from the API server.
94
     *
95
     * @param array $data
96
     *
97
     * @return TaxSetting
98
     */
99 1
    public static function createFromArray(array $data)
100
    {
101 1
        $tax = new self();
102 1
        $tax->isVatRegistered = $data['is_vat_registered'] ?? null;
103 1
        $tax->hasFskatt = $data['has_fskatt'] ?? null;
104 1
        $tax->vatNo = $data['vat_no'] ?? null;
105
106 1
        return $tax;
107
    }
108
109 1
    public function toArray()
110
    {
111 1
        $data = [];
112 1
        if ($this->isVatRegistered !== null) {
113 1
            $data['is_vat_registered'] = $this->isVatRegistered;
114
        }
115 1
        if ($this->hasFskatt !== null) {
116 1
            $data['has_fskatt'] = $this->hasFskatt;
117
        }
118 1
        if ($this->vatNo !== null) {
119 1
            $data['vat_no'] = $this->vatNo;
120
        }
121
122 1
        return $data;
123
    }
124
}
125