Completed
Push — master ( c0df86...3cffd5 )
by
unknown
26s
created

MembershipApplication   D

Complexity

Total Complexity 87

Size/Duplication

Total Lines 1027
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 19.63%

Importance

Changes 0
Metric Value
wmc 87
lcom 3
cbo 1
dl 0
loc 1027
ccs 43
cts 219
cp 0.1963
rs 4.4346
c 0
b 0
f 0

78 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A needsModeration() 0 3 2
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 isUnconfirmed() 0 3 1
A isCancelled() 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

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(name="request", indexes={@ORM\Index(name="idx_donation_id", columns={"donation_id"})})
15
 * @ORM\Entity
16
 */
17
class MembershipApplication {
18
19
	const STATUS_CONFIRMED = 1;
20
	const STATUS_NEUTRAL = 0;
21
	const STATUS_DELETED = -1;
22
	const STATUS_MODERATION = -2;
23
	const STATUS_ABORTED = -4;
24
	const STATUS_CANCELED = -8;
25
26
	/**
27
	 * @var integer
28
	 *
29
	 * @ORM\Column(name="id", type="integer")
30
	 * @ORM\Id
31
	 * @ORM\GeneratedValue(strategy="IDENTITY")
32
	 */
33
	private $id;
34
35
	/**
36
	 * FIXME: this should not be nullable
37
	 *
38
	 * @var integer
39
	 *
40
	 * @ORM\Column(name="status", type="smallint", options={"default":0}, nullable=true)
41
	 */
42
	private $status = 0;
43
44
	/**
45
	 * @var integer|null
46
	 *
47
	 * @ORM\Column(name="donation_id", type="integer", nullable=true)
48
	 */
49
	private $donationId;
50
51
	/**
52
	 * @var \DateTime
53
	 *
54
	 * @Gedmo\Timestampable(on="create")
55
	 * @ORM\Column(name="timestamp", type="datetime")
56
	 */
57
	private $creationTime;
58
59
	/**
60
	 * @var string|null
61
	 *
62
	 * @ORM\Column(name="anrede", type="string", length=16, nullable=true)
63
	 */
64
	private $applicantSalutation;
65
66
	/**
67
	 * @var string|null
68
	 *
69
	 * @ORM\Column(name="firma", type="string", length=100, nullable=true)
70
	 */
71
	private $company;
72
73
	/**
74
	 * @var string|null
75
	 *
76
	 * @ORM\Column(name="titel", type="string", length=16, nullable=true)
77
	 */
78
	private $applicantTitle;
79
80
	/**
81
	 * @var string
82
	 *
83
	 * @ORM\Column(name="name", type="string", length=250, options={"default":""}, nullable=false)
84
	 */
85
	private $probablyUnusedNameField = '';
86
87
	/**
88
	 * @var string
89
	 *
90
	 * @ORM\Column(name="vorname", type="string", length=50, options={"default":""}, nullable=false)
91
	 */
92
	private $applicantFirstName = '';
93
94
	/**
95
	 * @var string
96
	 *
97
	 * @ORM\Column(name="nachname", type="string", length=50, options={"default":""}, nullable=false)
98
	 */
99
	private $applicantLastName = '';
100
101
	/**
102
	 * @var string|null
103
	 *
104
	 * @ORM\Column(name="strasse", type="string", length=100, nullable=true)
105
	 */
106
	private $address;
107
108
	/**
109
	 * @var string|null
110
	 *
111
	 * @ORM\Column(name="plz", type="string", length=8, nullable=true)
112
	 */
113
	private $postcode;
114
115
	/**
116
	 * @var string|null
117
	 *
118
	 * @ORM\Column(name="ort", type="string", length=100, nullable=true)
119
	 */
120
	private $city;
121
122
	/**
123
	 * @var string|null
124
	 *
125
	 * @ORM\Column(name="country", type="string", length=8, options={"default":""}, nullable=true)
126
	 */
127
	private $country = '';
128
129
	/**
130
	 * @var string
131
	 *
132
	 * @ORM\Column(name="email", type="string", length=250, options={"default":""}, nullable=false)
133
	 */
134
	private $applicantEmailAddress = '';
135
136
	/**
137
	 * @var string
138
	 *
139
	 * @ORM\Column(name="phone", type="string", length=30, options={"default":""}, nullable=false)
140
	 */
141
	private $applicantPhoneNumber = '';
142
143
	/**
144
	 * Date of birth
145
	 *
146
	 * @var \DateTime|null
147
	 *
148
	 * @ORM\Column(name="dob", type="date", nullable=true)
149
	 */
150
	private $applicantDateOfBirth;
151
152
	/**
153
	 * @var string
154
	 *
155
	 * @ORM\Column(name="wikimedium_shipping", type="string", options={"default":""}, nullable=false)
156
	 */
157
	private $wikimediumShipping = 'none';
158
159
	/**
160
	 * @var string
161
	 *
162
	 * @ORM\Column(name="membership_type", type="string", options={"default":"sustaining"}, nullable=false)
163
	 */
164
	private $membershipType = 'sustaining';
165
166
	/**
167
	 * @var string
168
	 *
169
	 * @ORM\Column(name="payment_type", type="string", options={"default":"BEZ"}, nullable=false)
170
	 */
171
	private $paymentType = 'BEZ';
172
173
	/**
174
	 * @var integer
175
	 *
176
	 * @ORM\Column(name="membership_fee", type="integer", options={"default":0}, nullable=false)
177
	 */
178
	private $paymentAmountInEuro = 0;
179
180
	/**
181
	 * FIXME: this should not be nullable
182
	 *
183
	 * @var integer
184
	 *
185
	 * @ORM\Column(name="membership_fee_interval", type="smallint", options={"default":12}, nullable=true)
186
	 */
187
	private $paymentIntervalInMonths = 12;
188
189
	/**
190
	 * @var string
191
	 *
192
	 * @ORM\Column(name="account_number", type="string", length=16, options={"default":""}, nullable=false)
193
	 */
194
	private $paymentBankAccount = '';
195
196
	/**
197
	 * @var string
198
	 *
199
	 * @ORM\Column(name="bank_name", type="string", length=100, options={"default":""}, nullable=false)
200
	 */
201
	private $paymentBankName = '';
202
203
	/**
204
	 * @var string
205
	 *
206
	 * @ORM\Column(name="bank_code", type="string", length=16, options={"default":""}, nullable=false)
207
	 */
208
	private $paymentBankCode = '';
209
210
	/**
211
	 * @var string|null
212
	 *
213
	 * @ORM\Column(name="iban", type="string", length=32, options={"default":""}, nullable=true)
214
	 */
215
	private $paymentIban = '';
216
217
	/**
218
	 * @var string|null
219
	 *
220
	 * @ORM\Column(name="bic", type="string", length=32, options={"default":""}, nullable=true)
221
	 */
222
	private $paymentBic = '';
223
224
	/**
225
	 * @var string
226
	 *
227
	 * @ORM\Column(name="account_holder", type="string", length=50, options={"default":""}, nullable=false)
228
	 */
229
	private $paymentBankAccountHolder = '';
230
231
	/**
232
	 * @var string
233
	 *
234
	 * @ORM\Column(name="comment", type="text", options={"default":""}, nullable=false)
235
	 */
236
	private $comment = '';
237
238
	/**
239
	 * @var \DateTime|null
240
	 *
241
	 * @ORM\Column(name="export", type="datetime", nullable=true)
242
	 */
243
	private $export;
244
245
	/**
246
	 * @var \DateTime|null
247
	 *
248
	 * @ORM\Column(name="backup", type="datetime", nullable=true)
249
	 */
250
	private $backup;
251
252
	/**
253
	 * @var boolean
254
	 *
255
	 * @ORM\Column(name="wikilogin", type="boolean", options={"default":0}, nullable=false)
256
	 */
257
	private $wikilogin = 0;
258
259
	/**
260
	 * @var string|null
261
	 *
262
	 * @ORM\Column(name="tracking", type="string", length=50, nullable=true)
263
	 */
264
	private $tracking;
265
266
	/**
267
	 * @var string|null
268
	 *
269
	 * @ORM\Column(name="data", type="text", nullable=true)
270
	 */
271
	private $data;
272
273
	/**
274
	 * @return integer
275
	 */
276 3
	public function getId() {
277 3
		return $this->id;
278
	}
279
280
	/**
281
	 * @since 2.0
282
	 *
283
	 * @param integer|null $id
284
	 */
285 2
	public function setId( $id ) {
286 2
		$this->id = $id;
287 2
	}
288
289
	/**
290
	 * @param integer|null $donationId
291
	 *
292
	 * @return self
293
	 */
294
	public function setDonationId( $donationId ) {
295
		$this->donationId = $donationId;
296
297
		return $this;
298
	}
299
300
	/**
301
	 * Returns the id of the donation that led to the membership application,
302
	 * or null when the application is not linked to any donation.
303
	 *
304
	 * @return integer|null
305
	 */
306
	public function getDonationId() {
307
		return $this->donationId;
308
	}
309
310
	/**
311
	 * @param \DateTime|null $creationTime
312
	 *
313
	 * @return self
314
	 */
315
	public function setCreationTime( $creationTime ) {
316
		$this->creationTime = $creationTime;
317
318
		return $this;
319
	}
320
321
	/**
322
	 * @return \DateTime|null
323
	 */
324
	public function getCreationTime() {
325
		return $this->creationTime;
326
	}
327
328
	/**
329
	 * @param string|null $applicantSalutation
330
	 *
331
	 * @return self
332
	 */
333
	public function setApplicantSalutation( $applicantSalutation ) {
334
		$this->applicantSalutation = $applicantSalutation;
335
336
		return $this;
337
	}
338
339
	/**
340
	 * @return string|null
341
	 */
342
	public function getApplicantSalutation() {
343
		return $this->applicantSalutation;
344
	}
345
346
	/**
347
	 * @param string|null $company
348
	 *
349
	 * @return self
350
	 */
351
	public function setCompany( $company ) {
352
		$this->company = $company;
353
354
		return $this;
355
	}
356
357
	/**
358
	 * @return string|null
359
	 */
360
	public function getCompany() {
361
		return $this->company;
362
	}
363
364
	/**
365
	 * @param string $applicantTitle
366
	 *
367
	 * @return self
368
	 */
369
	public function setApplicantTitle( $applicantTitle ) {
370
		$this->applicantTitle = $applicantTitle;
371
372
		return $this;
373
	}
374
375
	/**
376
	 * @return string
377
	 */
378
	public function getApplicantTitle() {
379
		return $this->applicantTitle;
380
	}
381
382
	/**
383
	 * @param string $probablyUnusedNameField
384
	 *
385
	 * @return self
386
	 */
387
	public function setProbablyUnusedNameField( $probablyUnusedNameField ) {
388
		$this->probablyUnusedNameField = $probablyUnusedNameField;
389
390
		return $this;
391
	}
392
393
	/**
394
	 * @return string
395
	 */
396
	public function getProbablyUnusedNameField() {
397
		return $this->probablyUnusedNameField;
398
	}
399
400
	/**
401
	 * @param string $applicantFirstName
402
	 *
403
	 * @return self
404
	 */
405
	public function setApplicantFirstName( $applicantFirstName ) {
406
		$this->applicantFirstName = $applicantFirstName;
407
		$this->setNameFromParts( $applicantFirstName, $this->getApplicantLastName() );
408
409
		return $this;
410
	}
411
412
	/**
413
	 * @return string
414
	 */
415
	public function getApplicantFirstName() {
416
		return $this->applicantFirstName;
417
	}
418
419
	/**
420
	 * @param string $applicantLastName
421
	 *
422
	 * @return self
423
	 */
424
	public function setApplicantLastName( $applicantLastName ) {
425
		$this->applicantLastName = $applicantLastName;
426
		$this->setNameFromParts( $this->getApplicantFirstName(), $applicantLastName );
427
428
		return $this;
429
	}
430
431
	/**
432
	 * @return string
433
	 */
434
	public function getApplicantLastName() {
435
		return $this->applicantLastName;
436
	}
437
438
	/**
439
	 * Sets the full name
440
	 *
441
	 * @param string|null $firstName
442
	 * @param string|null $lastName
443
	 *
444
	 * @return self
445
	 */
446
	private function setNameFromParts( $firstName, $lastName ) {
447
		$this->setProbablyUnusedNameField( implode(
448
			' ',
449
			array_filter( [ $firstName, $lastName ] )
450
		) );
451
452
		return $this;
453
	}
454
455
	/**
456
	 * Set address (street, etc)
457
	 *
458
	 * @param string|null $address
459
	 *
460
	 * @return self
461
	 */
462
	public function setAddress( $address ) {
463
		$this->address = $address;
464
465
		return $this;
466
	}
467
468
	/**
469
	 * Get address (street, etc)
470
	 *
471
	 * @return string|null
472
	 */
473
	public function getAddress() {
474
		return $this->address;
475
	}
476
477
	/**
478
	 * @param string|null $postcode
479
	 *
480
	 * @return self
481
	 */
482
	public function setPostcode( $postcode ) {
483
		$this->postcode = $postcode;
484
485
		return $this;
486
	}
487
488
	/**
489
	 * @return string|null
490
	 */
491
	public function getPostcode() {
492
		return $this->postcode;
493
	}
494
495
	/**
496
	 * @param string|null $city
497
	 *
498
	 * @return self
499
	 */
500
	public function setCity( $city ) {
501
		$this->city = $city;
502
503
		return $this;
504
	}
505
506
	/**
507
	 * @return string|null
508
	 */
509
	public function getCity() {
510
		return $this->city;
511
	}
512
513
	/**
514
	 * Set email
515
	 *
516
	 * @param string $applicantEmailAddress
517
	 *
518
	 * @return self
519
	 */
520
	public function setApplicantEmailAddress( $applicantEmailAddress ) {
521
		$this->applicantEmailAddress = $applicantEmailAddress;
522
523
		return $this;
524
	}
525
526
	/**
527
	 * Get email
528
	 *
529
	 * @return string
530
	 */
531
	public function getApplicantEmailAddress() {
532
		return $this->applicantEmailAddress;
533
	}
534
535
	/**
536
	 * Set phone
537
	 *
538
	 * @param string $applicantPhoneNumber
539
	 *
540
	 * @return self
541
	 */
542
	public function setApplicantPhoneNumber( $applicantPhoneNumber ) {
543
		$this->applicantPhoneNumber = $applicantPhoneNumber;
544
545
		return $this;
546
	}
547
548
	/**
549
	 * Get phone
550
	 *
551
	 * @return string
552
	 */
553
	public function getApplicantPhoneNumber() {
554
		return $this->applicantPhoneNumber;
555
	}
556
557
	/**
558
	 * @param \DateTime|null $dateOfBirth
559
	 *
560
	 * @return self
561
	 */
562
	public function setApplicantDateOfBirth( $dateOfBirth ) {
563
		$this->applicantDateOfBirth = $dateOfBirth;
564
565
		return $this;
566
	}
567
568
	/**
569
	 * @return \DateTime|null
570
	 */
571
	public function getApplicantDateOfBirth() {
572
		return $this->applicantDateOfBirth;
573
	}
574
575
	/**
576
	 * @param string $wikimediumShipping
577
	 *
578
	 * @return self
579
	 */
580
	public function setWikimediumShipping( $wikimediumShipping ) {
581
		$this->wikimediumShipping = $wikimediumShipping;
582
583
		return $this;
584
	}
585
586
	/**
587
	 * @return string
588
	 */
589
	public function getWikimediumShipping() {
590
		return $this->wikimediumShipping;
591
	}
592
593
	/**
594
	 * @param string $membershipType
595
	 *
596
	 * @return self
597
	 */
598
	public function setMembershipType( $membershipType ) {
599
		$this->membershipType = $membershipType;
600
601
		return $this;
602
	}
603
604
	/**
605
	 * @return string
606
	 */
607
	public function getMembershipType() {
608
		return $this->membershipType;
609
	}
610
611
	/**
612
	 * @since 2.1
613
	 *
614
	 * @param string $paymentType
615
	 *
616
	 * @return self
617
	 */
618
	public function setPaymentType( $paymentType ) {
619
		$this->paymentType = $paymentType;
620
621
		return $this;
622
	}
623
624
	/**
625
	 * @since 2.1
626
	 *
627
	 * @return string
628
	 */
629
	public function getPaymentType() {
630
		return $this->paymentType;
631
	}
632
633
	/**
634
	 * @param integer $paymentAmountInEuro
635
	 *
636
	 * @return self
637
	 */
638
	public function setPaymentAmount( $paymentAmountInEuro ) {
639
		$this->paymentAmountInEuro = $paymentAmountInEuro;
640
641
		return $this;
642
	}
643
644
	/**
645
	 * @return integer
646
	 */
647
	public function getPaymentAmount() {
648
		return $this->paymentAmountInEuro;
649
	}
650
651
	/**
652
	 * @param integer $paymentIntervalInMonths
653
	 *
654
	 * @return self
655
	 */
656
	public function setPaymentIntervalInMonths($paymentIntervalInMonths) {
657
		$this->paymentIntervalInMonths = $paymentIntervalInMonths;
658
659
		return $this;
660
	}
661
662
	/**
663
	 * @return integer
664
	 */
665
	public function getPaymentIntervalInMonths() {
666
		return $this->paymentIntervalInMonths;
667
	}
668
669
670
	/**
671
	 * @param string $paymentBankAccount
672
	 *
673
	 * @return self
674
	 */
675
	public function setPaymentBankAccount( $paymentBankAccount ) {
676
		$this->paymentBankAccount = $paymentBankAccount;
677
678
		return $this;
679
	}
680
681
	/**
682
	 * @return string
683
	 */
684
	public function getPaymentBankAccount() {
685
		return $this->paymentBankAccount;
686
	}
687
688
	/**
689
	 * @param string $paymentBankName
690
	 *
691
	 * @return self
692
	 */
693
	public function setPaymentBankName( $paymentBankName ) {
694
		$this->paymentBankName = $paymentBankName;
695
696
		return $this;
697
	}
698
699
	/**
700
	 * @return string
701
	 */
702
	public function getPaymentBankName() {
703
		return $this->paymentBankName;
704
	}
705
706
	/**
707
	 * @param string $paymentBankCode
708
	 *
709
	 * @return self
710
	 */
711
	public function setPaymentBankCode( $paymentBankCode ) {
712
		$this->paymentBankCode = $paymentBankCode;
713
714
		return $this;
715
	}
716
717
	/**
718
	 * @return string
719
	 */
720
	public function getPaymentBankCode() {
721
		return $this->paymentBankCode;
722
	}
723
724
	/**
725
	 * @param string|null $paymentIban
726
	 *
727
	 * @return self
728
	 */
729
	public function setPaymentIban( $paymentIban ) {
730
		$this->paymentIban = $paymentIban;
731
732
		return $this;
733
	}
734
735
	/**
736
	 * @return string|null
737
	 */
738
	public function getPaymentIban() {
739
		return $this->paymentIban;
740
	}
741
742
	/**
743
	 * @param string|null $paymentBic
744
	 *
745
	 * @return self
746
	 */
747
	public function setPaymentBic( $paymentBic ) {
748
		$this->paymentBic = $paymentBic;
749
750
		return $this;
751
	}
752
753
	/**
754
	 * @return string|null
755
	 */
756
	public function getPaymentBic() {
757
		return $this->paymentBic;
758
	}
759
760
	/**
761
	 * @param string $paymentBankAccountHolder
762
	 *
763
	 * @return self
764
	 */
765
	public function setPaymentBankAccountHolder( $paymentBankAccountHolder ) {
766
		$this->paymentBankAccountHolder = $paymentBankAccountHolder;
767
768
		return $this;
769
	}
770
771
	/**
772
	 * @return string
773
	 */
774
	public function getPaymentBankAccountHolder() {
775
		return $this->paymentBankAccountHolder;
776
	}
777
778
	/**
779
	 * @param string $comment
780
	 *
781
	 * @return self
782
	 */
783
	public function setComment( $comment ) {
784
		$this->comment = $comment;
785
786
		return $this;
787
	}
788
789
	/**
790
	 * @return string
791
	 */
792
	public function getComment() {
793
		return $this->comment;
794
	}
795
796
	/**
797
	 * Sets the time of export.
798
	 *
799
	 * @param \DateTime|null $export
800
	 *
801
	 * @return self
802
	 */
803
	public function setExport( $export ) {
804
		$this->export = $export;
805
806
		return $this;
807
	}
808
809
	/**
810
	 * Returns the time of export.
811
	 *
812
	 * @return \DateTime|null
813
	 */
814
	public function getExport() {
815
		return $this->export;
816
	}
817
818
	/**
819
	 * Sets the time of backup.
820
	 *
821
	 * @param \DateTime|null $backup
822
	 *
823
	 * @return self
824
	 */
825
	public function setBackup( $backup ) {
826
		$this->backup = $backup;
827
828
		return $this;
829
	}
830
831
	/**
832
	 * Returns the time of backup.
833
	 *
834
	 * @return \DateTime|null
835
	 */
836
	public function getBackup() {
837
		return $this->backup;
838
	}
839
840
	/**
841
	 * @param boolean $wikilogin
842
	 *
843
	 * @return self
844
	 */
845
	public function setWikilogin( $wikilogin ) {
846
		$this->wikilogin = $wikilogin;
847
848
		return $this;
849
	}
850
851
	/**
852
	 * @return boolean
853
	 */
854
	public function getWikilogin() {
855
		return $this->wikilogin;
856
	}
857
858
	/**
859
	 * @param string|null $tracking
860
	 *
861
	 * @return self
862
	 */
863
	public function setTracking( $tracking ) {
864
		$this->tracking = $tracking;
865
866
		return $this;
867
	}
868
869
	/**
870
	 * @return string|null
871
	 */
872
	public function getTracking() {
873
		return $this->tracking;
874
	}
875
876
	/**
877
	 * Sets the status of the membership request.
878
	 * The allowed values are the STATUS_ constants in this class.
879
	 *
880
	 * @param integer $status
881
	 *
882
	 * @return self
883
	 */
884 4
	public function setStatus( $status ) {
885 4
		$this->status = $status;
886
887 4
		return $this;
888
	}
889
890
	/**
891
	 * Returns the status of the membership request.
892
	 * The possible values are the STATUS_ constants in this class.
893
	 *
894
	 * @return integer
895
	 */
896
	public function getStatus() {
897
		return $this->status;
898
	}
899
900
	/**
901
	 * @param string|null $country
902
	 *
903
	 * @return self
904
	 */
905
	public function setCountry( $country ) {
906
		$this->country = $country;
907
908
		return $this;
909
	}
910
911
	/**
912
	 * @return string|null
913
	 */
914
	public function getCountry() {
915
		return $this->country;
916
	}
917
918
	/**
919
	 * @param string|null $data
920
	 * @return self
921
	 */
922
	public function setData( $data ) {
923
		$this->data = $data;
924
925
		return $this;
926
	}
927
928
	/**
929
	 * @return string|null
930
	 */
931
	public function getData() {
932
		return $this->data;
933
	}
934
935
	/**
936
	 * @return bool
937
	 */
938
	public function isUnconfirmed() {
939
		return $this->status === self::STATUS_NEUTRAL;
940
	}
941
942
	/**
943
	 * @return bool
944
	 */
945 3
	public function needsModeration() {
946 3
		return $this->status < 0 && abs( $this->status ) & abs( self::STATUS_MODERATION );
947
	}
948
949
	/**
950
	 * @return bool
951
	 */
952 3
	public function isCancelled() {
953 3
		return $this->status < 0 && abs( $this->status ) & abs( self::STATUS_CANCELED );
954
	}
955
956
	public function log( $message ) {
957
		$dataArray = $this->getDecodedData();
958
		$dataArray[ "log" ][ date( "Y-m-d H:i:s" ) ] = $message;
959
		$this->encodeAndSetData( $dataArray );
960
961
		return $this;
962
	}
963
964
	/**
965
	 * NOTE: if possible, use @see getDataObject instead, as it provides a nicer API.
966
	 *
967
	 * @since 2.0
968
	 * @return array
969
	 */
970 5
	public function getDecodedData() {
971 5
		if ( $this->data === null ) {
972 3
			return [];
973
		}
974
975 4
		$data = unserialize( base64_decode( $this->data ) );
976
977 4
		return is_array( $data ) ? $data : [];
978
	}
979
980
	/**
981
	 * NOTE: if possible, use @see modifyDataObject instead, as it provides a nicer API.
982
	 *
983
	 * @since 2.0
984
	 * @param array $data
0 ignored issues
show
Bug introduced by
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
985
	 */
986 4
	public function encodeAndSetData( array $dataArray ) {
987 4
		$this->data = base64_encode( serialize( $dataArray ) );
988 4
	}
989
990
	/**
991
	 * WARNING: updates made to the return value will not be reflected in the Donation state.
992
	 * Similarly, updates to the Donation state will not propagate to the returned object.
993
	 * To update the Donation state, explicitly call @see setDataObject.
994
	 *
995
	 * @since 2.0
996
	 * @return MembershipApplicationData
997
	 */
998 2
	public function getDataObject() {
999 2
		$dataArray = $this->getDecodedData();
1000
1001 2
		$data = new MembershipApplicationData();
1002
1003 2
		$data->setAccessToken( array_key_exists( 'token', $dataArray ) ? $dataArray['token'] : null );
1004 2
		$data->setUpdateToken( array_key_exists( 'utoken', $dataArray ) ? $dataArray['utoken'] : null );
1005 2
		$data->setPreservedStatus( array_key_exists( 'old_status', $dataArray ) ? $dataArray['old_status'] : null );
1006
1007 2
		return $data;
1008
	}
1009
1010
	/**
1011
	 * @since 2.0
1012
	 * @param MembershipApplicationData $data
1013
	 */
1014 4
	public function setDataObject( MembershipApplicationData $data ) {
1015 4
		$dataArray = array_merge(
1016 4
			$this->getDecodedData(),
1017
			[
1018 4
				'token' => $data->getAccessToken(),
1019 4
				'utoken' => $data->getUpdateToken(),
1020 4
				'old_status' => $data->getPreservedStatus(),
1021
			]
1022
		);
1023
1024 4
		foreach ( [ 'token', 'utoken', 'old_status' ] as $keyName ) {
1025 4
			if ( is_null( $dataArray[$keyName] ) ) {
1026 4
				unset( $dataArray[$keyName] );
1027
			}
1028
		}
1029
1030 4
		$this->encodeAndSetData( $dataArray );
1031 4
	}
1032
1033
	/**
1034
	 * @since 2.0
1035
	 * @param callable $modificationFunction Takes a modifiable MembershipApplicationData parameter
1036
	 */
1037 1
	public function modifyDataObject( callable $modificationFunction ) {
1038 1
		$dataObject = $this->getDataObject();
1039 1
		$modificationFunction( $dataObject );
1040 1
		$this->setDataObject( $dataObject );
1041 1
	}
1042
1043
}
1044