MembershipApplication   F
last analyzed

Complexity

Total Complexity 91

Size/Duplication

Total Lines 1071
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 22.12%

Importance

Changes 0
Metric Value
wmc 91
lcom 3
cbo 1
dl 0
loc 1071
ccs 50
cts 226
cp 0.2212
rs 1.316
c 0
b 0
f 0

81 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A setId() 0 3 1
A setDonationId() 0 5 1
A getDonationId() 0 3 1
A setCreationTime() 0 5 1
A getCreationTime() 0 3 1
A setApplicantSalutation() 0 5 1
A getApplicantSalutation() 0 3 1
A setCompany() 0 5 1
A getCompany() 0 3 1
A setApplicantTitle() 0 5 1
A getApplicantTitle() 0 3 1
A setProbablyUnusedNameField() 0 5 1
A getProbablyUnusedNameField() 0 3 1
A setApplicantFirstName() 0 6 1
A getApplicantFirstName() 0 3 1
A setApplicantLastName() 0 6 1
A getApplicantLastName() 0 3 1
A setNameFromParts() 0 8 1
A setAddress() 0 5 1
A getAddress() 0 3 1
A setPostcode() 0 5 1
A getPostcode() 0 3 1
A setCity() 0 5 1
A getCity() 0 3 1
A setApplicantEmailAddress() 0 5 1
A getApplicantEmailAddress() 0 3 1
A setApplicantPhoneNumber() 0 5 1
A getApplicantPhoneNumber() 0 3 1
A setApplicantDateOfBirth() 0 5 1
A getApplicantDateOfBirth() 0 3 1
A setWikimediumShipping() 0 5 1
A getWikimediumShipping() 0 3 1
A setMembershipType() 0 5 1
A getMembershipType() 0 3 1
A setPaymentType() 0 5 1
A getPaymentType() 0 3 1
A setPaymentAmount() 0 5 1
A getPaymentAmount() 0 3 1
A setPaymentIntervalInMonths() 0 5 1
A getPaymentIntervalInMonths() 0 3 1
A setPaymentBankAccount() 0 5 1
A getPaymentBankAccount() 0 3 1
A setPaymentBankName() 0 5 1
A getPaymentBankName() 0 3 1
A setPaymentBankCode() 0 5 1
A getPaymentBankCode() 0 3 1
A setPaymentIban() 0 5 1
A getPaymentIban() 0 3 1
A setPaymentBic() 0 5 1
A getPaymentBic() 0 3 1
A setPaymentBankAccountHolder() 0 5 1
A getPaymentBankAccountHolder() 0 3 1
A setComment() 0 5 1
A getComment() 0 3 1
A setExport() 0 5 1
A getExport() 0 3 1
A setBackup() 0 5 1
A getBackup() 0 3 1
A setWikilogin() 0 5 1
A getWikilogin() 0 3 1
A setTracking() 0 5 1
A getTracking() 0 3 1
A setStatus() 0 5 1
A getStatus() 0 3 1
A setCountry() 0 5 1
A getCountry() 0 3 1
A setData() 0 5 1
A getData() 0 3 1
A isUnconfirmed() 0 3 1
A needsModeration() 0 3 2
A isCancelled() 0 3 2
A isDeleted() 0 3 2
A log() 0 7 1
A getDecodedData() 0 9 3
A encodeAndSetData() 0 3 1
A getDataObject() 0 11 4
A setDataObject() 0 18 3
A modifyDataObject() 0 5 1
A setDonationReceipt() 0 5 1
A getDonationReceipt() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like MembershipApplication often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use MembershipApplication, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Entities;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use WMDE\Fundraising\Store\MembershipApplicationData;
10
11
/**
12
 * @since 2.0
13
 *
14
 * @ORM\Table(
15
 *     name="request",
16
 *     indexes={
17
 *			@ORM\Index(name="m_email", columns={"email"}, flags={"fulltext"}),
18
 *          @ORM\Index(name="m_name", columns={"name"}, flags={"fulltext"}),
19
 *     		@ORM\Index(name="m_ort", columns={"ort"}, flags={"fulltext"})
20
 *     }
21
 *	 )
22
 * @ORM\Entity
23
 */
24
class MembershipApplication {
25
26
	public const STATUS_CONFIRMED = 1;
27
	public const STATUS_NEUTRAL = 0;
28
	public const STATUS_DELETED = -1;
29
	public const STATUS_MODERATION = -2;
30
	public const STATUS_ABORTED = -4;
31
	public const STATUS_CANCELED = -8;
32
33
	/**
34
	 * @var integer
35
	 *
36
	 * @ORM\Column(name="id", type="integer")
37
	 * @ORM\Id
38
	 * @ORM\GeneratedValue(strategy="IDENTITY")
39
	 */
40
	private $id;
41
42
	/**
43
	 * FIXME: this should not be nullable
44
	 *
45
	 * @var integer
46
	 *
47
	 * @ORM\Column(name="status", type="smallint", options={"default":0}, nullable=true)
48
	 */
49
	private $status = 0;
50
51
	/**
52
	 * This is no longer written by the fundraising frontend.
53
	 *
54
	 * Until we remove all references to this field in the backend, the field is not removed but just marked as deprecated.
55
	 *
56
	 * @deprecated
57
	 * @var integer|null
58
	 *
59
	 * @ORM\Column(name="donation_id", type="integer", nullable=true)
60
	 */
61
	private $donationId;
62
63
	/**
64
	 * @var \DateTime
65
	 *
66
	 * @Gedmo\Timestampable(on="create")
67
	 * @ORM\Column(name="timestamp", type="datetime")
68
	 */
69
	private $creationTime;
70
71
	/**
72
	 * @var string|null
73
	 *
74
	 * @ORM\Column(name="anrede", type="string", length=16, nullable=true)
75
	 */
76
	private $applicantSalutation;
77
78
	/**
79
	 * @var string|null
80
	 *
81
	 * @ORM\Column(name="firma", type="string", length=100, nullable=true)
82
	 */
83
	private $company;
84
85
	/**
86
	 * @var string|null
87
	 *
88
	 * @ORM\Column(name="titel", type="string", length=16, nullable=true)
89
	 */
90
	private $applicantTitle;
91
92
	/**
93
	 * @var string
94
	 *
95
	 * @ORM\Column(name="name", type="string", length=250, options={"default":""}, nullable=false)
96
	 */
97
	private $probablyUnusedNameField = '';
98
99
	/**
100
	 * @var string
101
	 *
102
	 * @ORM\Column(name="vorname", type="string", length=50, options={"default":""}, nullable=false)
103
	 */
104
	private $applicantFirstName = '';
105
106
	/**
107
	 * @var string
108
	 *
109
	 * @ORM\Column(name="nachname", type="string", length=50, options={"default":""}, nullable=false)
110
	 */
111
	private $applicantLastName = '';
112
113
	/**
114
	 * @var string|null
115
	 *
116
	 * @ORM\Column(name="strasse", type="string", length=100, nullable=true)
117
	 */
118
	private $address;
119
120
	/**
121
	 * @var string|null
122
	 *
123
	 * @ORM\Column(name="plz", type="string", length=8, nullable=true)
124
	 */
125
	private $postcode;
126
127
	/**
128
	 * @var string|null
129
	 *
130
	 * @ORM\Column(name="ort", type="string", length=100, nullable=true)
131
	 */
132
	private $city;
133
134
	/**
135
	 * @var string|null
136
	 *
137
	 * @ORM\Column(name="country", type="string", length=8, options={"default":""}, nullable=true)
138
	 */
139
	private $country = '';
140
141
	/**
142
	 * @var string
143
	 *
144
	 * @ORM\Column(name="email", type="string", length=250, options={"default":""}, nullable=false)
145
	 */
146
	private $applicantEmailAddress = '';
147
148
	/**
149
	 * @var string
150
	 *
151
	 * @ORM\Column(name="phone", type="string", length=30, options={"default":""}, nullable=false)
152
	 */
153
	private $applicantPhoneNumber = '';
154
155
	/**
156
	 * Date of birth
157
	 *
158
	 * @var \DateTime|null
159
	 *
160
	 * @ORM\Column(name="dob", type="date", nullable=true)
161
	 */
162
	private $applicantDateOfBirth;
163
164
	/**
165
	 * @var string
166
	 *
167
	 * @ORM\Column(name="wikimedium_shipping", type="string", options={"default":""}, nullable=false)
168
	 */
169
	private $wikimediumShipping = 'none';
170
171
	/**
172
	 * @var string
173
	 *
174
	 * @ORM\Column(name="membership_type", type="string", options={"default":"sustaining"}, nullable=false)
175
	 */
176
	private $membershipType = 'sustaining';
177
178
	/**
179
	 * @var string
180
	 *
181
	 * @ORM\Column(name="payment_type", type="string", options={"default":"BEZ"}, nullable=false)
182
	 */
183
	private $paymentType = 'BEZ';
184
185
	/**
186
	 * @var integer
187
	 *
188
	 * @ORM\Column(name="membership_fee", type="integer", options={"default":0}, nullable=false)
189
	 */
190
	private $paymentAmountInEuro = 0;
191
192
	/**
193
	 * FIXME: this should not be nullable
194
	 *
195
	 * @var integer
196
	 *
197
	 * @ORM\Column(name="membership_fee_interval", type="smallint", options={"default":12}, nullable=true)
198
	 */
199
	private $paymentIntervalInMonths = 12;
200
201
	/**
202
	 * @var string
203
	 *
204
	 * @ORM\Column(name="account_number", type="string", length=16, options={"default":""}, nullable=false)
205
	 */
206
	private $paymentBankAccount = '';
207
208
	/**
209
	 * @var string
210
	 *
211
	 * @ORM\Column(name="bank_name", type="string", length=100, options={"default":""}, nullable=false)
212
	 */
213
	private $paymentBankName = '';
214
215
	/**
216
	 * @var string
217
	 *
218
	 * @ORM\Column(name="bank_code", type="string", length=16, options={"default":""}, nullable=false)
219
	 */
220
	private $paymentBankCode = '';
221
222
	/**
223
	 * @var string|null
224
	 *
225
	 * @ORM\Column(name="iban", type="string", length=32, options={"default":""}, nullable=true)
226
	 */
227
	private $paymentIban = '';
228
229
	/**
230
	 * @var string|null
231
	 *
232
	 * @ORM\Column(name="bic", type="string", length=32, options={"default":""}, nullable=true)
233
	 */
234
	private $paymentBic = '';
235
236
	/**
237
	 * @var string
238
	 *
239
	 * @ORM\Column(name="account_holder", type="string", length=50, options={"default":""}, nullable=false)
240
	 */
241
	private $paymentBankAccountHolder = '';
242
243
	/**
244
	 * @var string
245
	 *
246
	 * @ORM\Column(name="comment", type="text", options={"default":""}, nullable=false)
247
	 */
248
	private $comment = '';
249
250
	/**
251
	 * @var \DateTime|null
252
	 *
253
	 * @ORM\Column(name="export", type="datetime", nullable=true)
254
	 */
255
	private $export;
256
257
	/**
258
	 * @var \DateTime|null
259
	 *
260
	 * @ORM\Column(name="backup", type="datetime", nullable=true)
261
	 */
262
	private $backup;
263
264
	/**
265
	 * @var boolean
266
	 *
267
	 * @ORM\Column(name="wikilogin", type="boolean", options={"default":0}, nullable=false)
268
	 */
269
	private $wikilogin = 0;
270
271
	/**
272
	 * @var string|null
273
	 *
274
	 * @ORM\Column(name="tracking", type="string", length=50, nullable=true)
275
	 */
276
	private $tracking;
277
278
	/**
279
	 * @var string|null
280
	 *
281
	 * @ORM\Column(name="data", type="text", nullable=true)
282
	 */
283
	private $data;
284
285
	/**
286
	 * @var boolean|null
287
	 *
288
	 * @ORM\Column(name="donation_receipt", type="boolean", nullable=true)
289
	 */
290
	private $donationReceipt;
291
292
	/**
293
	 * @return integer
294
	 */
295 3
	public function getId() {
296 3
		return $this->id;
297
	}
298
299
	/**
300
	 * @since 2.0
301
	 *
302
	 * @param integer|null $id
303
	 */
304 2
	public function setId( $id ) {
305 2
		$this->id = $id;
306 2
	}
307
308
	/**
309
	 * @param integer|null $donationId
310
	 *
311
	 * @return self
312
	 */
313
	public function setDonationId( $donationId ) {
314
		$this->donationId = $donationId;
0 ignored issues
show
Deprecated Code introduced by
The property WMDE\Fundraising\Entitie...pplication::$donationId has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
315
316
		return $this;
317
	}
318
319
	/**
320
	 * Returns the id of the donation that led to the membership application,
321
	 * or null when the application is not linked to any donation.
322
	 *
323
	 * @return integer|null
324
	 */
325
	public function getDonationId() {
326
		return $this->donationId;
0 ignored issues
show
Deprecated Code introduced by
The property WMDE\Fundraising\Entitie...pplication::$donationId has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
327
	}
328
329
	/**
330
	 * @param \DateTime|null $creationTime
331
	 *
332
	 * @return self
333
	 */
334
	public function setCreationTime( $creationTime ) {
335
		$this->creationTime = $creationTime;
336
337
		return $this;
338
	}
339
340
	/**
341
	 * @return \DateTime|null
342
	 */
343
	public function getCreationTime() {
344
		return $this->creationTime;
345
	}
346
347
	/**
348
	 * @param string|null $applicantSalutation
349
	 *
350
	 * @return self
351
	 */
352
	public function setApplicantSalutation( $applicantSalutation ) {
353
		$this->applicantSalutation = $applicantSalutation;
354
355
		return $this;
356
	}
357
358
	/**
359
	 * @return string|null
360
	 */
361
	public function getApplicantSalutation() {
362
		return $this->applicantSalutation;
363
	}
364
365
	/**
366
	 * @param string|null $company
367
	 *
368
	 * @return self
369
	 */
370
	public function setCompany( $company ) {
371
		$this->company = $company;
372
373
		return $this;
374
	}
375
376
	/**
377
	 * @return string|null
378
	 */
379
	public function getCompany() {
380
		return $this->company;
381
	}
382
383
	/**
384
	 * @param string $applicantTitle
385
	 *
386
	 * @return self
387
	 */
388
	public function setApplicantTitle( $applicantTitle ) {
389
		$this->applicantTitle = $applicantTitle;
390
391
		return $this;
392
	}
393
394
	/**
395
	 * @return string
396
	 */
397
	public function getApplicantTitle() {
398
		return $this->applicantTitle;
399
	}
400
401
	/**
402
	 * @param string $probablyUnusedNameField
403
	 *
404
	 * @return self
405
	 */
406
	public function setProbablyUnusedNameField( $probablyUnusedNameField ) {
407
		$this->probablyUnusedNameField = $probablyUnusedNameField;
408
409
		return $this;
410
	}
411
412
	/**
413
	 * @return string
414
	 */
415
	public function getProbablyUnusedNameField() {
416
		return $this->probablyUnusedNameField;
417
	}
418
419
	/**
420
	 * @param string $applicantFirstName
421
	 *
422
	 * @return self
423
	 */
424
	public function setApplicantFirstName( $applicantFirstName ) {
425
		$this->applicantFirstName = $applicantFirstName;
426
		$this->setNameFromParts( $applicantFirstName, $this->getApplicantLastName() );
427
428
		return $this;
429
	}
430
431
	/**
432
	 * @return string
433
	 */
434
	public function getApplicantFirstName() {
435
		return $this->applicantFirstName;
436
	}
437
438
	/**
439
	 * @param string $applicantLastName
440
	 *
441
	 * @return self
442
	 */
443
	public function setApplicantLastName( $applicantLastName ) {
444
		$this->applicantLastName = $applicantLastName;
445
		$this->setNameFromParts( $this->getApplicantFirstName(), $applicantLastName );
446
447
		return $this;
448
	}
449
450
	/**
451
	 * @return string
452
	 */
453
	public function getApplicantLastName() {
454
		return $this->applicantLastName;
455
	}
456
457
	/**
458
	 * Sets the full name
459
	 *
460
	 * @param string|null $firstName
461
	 * @param string|null $lastName
462
	 *
463
	 * @return self
464
	 */
465
	private function setNameFromParts( $firstName, $lastName ) {
466
		$this->setProbablyUnusedNameField( implode(
467
			' ',
468
			array_filter( [ $firstName, $lastName ] )
469
		) );
470
471
		return $this;
472
	}
473
474
	/**
475
	 * Set address (street, etc)
476
	 *
477
	 * @param string|null $address
478
	 *
479
	 * @return self
480
	 */
481
	public function setAddress( $address ) {
482
		$this->address = $address;
483
484
		return $this;
485
	}
486
487
	/**
488
	 * Get address (street, etc)
489
	 *
490
	 * @return string|null
491
	 */
492
	public function getAddress() {
493
		return $this->address;
494
	}
495
496
	/**
497
	 * @param string|null $postcode
498
	 *
499
	 * @return self
500
	 */
501
	public function setPostcode( $postcode ) {
502
		$this->postcode = $postcode;
503
504
		return $this;
505
	}
506
507
	/**
508
	 * @return string|null
509
	 */
510
	public function getPostcode() {
511
		return $this->postcode;
512
	}
513
514
	/**
515
	 * @param string|null $city
516
	 *
517
	 * @return self
518
	 */
519
	public function setCity( $city ) {
520
		$this->city = $city;
521
522
		return $this;
523
	}
524
525
	/**
526
	 * @return string|null
527
	 */
528
	public function getCity() {
529
		return $this->city;
530
	}
531
532
	/**
533
	 * Set email
534
	 *
535
	 * @param string $applicantEmailAddress
536
	 *
537
	 * @return self
538
	 */
539
	public function setApplicantEmailAddress( $applicantEmailAddress ) {
540
		$this->applicantEmailAddress = $applicantEmailAddress;
541
542
		return $this;
543
	}
544
545
	/**
546
	 * Get email
547
	 *
548
	 * @return string
549
	 */
550
	public function getApplicantEmailAddress() {
551
		return $this->applicantEmailAddress;
552
	}
553
554
	/**
555
	 * Set phone
556
	 *
557
	 * @param string $applicantPhoneNumber
558
	 *
559
	 * @return self
560
	 */
561
	public function setApplicantPhoneNumber( $applicantPhoneNumber ) {
562
		$this->applicantPhoneNumber = $applicantPhoneNumber;
563
564
		return $this;
565
	}
566
567
	/**
568
	 * Get phone
569
	 *
570
	 * @return string
571
	 */
572
	public function getApplicantPhoneNumber() {
573
		return $this->applicantPhoneNumber;
574
	}
575
576
	/**
577
	 * @param \DateTime|null $dateOfBirth
578
	 *
579
	 * @return self
580
	 */
581
	public function setApplicantDateOfBirth( $dateOfBirth ) {
582
		$this->applicantDateOfBirth = $dateOfBirth;
583
584
		return $this;
585
	}
586
587
	/**
588
	 * @return \DateTime|null
589
	 */
590
	public function getApplicantDateOfBirth() {
591
		return $this->applicantDateOfBirth;
592
	}
593
594
	/**
595
	 * @param string $wikimediumShipping
596
	 *
597
	 * @return self
598
	 */
599
	public function setWikimediumShipping( $wikimediumShipping ) {
600
		$this->wikimediumShipping = $wikimediumShipping;
601
602
		return $this;
603
	}
604
605
	/**
606
	 * @return string
607
	 */
608
	public function getWikimediumShipping() {
609
		return $this->wikimediumShipping;
610
	}
611
612
	/**
613
	 * @param string $membershipType
614
	 *
615
	 * @return self
616
	 */
617
	public function setMembershipType( $membershipType ) {
618
		$this->membershipType = $membershipType;
619
620
		return $this;
621
	}
622
623
	/**
624
	 * @return string
625
	 */
626
	public function getMembershipType() {
627
		return $this->membershipType;
628
	}
629
630
	/**
631
	 * @since 2.1
632
	 *
633
	 * @param string $paymentType
634
	 *
635
	 * @return self
636
	 */
637
	public function setPaymentType( $paymentType ) {
638
		$this->paymentType = $paymentType;
639
640
		return $this;
641
	}
642
643
	/**
644
	 * @since 2.1
645
	 *
646
	 * @return string
647
	 */
648
	public function getPaymentType() {
649
		return $this->paymentType;
650
	}
651
652
	/**
653
	 * @param integer $paymentAmountInEuro
654
	 *
655
	 * @return self
656
	 */
657
	public function setPaymentAmount( $paymentAmountInEuro ) {
658
		$this->paymentAmountInEuro = $paymentAmountInEuro;
659
660
		return $this;
661
	}
662
663
	/**
664
	 * @return integer
665
	 */
666
	public function getPaymentAmount() {
667
		return $this->paymentAmountInEuro;
668
	}
669
670
	/**
671
	 * @param integer $paymentIntervalInMonths
672
	 *
673
	 * @return self
674
	 */
675
	public function setPaymentIntervalInMonths($paymentIntervalInMonths) {
676
		$this->paymentIntervalInMonths = $paymentIntervalInMonths;
677
678
		return $this;
679
	}
680
681
	/**
682
	 * @return integer
683
	 */
684
	public function getPaymentIntervalInMonths() {
685
		return $this->paymentIntervalInMonths;
686
	}
687
688
689
	/**
690
	 * @param string $paymentBankAccount
691
	 *
692
	 * @return self
693
	 */
694
	public function setPaymentBankAccount( $paymentBankAccount ) {
695
		$this->paymentBankAccount = $paymentBankAccount;
696
697
		return $this;
698
	}
699
700
	/**
701
	 * @return string
702
	 */
703
	public function getPaymentBankAccount() {
704
		return $this->paymentBankAccount;
705
	}
706
707
	/**
708
	 * @param string $paymentBankName
709
	 *
710
	 * @return self
711
	 */
712
	public function setPaymentBankName( $paymentBankName ) {
713
		$this->paymentBankName = $paymentBankName;
714
715
		return $this;
716
	}
717
718
	/**
719
	 * @return string
720
	 */
721
	public function getPaymentBankName() {
722
		return $this->paymentBankName;
723
	}
724
725
	/**
726
	 * @param string $paymentBankCode
727
	 *
728
	 * @return self
729
	 */
730
	public function setPaymentBankCode( $paymentBankCode ) {
731
		$this->paymentBankCode = $paymentBankCode;
732
733
		return $this;
734
	}
735
736
	/**
737
	 * @return string
738
	 */
739
	public function getPaymentBankCode() {
740
		return $this->paymentBankCode;
741
	}
742
743
	/**
744
	 * @param string|null $paymentIban
745
	 *
746
	 * @return self
747
	 */
748
	public function setPaymentIban( $paymentIban ) {
749
		$this->paymentIban = $paymentIban;
750
751
		return $this;
752
	}
753
754
	/**
755
	 * @return string|null
756
	 */
757
	public function getPaymentIban() {
758
		return $this->paymentIban;
759
	}
760
761
	/**
762
	 * @param string|null $paymentBic
763
	 *
764
	 * @return self
765
	 */
766
	public function setPaymentBic( $paymentBic ) {
767
		$this->paymentBic = $paymentBic;
768
769
		return $this;
770
	}
771
772
	/**
773
	 * @return string|null
774
	 */
775
	public function getPaymentBic() {
776
		return $this->paymentBic;
777
	}
778
779
	/**
780
	 * @param string $paymentBankAccountHolder
781
	 *
782
	 * @return self
783
	 */
784
	public function setPaymentBankAccountHolder( $paymentBankAccountHolder ) {
785
		$this->paymentBankAccountHolder = $paymentBankAccountHolder;
786
787
		return $this;
788
	}
789
790
	/**
791
	 * @return string
792
	 */
793
	public function getPaymentBankAccountHolder() {
794
		return $this->paymentBankAccountHolder;
795
	}
796
797
	/**
798
	 * @param string $comment
799
	 *
800
	 * @return self
801
	 */
802
	public function setComment( $comment ) {
803
		$this->comment = $comment;
804
805
		return $this;
806
	}
807
808
	/**
809
	 * @return string
810
	 */
811
	public function getComment() {
812
		return $this->comment;
813
	}
814
815
	/**
816
	 * Sets the time of export.
817
	 *
818
	 * @param \DateTime|null $export
819
	 *
820
	 * @return self
821
	 */
822
	public function setExport( $export ) {
823
		$this->export = $export;
824
825
		return $this;
826
	}
827
828
	/**
829
	 * Returns the time of export.
830
	 *
831
	 * @return \DateTime|null
832
	 */
833
	public function getExport() {
834
		return $this->export;
835
	}
836
837
	/**
838
	 * Sets the time of backup.
839
	 *
840
	 * @param \DateTime|null $backup
841
	 *
842
	 * @return self
843
	 */
844
	public function setBackup( $backup ) {
845
		$this->backup = $backup;
846
847
		return $this;
848
	}
849
850
	/**
851
	 * Returns the time of backup.
852
	 *
853
	 * @return \DateTime|null
854
	 */
855
	public function getBackup() {
856
		return $this->backup;
857
	}
858
859
	/**
860
	 * @param boolean $wikilogin
861
	 *
862
	 * @return self
863
	 */
864
	public function setWikilogin( $wikilogin ) {
865
		$this->wikilogin = $wikilogin;
866
867
		return $this;
868
	}
869
870
	/**
871
	 * @return boolean
872
	 */
873
	public function getWikilogin() {
874
		return $this->wikilogin;
875
	}
876
877
	/**
878
	 * @param string|null $tracking
879
	 *
880
	 * @return self
881
	 */
882
	public function setTracking( $tracking ) {
883
		$this->tracking = $tracking;
884
885
		return $this;
886
	}
887
888
	/**
889
	 * @return string|null
890
	 */
891
	public function getTracking() {
892
		return $this->tracking;
893
	}
894
895
	/**
896
	 * Sets the status of the membership request.
897
	 * The allowed values are the STATUS_ constants in this class.
898
	 *
899
	 * @param integer $status
900
	 *
901
	 * @return self
902
	 */
903 6
	public function setStatus( $status ) {
904 6
		$this->status = $status;
905
906 6
		return $this;
907
	}
908
909
	/**
910
	 * Returns the status of the membership request.
911
	 * The possible values are the STATUS_ constants in this class.
912
	 *
913
	 * @return integer
914
	 */
915
	public function getStatus() {
916
		return $this->status;
917
	}
918
919
	/**
920
	 * @param string|null $country
921
	 *
922
	 * @return self
923
	 */
924
	public function setCountry( $country ) {
925
		$this->country = $country;
926
927
		return $this;
928
	}
929
930
	/**
931
	 * @return string|null
932
	 */
933
	public function getCountry() {
934
		return $this->country;
935
	}
936
937
	/**
938
	 * @param string|null $data
939
	 * @return self
940
	 */
941
	public function setData( $data ) {
942
		$this->data = $data;
943
944
		return $this;
945
	}
946
947
	/**
948
	 * @return string|null
949
	 */
950
	public function getData() {
951
		return $this->data;
952
	}
953
954
	/**
955
	 * @return bool
956
	 */
957
	public function isUnconfirmed() {
958
		return $this->status === self::STATUS_NEUTRAL;
959
	}
960
961
	/**
962
	 * @return bool
963
	 */
964 3
	public function needsModeration() {
965 3
		return $this->status < 0 && abs( $this->status ) & abs( self::STATUS_MODERATION );
966
	}
967
968
	/**
969
	 * @return bool
970
	 */
971 4
	public function isCancelled() {
972 4
		return $this->status < 0 && abs( $this->status ) & abs( self::STATUS_CANCELED );
973
	}
974
975
	/**
976
	 * @since 4.2
977
	 * @return bool
978
	 */
979 2
	public function isDeleted() {
980 2
		return $this->status < 0 && abs( $this->status ) & abs( self::STATUS_DELETED );
981
	}
982
983
	public function log( $message ) {
984
		$dataArray = $this->getDecodedData();
985
		$dataArray['log'][date( 'Y-m-d H:i:s' )] = $message;
986
		$this->encodeAndSetData( $dataArray );
987
988
		return $this;
989
	}
990
991
	/**
992
	 * NOTE: if possible, use @see getDataObject instead, as it provides a nicer API.
993
	 *
994
	 * @since 2.0
995
	 * @return array
996
	 */
997 5
	public function getDecodedData() {
998 5
		if ( $this->data === null ) {
999 3
			return [];
1000
		}
1001
1002 4
		$data = unserialize( base64_decode( $this->data ) );
1003
1004 4
		return is_array( $data ) ? $data : [];
1005
	}
1006
1007
	/**
1008
	 * NOTE: if possible, use @see modifyDataObject instead, as it provides a nicer API.
1009
	 *
1010
	 * @since 2.0
1011
	 * @param array $dataArray
1012
	 */
1013 4
	public function encodeAndSetData( array $dataArray ) {
1014 4
		$this->data = base64_encode( serialize( $dataArray ) );
1015 4
	}
1016
1017
	/**
1018
	 * WARNING: updates made to the return value will not be reflected in the Donation state.
1019
	 * Similarly, updates to the Donation state will not propagate to the returned object.
1020
	 * To update the Donation state, explicitly call @see setDataObject.
1021
	 *
1022
	 * @since 2.0
1023
	 * @return MembershipApplicationData
1024
	 */
1025 2
	public function getDataObject() {
1026 2
		$dataArray = $this->getDecodedData();
1027
1028 2
		$data = new MembershipApplicationData();
1029
1030 2
		$data->setAccessToken( array_key_exists( 'token', $dataArray ) ? $dataArray['token'] : null );
1031 2
		$data->setUpdateToken( array_key_exists( 'utoken', $dataArray ) ? $dataArray['utoken'] : null );
1032 2
		$data->setPreservedStatus( array_key_exists( 'old_status', $dataArray ) ? $dataArray['old_status'] : null );
1033
1034 2
		return $data;
1035
	}
1036
1037
	/**
1038
	 * @since 2.0
1039
	 * @param MembershipApplicationData $data
1040
	 */
1041 4
	public function setDataObject( MembershipApplicationData $data ) {
1042 4
		$dataArray = array_merge(
1043 4
			$this->getDecodedData(),
1044
			[
1045 4
				'token' => $data->getAccessToken(),
1046 4
				'utoken' => $data->getUpdateToken(),
1047 4
				'old_status' => $data->getPreservedStatus(),
1048
			]
1049
		);
1050
1051 4
		foreach ( [ 'token', 'utoken', 'old_status' ] as $keyName ) {
1052 4
			if ( is_null( $dataArray[$keyName] ) ) {
1053 3
				unset( $dataArray[$keyName] );
1054
			}
1055
		}
1056
1057 4
		$this->encodeAndSetData( $dataArray );
1058 4
	}
1059
1060
	/**
1061
	 * @since 2.0
1062
	 * @param callable $modificationFunction Takes a modifiable MembershipApplicationData parameter
1063
	 */
1064 1
	public function modifyDataObject( callable $modificationFunction ) {
1065 1
		$dataObject = $this->getDataObject();
1066 1
		$modificationFunction( $dataObject );
1067 1
		$this->setDataObject( $dataObject );
1068 1
	}
1069
1070
	/**
1071
	 * Set donation receipt state
1072
	 *
1073
	 * @since 7.0
1074
	 *
1075
	 * @param boolean|null $donationReceipt
1076
	 * @return self
1077
	 */
1078 1
	public function setDonationReceipt( ?bool $donationReceipt ): self {
1079 1
		$this->donationReceipt = $donationReceipt;
1080
1081 1
		return $this;
1082
	}
1083
1084
	/**
1085
	 * Get donation receipt state
1086
	 *
1087
	 * @since 7.0
1088
	 *
1089
	 * @return boolean|null
1090
	 */
1091 2
	public function getDonationReceipt(): ?bool {
1092 2
		return $this->donationReceipt;
1093
	}
1094
}
1095