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

InvoiceDefaults::withDefaultInvoiceFee()   A

Complexity

Conditions 1
Paths 1

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 7
Code Lines 4

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 2
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 InvoiceDefaults implements CreatableFromArray
13
{
14
    /**
15
     * @var string
16
     */
17
    private $defaultMessage;
18
19
    /**
20
     * @var int
21
     */
22
    private $defaultInterestRate;
23
24
    /**
25
     * @var int
26
     */
27
    private $defaultReminderFee;
28
29
    /**
30
     * @var int
31
     */
32
    private $defaultInvoiceFee;
33
34
    /**
35
     * @var AutomaticReminder
36
     */
37
    private $automaticReminders;
38
39
    /**
40
     * @var AutomaticReminderWriteOff
41
     */
42
    private $automaticWriteoff;
43
44
    /**
45
     * @var AutomaticReminderCollection
46
     */
47
    private $automaticCollection;
48
49
    /**
50
     * @return string
51
     */
52
    public function getDefaultMessage()
53
    {
54
        return $this->defaultMessage;
55
    }
56
57
    /**
58
     * @param string $defaultMessage
59
     *
60
     * @return InvoiceDefaults
61
     */
62
    public function withDefaultMessage(string $defaultMessage)
63
    {
64
        $new = clone $this;
65
        $new->defaultMessage = $defaultMessage;
66
67
        return $new;
68
    }
69
70
    /**
71
     * @return int
72
     */
73
    public function getDefaultInterestRate()
74
    {
75
        return $this->defaultInterestRate;
76
    }
77
78
    /**
79
     * @param int $defaultInterestRate
80
     *
81
     * @return InvoiceDefaults
82
     */
83
    public function withDefaultInterestRate(int $defaultInterestRate)
84
    {
85
        $new = clone $this;
86
        $new->defaultInterestRate = $defaultInterestRate;
87
88
        return $new;
89
    }
90
91
    /**
92
     * @return int
93
     */
94
    public function getDefaultReminderFee()
95
    {
96
        return $this->defaultReminderFee;
97
    }
98
99
    /**
100
     * @param int $defaultReminderFee
101
     *
102
     * @return InvoiceDefaults
103
     */
104
    public function withDefaultReminderFee(int $defaultReminderFee)
105
    {
106
        $new = clone $this;
107
        $new->defaultReminderFee = $defaultReminderFee;
108
109
        return $new;
110
    }
111
112
    /**
113
     * @return int
114
     */
115
    public function getDefaultInvoiceFee()
116
    {
117
        return $this->defaultInvoiceFee;
118
    }
119
120
    /**
121
     * @param int $defaultInvoiceFee
122
     *
123
     * @return InvoiceDefaults
124
     */
125
    public function withDefaultInvoiceFee(int $defaultInvoiceFee)
126
    {
127
        $new = clone $this;
128
        $new->defaultInvoiceFee = $defaultInvoiceFee;
129
130
        return $new;
131
    }
132
133
    /**
134
     * @return AutomaticReminder
135
     */
136
    public function getAutomaticReminders()
137
    {
138
        return $this->automaticReminders;
139
    }
140
141
    /**
142
     * @param AutomaticReminder $automaticReminders
143
     *
144
     * @return InvoiceDefaults
145
     */
146
    public function withAutomaticReminders(AutomaticReminder $automaticReminders)
147
    {
148
        $new = clone $this;
149
        $new->automaticReminders = $automaticReminders;
150
151
        return $new;
152
    }
153
154
    /**
155
     * @return AutomaticReminderWriteOff
156
     */
157
    public function getAutomaticReminderWriteOff()
158
    {
159
        return $this->automaticWriteoff;
160
    }
161
162
    /**
163
     * @param AutomaticReminderWriteOff $automaticWriteoff
164
     *
165
     * @return InvoiceDefaults
166
     */
167
    public function withAutomaticWriteoff(AutomaticReminderWriteOff $automaticWriteoff)
168
    {
169
        $new = clone $this;
170
        $new->automaticWriteoff = $automaticWriteoff;
171
172
        return $new;
173
    }
174
175
    /**
176
     * @return AutomaticReminderCollection
177
     */
178
    public function getAutomaticReminderCollection()
179
    {
180
        return $this->automaticCollection;
181
    }
182
183
    /**
184
     * @param AutomaticReminderCollection $automaticCollection
185
     *
186
     * @return InvoiceDefaults
187
     */
188
    public function withAutomaticCollection(AutomaticReminderCollection $automaticCollection)
189
    {
190
        $new = clone $this;
191
        $new->automaticCollection = $automaticCollection;
192
193
        return $new;
194
    }
195
196
    /**
197
     * Create an API response object from the HTTP response from the API server.
198
     *
199
     * @param array $data
200
     *
201
     * @return self
202
     */
203 2
    public static function createFromArray(array $data)
204
    {
205 2
        $invoiceDefault = new self();
206 2
        $invoiceDefault->defaultMessage = $data['default_message'] ?? null;
207 2
        $invoiceDefault->defaultInterestRate = $data['default_interest_rate'] ?? null;
208 2
        $invoiceDefault->defaultReminderFee = $data['default_reminder_fee'] ?? null;
209 2
        $invoiceDefault->defaultInvoiceFee = $data['default_invoice_fee'] ?? null;
210 2
        $invoiceDefault->automaticReminders = AutomaticReminder::createFromArray($data['automatic_reminders']);
211 2
        $invoiceDefault->automaticWriteoff = AutomaticReminderWriteOff::createFromArray($data['automatic_writeoff']);
212 2
        $invoiceDefault->automaticCollection = AutomaticReminderCollection::createFromArray($data['automatic_collection']);
213
214 2
        return $invoiceDefault;
215
    }
216
217 1
    public function toArray()
218
    {
219 1
        $data = [];
220 1
        if ($this->defaultMessage !== null) {
221 1
            $data['default_message'] = $this->defaultMessage;
222
        }
223 1
        if ($this->defaultInterestRate !== null) {
224
            $data['default_interest_rate'] = $this->defaultInterestRate;
225
        }
226 1
        if ($this->defaultReminderFee !== null) {
227 1
            $data['default_reminder_fee'] = $this->defaultReminderFee;
228
        }
229 1
        if ($this->defaultInvoiceFee !== null) {
230 1
            $data['default_invoice_fee'] = $this->defaultInvoiceFee;
231
        }
232 1
        if ($this->automaticReminders !== null) {
233 1
            $data['automatic_reminders'] = $this->automaticReminders->toArray();
234
        }
235 1
        if ($this->automaticWriteoff !== null) {
236 1
            $data['automatic_reminders'] = $this->automaticWriteoff->toArray();
237
        }
238 1
        if ($this->automaticCollection !== null) {
239 1
            $data['automatic_reminders'] = $this->automaticCollection->toArray();
240
        }
241
242 1
        return $data;
243
    }
244
}
245