1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
4
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Entities; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Ramsey\Uuid\Uuid; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @since 8.0 |
12
|
|
|
* |
13
|
|
|
* @ORM\Table( name="address_change" ) |
14
|
|
|
* @ORM\Entity |
15
|
|
|
*/ |
16
|
|
|
class AddressChange { |
17
|
|
|
|
18
|
|
|
public const ADDRESS_TYPE_PERSON = 'person'; |
19
|
|
|
|
20
|
|
|
public const ADDRESS_TYPE_COMPANY = 'company'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var integer |
24
|
|
|
* |
25
|
|
|
* @ORM\Column(name="id", type="integer") |
26
|
|
|
* @ORM\Id |
27
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
28
|
|
|
*/ |
29
|
|
|
private $id; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @ORM\ManyToOne(targetEntity="Address") |
33
|
|
|
* @ORM\JoinColumn(name="address_id", referencedColumnName="id") |
34
|
|
|
*/ |
35
|
|
|
private $address; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
* |
40
|
|
|
* @ORM\Column(name="current_identifier", type="string", length=36, nullable=true, unique=true) |
41
|
|
|
*/ |
42
|
|
|
private $identifier; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
* |
47
|
|
|
* @ORM\Column(name="previous_identifier", type="string", length=36, nullable=true, unique=true) |
48
|
|
|
*/ |
49
|
|
|
private $previousIdentifier; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var int |
53
|
|
|
* |
54
|
|
|
* @ORM\Column(name="third_party_identifier", type="integer", nullable=true, unique=true) |
55
|
|
|
*/ |
56
|
|
|
private $thirdPartyIdentifier; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string |
60
|
|
|
* |
61
|
|
|
* @ORM\Column(name="address_type", type="string", length = 10) |
62
|
|
|
*/ |
63
|
|
|
private $addressType; |
64
|
|
|
|
65
|
6 |
|
public function __construct( string $addressType ) { |
66
|
6 |
|
$this->addressType = $addressType; |
67
|
6 |
|
if ($this->identifier === null) { |
68
|
6 |
|
$this->generateUuid(); |
69
|
|
|
} |
70
|
6 |
|
} |
71
|
|
|
|
72
|
6 |
|
private function generateUuid(): void { |
73
|
6 |
|
$this->identifier = Uuid::uuid4()->toString(); |
74
|
6 |
|
} |
75
|
|
|
|
76
|
3 |
|
public function updateAddressIdentifier(): void { |
77
|
3 |
|
$this->previousIdentifier = $this->getCurrentIdentifier(); |
78
|
3 |
|
$this->generateUuid(); |
79
|
3 |
|
} |
80
|
|
|
|
81
|
6 |
|
public function getCurrentIdentifier(): string { |
82
|
6 |
|
if ($this->identifier === null) { |
83
|
|
|
$this->generateUuid(); |
84
|
|
|
} |
85
|
6 |
|
return $this->identifier; |
86
|
|
|
} |
87
|
|
|
|
88
|
3 |
|
public function getPreviousIdentifier(): ?string { |
89
|
3 |
|
return $this->previousIdentifier; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getAddress(): Address { |
93
|
|
|
return $this->address; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function setAddress( Address $address ) { |
97
|
|
|
$this->address = $address; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getThirdPartyIdentifier(): int { |
101
|
|
|
return $this->thirdPartyIdentifier; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function setThirdPartyIdentifier( int $thirdPartyIdentifier ): void { |
105
|
|
|
$this->thirdPartyIdentifier = $thirdPartyIdentifier; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getAddressType(): string { |
109
|
|
|
return $this->addressType; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|