Completed
Pull Request — master (#7)
by
unknown
01:28
created

Donor::setAddress2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of byrokrat\giroapp.
4
 *
5
 * byrokrat\giroapp is free software: you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License as published
7
 * by the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * byrokrat\giroapp is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with byrokrat\giroapp. If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * Copyright 2016-17 Hannes Forsgård
19
 */
20
21
declare(strict_types = 1);
22
23
namespace byrokrat\giroapp\Model;
24
25
use byrokrat\giroapp\Model\DonorState\DonorState;
26
use byrokrat\amount\Amount;
27
use byrokrat\autogiro\Writer\Writer;
28
29
/**
30
 * Models an individual donor
31
 */
32
class Donor
33
{
34
    /**
35
     * Indicator that mandate exists printed on paper
36
     */
37
    const MANDATE_SOURCE_PAPER = 'MANDATE_SOURCE_PAPER';
38
39
    /**
40
     * Indicator that mandate is digital
41
     */
42
    const MANDATE_SOURCE_DIGITAL = 'MANDATE_SOURCE_DIGITAL';
43
44
    /**
45
     * @var DonorState
46
     */
47
    private $state;
48
49
    /**
50
     * @var string
51
     */
52
    private $mandateSource;
53
54
    /**
55
     * @var string
56
     */
57
    private $payerNumber;
58
59
    /**
60
     * @var \byrokrat\banking\AccountNumber
61
     */
62
    private $account;
63
64
    /**
65
     * @var \byrokrat\id\Id
66
     */
67
    private $id;
68
69
    /**
70
     * @var string
71
     */
72
    private $comment;
73
74
    /**
75
     * @var string
76
     */
77
    private $name;
78
79
    /**
80
     * @var string
81
     */
82
    private $coAddress;
83
84
    /**
85
     * @var string
86
     */
87
    private $address1;
88
89
    /**
90
     * @var string
91
     */
92
    private $address2;
93
94
    /**
95
     * @var string
96
     */
97
    private $postalCode;
98
99
    /**
100
     * @var string
101
     */
102
    private $postalCity;
103
104
    /**
105
     * TODO:
106
     * Contact information should be moved to a separate object, ContactPerson.
107
     * It should be clear in the end application that this contact information,
108
     * if added, should only be used to contact the donor on autogiro subjects.
109
     * This to conform with Data protection regulations.
110
     */
111
112
    /**
113
     * @var string
114
     */
115
    private $email;
116
117
    /**
118
     * @var string
119
     */
120
    private $phone;
121
122
    /**
123
     * @var \byrokrat\Amount\Currency
124
     */
125
    private $donationAmount;
126
127
    public function __construct(
128
        DonorState $state,
129
        string $mandateSource,
130
        string $payerNumber,
131
        \byrokrat\banking\AccountNumber $account,
132
        \byrokrat\id\Id $id,
133
        string $name,
134
        string $comment = "",
135
        string $coAddress = "",
136
        string $address1 = "",
137
        string $address2 = "",
138
        string $postalCode = "",
139
        string $postalCity = ""
140
    ) {
141
        $this->setState($state);
142
        $this->mandateSource = $mandateSource;
143
        $this->payerNumber = $payerNumber;
144
        $this->account = $account;
145
        $this->id = $id;
146
        $this->comment = $comment;
147
        $this->name = $name;
148
        $this->coAddress = $coAddress;
149
        $this->address1 = $address1;
150
        $this->address2 = $address2;
151
        $this->postalCode = $postalCode;
152
        $this->postalCity = $postalCity;
153
154
        $this->email = "";
155
        $this->phone = "";
156
        $this->donationAmount = new Amount('0');
157
    }
158
159
    public function getState(): DonorState
160
    {
161
        return $this->state;
162
    }
163
164
    public function setState(DonorState $state)
165
    {
166
        $this->state = $state;
167
    }
168
169
    public function getMandateSource(): string
170
    {
171
        return $this->mandateSource;
172
    }
173
174
    public function getPayerNumber(): string
175
    {
176
        return $this->payerNumber;
177
    }
178
179
    public function setPayerNumber(string $payerNumber)
180
    {
181
        $this->payerNumber = $payerNumber;
182
    }
183
184
    /*
185
     * Don't think $this is needed. Likely a new autogiro mantade will be issued
186
     * if the account is changed. However, it might be interesting in our
187
     * system to link mandates for the same person, but different accounts. But
188
     * that will probably not be done here.
189
    public function setAccount(\byrokrat\banking\AccountNumber $account)
190
    {
191
        $this->account = $account;
192
    }
193
     */
194
195
    public function getAccount(): \byrokrat\banking\AccountNumber
196
    {
197
        return $this->account;
198
    }
199
200
    public function getId(): \byrokrat\id\Id
201
    {
202
        return $this->id;
203
    }
204
205
    public function setComment(string $comment)
206
    {
207
        $this->comment = $comment;
208
    }
209
210
    public function getComment(): string
211
    {
212
        return $this->comment;
213
    }
214
215
    public function setName(string $name)
216
    {
217
        $this->name = $name;
218
    }
219
220
    public function getName(): string
221
    {
222
        return $this->name;
223
    }
224
225
    public function setCoAddress(string $coAddress)
226
    {
227
        $this->coAddress = $coAddress;
228
    }
229
230
    public function getCoAddress(): string
231
    {
232
        return $this->coAddress;
233
    }
234
235
    public function setAddress1(string $address1)
236
    {
237
        $this->address1 = $address1;
238
    }
239
240
    public function getAddress1(): string
241
    {
242
        return $this->address1;
243
    }
244
245
    public function setAddress2(string $address2)
246
    {
247
        $this->address2 = $address2;
248
    }
249
250
    public function getAddress2(): string
251
    {
252
        return $this->address2;
253
    }
254
255
    public function setPostalCode(string $postalCode)
256
    {
257
        $this->postalCode = $postalCode;
258
    }
259
260
    public function getPostalCode(): string
261
    {
262
        return $this->postalCode;
263
    }
264
265
    public function setPostalCity(string $postalCity)
266
    {
267
        $this->postalCity = $postalCity;
268
    }
269
270
    public function getPostalCity(): string
271
    {
272
        return $this->postalCity;
273
    }
274
275
    public function getEmail(): string
276
    {
277
        return $this->email;
278
    }
279
280
    public function setEmail(string $email)
281
    {
282
        $this->email = $email;
283
    }
284
285
    public function getPhone(): string
286
    {
287
        return $this->phone;
288
    }
289
290
    public function setPhone(string $phone)
291
    {
292
        $this->phone = $phone;
293
    }
294
295
    public function getDonationAmount(): \byrokrat\Amount\Currency
296
    {
297
        return $this->getDonationAmount;
0 ignored issues
show
Bug introduced by
The property getDonationAmount does not seem to exist. Did you mean donationAmount?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
298
    }
299
300
    public function setDonationAmount(\byrokrat\Amount\Currency $donationAmount)
301
    {
302
        $this->donationAmount = $donationAmount;
303
    }
304
305
    public function exportToAutogiro(Writer $writer)
306
    {
307
        $this->getState()->export($this, $writer);
308
    }
309
}
310