1 | <?php |
||
22 | class AddressChange { |
||
23 | |||
24 | public const ADDRESS_TYPE_PERSON = 'person'; |
||
25 | |||
26 | public const ADDRESS_TYPE_COMPANY = 'company'; |
||
27 | |||
28 | public const EXTERNAL_ID_TYPE_DONATION = 'donation'; |
||
29 | |||
30 | public const EXTERNAL_ID_TYPE_MEMBERSHIP = 'membership'; |
||
31 | |||
32 | /** |
||
33 | * @var integer |
||
34 | * |
||
35 | * @ORM\Column(name="id", type="integer") |
||
36 | * @ORM\Id |
||
37 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
38 | */ |
||
39 | private $id; |
||
40 | |||
41 | /** |
||
42 | * @ORM\ManyToOne(targetEntity="Address") |
||
43 | * @ORM\JoinColumn(name="address_id", referencedColumnName="id") |
||
44 | */ |
||
45 | private $address; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | * |
||
50 | * @ORM\Column(name="current_identifier", type="string", length=36, nullable=true, unique=true) |
||
51 | */ |
||
52 | private $identifier; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | * |
||
57 | * @ORM\Column(name="previous_identifier", type="string", length=36, nullable=true, unique=true) |
||
58 | */ |
||
59 | private $previousIdentifier; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | * |
||
64 | * @ORM\Column(name="address_type", type="string", length = 10) |
||
65 | */ |
||
66 | private $addressType; |
||
67 | |||
68 | /** |
||
69 | * @var int |
||
70 | * |
||
71 | * @ORM\Column(name="external_id", type="integer") |
||
72 | */ |
||
73 | private $externalId; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | * |
||
78 | * @ORM\Column(name="external_id_type", type="string", length=10 ) |
||
79 | */ |
||
80 | private $externalIdType; |
||
81 | |||
82 | /** |
||
83 | * Date of last export |
||
84 | * |
||
85 | * No getter / setter needed -> read access is in AddressChange repo and update in exporter code |
||
86 | * |
||
87 | * @var \DateTime |
||
88 | * |
||
89 | * @ORM\Column(name="export_date", type="datetime", nullable=true) |
||
90 | */ |
||
91 | private $exportDate; |
||
92 | |||
93 | /** |
||
94 | * When this was created |
||
95 | * |
||
96 | * No getter / setter needed, modification is in AddressChange repo |
||
97 | * |
||
98 | * @var \DateTime |
||
99 | * @ORM\Column(name="created_at", type="datetime") |
||
100 | */ |
||
101 | private $createdAt; |
||
102 | |||
103 | /** |
||
104 | * When this was last modified |
||
105 | * |
||
106 | * No getter / setter needed, modification is in AddressChange repo |
||
107 | * |
||
108 | * @var \DateTime |
||
109 | * @ORM\Column(name="modified_at", type="datetime") |
||
110 | */ |
||
111 | private $modifiedAt; |
||
112 | |||
113 | /** |
||
114 | * @var boolean |
||
115 | * |
||
116 | * @ORM\Column(name="donation_receipt", type="boolean", nullable=false) |
||
117 | */ |
||
118 | private $donationReceipt = true; |
||
119 | |||
120 | |||
121 | 2 | private function __construct( string $addressType, string $externalIdType, int $externalId ) { |
|
131 | |||
132 | 1 | public static function newDonationAddressChange( string $addressType, int $donationId ): self { |
|
135 | |||
136 | 1 | public static function newMembershipAddressChange( string $addressType, int $membershipId ): self { |
|
139 | |||
140 | 2 | private function generateUuid(): void { |
|
143 | |||
144 | 1 | public function updateAddressIdentifier(): void { |
|
148 | |||
149 | 2 | public function getCurrentIdentifier(): string { |
|
155 | |||
156 | 1 | public function getPreviousIdentifier(): ?string { |
|
159 | |||
160 | public function isOptedIntoDonationReceipt() { |
||
163 | |||
164 | public function setDonationReceipt( $donationReceipt ) { |
||
167 | |||
168 | public function getAddress(): ?Address { |
||
171 | |||
172 | public function setAddress( Address $address ) { |
||
175 | |||
176 | public function getAddressType(): string { |
||
179 | } |
||
180 |