|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\AddressChangeContext\UseCases\ChangeAddress; |
|
6
|
|
|
|
|
7
|
|
|
use WMDE\Fundraising\AddressChangeContext\Domain\Model\AddressType; |
|
8
|
|
|
|
|
9
|
|
|
class ChangeAddressRequest { |
|
10
|
4 |
|
private function __construct( |
|
11
|
|
|
public readonly AddressType $addressType, |
|
12
|
|
|
public readonly string $address, |
|
13
|
|
|
public readonly string $postcode, |
|
14
|
|
|
public readonly string $city, |
|
15
|
|
|
public readonly string $country, |
|
16
|
|
|
public readonly string $identifier, |
|
17
|
|
|
public readonly bool $donationReceipt, |
|
18
|
|
|
public readonly bool $isOptOutOnly, |
|
19
|
|
|
public readonly string $company = '', |
|
20
|
|
|
public readonly string $salutation = '', |
|
21
|
|
|
public readonly string $title = '', |
|
22
|
|
|
public readonly string $firstName = '', |
|
23
|
|
|
public readonly string $lastName = '', |
|
24
|
|
|
) { |
|
25
|
4 |
|
} |
|
26
|
|
|
|
|
27
|
2 |
|
public static function newPersonalChangeAddressRequest( |
|
28
|
|
|
string $salutation, |
|
29
|
|
|
string $title, |
|
30
|
|
|
string $firstName, |
|
31
|
|
|
string $lastName, |
|
32
|
|
|
string $address, |
|
33
|
|
|
string $postcode, |
|
34
|
|
|
string $city, |
|
35
|
|
|
string $country, |
|
36
|
|
|
string $identifier, |
|
37
|
|
|
bool $donationReceipt, |
|
38
|
|
|
bool $isOptOutOnly, |
|
39
|
|
|
): ChangeAddressRequest { |
|
40
|
2 |
|
return new self( |
|
41
|
2 |
|
addressType: AddressType::Person, |
|
42
|
2 |
|
address: trim( $address ), |
|
43
|
2 |
|
postcode: trim( $postcode ), |
|
44
|
2 |
|
city: trim( $city ), |
|
45
|
2 |
|
country: trim( $country ), |
|
46
|
2 |
|
identifier: trim( $identifier ), |
|
47
|
2 |
|
donationReceipt: $donationReceipt, |
|
48
|
2 |
|
isOptOutOnly: $isOptOutOnly, |
|
49
|
2 |
|
salutation: trim( $salutation ), |
|
50
|
2 |
|
title: trim( $title ), |
|
51
|
2 |
|
firstName: trim( $firstName ), |
|
52
|
2 |
|
lastName: trim( $lastName ), |
|
53
|
2 |
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
2 |
|
public static function newCompanyChangeAddressRequest( |
|
57
|
|
|
string $company, |
|
58
|
|
|
string $address, |
|
59
|
|
|
string $postcode, |
|
60
|
|
|
string $city, |
|
61
|
|
|
string $country, |
|
62
|
|
|
string $identifier, |
|
63
|
|
|
bool $donationReceipt, |
|
64
|
|
|
bool $isOptOutOnly, |
|
65
|
|
|
): ChangeAddressRequest { |
|
66
|
2 |
|
return new self( |
|
67
|
2 |
|
addressType: AddressType::Company, |
|
68
|
2 |
|
address: trim( $address ), |
|
69
|
2 |
|
postcode: trim( $postcode ), |
|
70
|
2 |
|
city: trim( $city ), |
|
71
|
2 |
|
country: trim( $country ), |
|
72
|
2 |
|
identifier: trim( $identifier ), |
|
73
|
2 |
|
donationReceipt: $donationReceipt, |
|
74
|
2 |
|
isOptOutOnly: $isOptOutOnly, |
|
75
|
2 |
|
company: trim( $company ), |
|
76
|
2 |
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function isPersonal(): bool { |
|
80
|
|
|
return $this->addressType === AddressType::Person; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function isCompany(): bool { |
|
84
|
|
|
return $this->addressType === AddressType::Company; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function isOptedOutOfDonationReceipt(): bool { |
|
88
|
|
|
return !$this->donationReceipt; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function hasAddressChangeData(): bool { |
|
92
|
|
|
return !$this->isOptOutOnly; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|