Completed
Push — master ( 0bd35f...059f21 )
by
unknown
04:06 queued 01:35
created

MembershipApplication::setCity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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