Completed
Pull Request — master (#600)
by Jeroen De
07:28
created
src/Validation/PersonNameValidator.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\Validation;
6 6
 
@@ -13,28 +13,28 @@  discard block
 block discarded – undo
13 13
 class PersonNameValidator {
14 14
 	use CanValidateField;
15 15
 
16
-	public function validate( DonorName $name ): ValidationResult {
17
-		if ( $name->getPersonType() === DonorName::PERSON_PRIVATE ) {
18
-			return $this->validatePrivatePerson( $name );
16
+	public function validate(DonorName $name): ValidationResult {
17
+		if ($name->getPersonType() === DonorName::PERSON_PRIVATE) {
18
+			return $this->validatePrivatePerson($name);
19 19
 		}
20 20
 
21
-		return $this->validateCompanyPerson( $name );
21
+		return $this->validateCompanyPerson($name);
22 22
 	}
23 23
 
24
-	private function validatePrivatePerson( DonorName $instance ): ValidationResult {
24
+	private function validatePrivatePerson(DonorName $instance): ValidationResult {
25 25
 		$validator = new RequiredFieldValidator();
26 26
 
27
-		return new ValidationResult( ...array_filter( [
28
-			$this->getFieldViolation( $validator->validate( $instance->getSalutation() ), 'salutation' ),
29
-			$this->getFieldViolation( $validator->validate( $instance->getFirstName() ), 'firstName' ),
30
-			$this->getFieldViolation( $validator->validate( $instance->getLastName() ), 'lastName' )
31
-		] ) );
27
+		return new ValidationResult(...array_filter([
28
+			$this->getFieldViolation($validator->validate($instance->getSalutation()), 'salutation'),
29
+			$this->getFieldViolation($validator->validate($instance->getFirstName()), 'firstName'),
30
+			$this->getFieldViolation($validator->validate($instance->getLastName()), 'lastName')
31
+		]));
32 32
 	}
33 33
 
34
-	private function validateCompanyPerson( DonorName $instance ): ValidationResult {
35
-		return new ValidationResult( ...array_filter( [
36
-			$this->getFieldViolation( ( new RequiredFieldValidator() )->validate( $instance->getCompanyName() ), 'company' )
37
-		] ) );
34
+	private function validateCompanyPerson(DonorName $instance): ValidationResult {
35
+		return new ValidationResult(...array_filter([
36
+			$this->getFieldViolation((new RequiredFieldValidator())->validate($instance->getCompanyName()), 'company')
37
+		]));
38 38
 	}
39 39
 
40 40
 }
Please login to merge, or discard this patch.
src/MembershipApplicationContext/Domain/Model/MembershipApplicant.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Model;
6 6
 
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	private $phone;
19 19
 	private $dateOfBirth;
20 20
 
21
-	public function __construct( ApplicantName $name, PhysicalAddress $address, EmailAddress $email,
22
-		PhoneNumber $phone, \DateTime $dateOfBirth = null ) {
21
+	public function __construct(ApplicantName $name, PhysicalAddress $address, EmailAddress $email,
22
+		PhoneNumber $phone, \DateTime $dateOfBirth = null) {
23 23
 
24 24
 		$this->personName = $name;
25 25
 		$this->physicalAddress = $address;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		return $this->dateOfBirth;
48 48
 	}
49 49
 
50
-	public function changeEmailAddress( EmailAddress $email ) {
50
+	public function changeEmailAddress(EmailAddress $email) {
51 51
 		$this->email = $email;
52 52
 	}
53 53
 
Please login to merge, or discard this patch.
DataAccess/DoctrineMembershipApplicationRepository.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\DataAccess;
6 6
 
@@ -29,102 +29,102 @@  discard block
 block discarded – undo
29 29
 
30 30
 	private $entityManager;
31 31
 
32
-	public function __construct( EntityManager $entityManager ) {
32
+	public function __construct(EntityManager $entityManager) {
33 33
 		$this->entityManager = $entityManager;
34 34
 	}
35 35
 
36
-	public function storeApplication( MembershipApplication $application ) {
37
-		if ( $application->hasId() ) {
38
-			$this->updateApplication( $application );
36
+	public function storeApplication(MembershipApplication $application) {
37
+		if ($application->hasId()) {
38
+			$this->updateApplication($application);
39 39
 		}
40 40
 		else {
41
-			$this->insertApplication( $application );
41
+			$this->insertApplication($application);
42 42
 		}
43 43
 	}
44 44
 
45
-	private function insertApplication( MembershipApplication $application ) {
45
+	private function insertApplication(MembershipApplication $application) {
46 46
 		$doctrineApplication = new DoctrineApplication();
47
-		$this->updateDoctrineApplication( $doctrineApplication, $application );
47
+		$this->updateDoctrineApplication($doctrineApplication, $application);
48 48
 
49 49
 		try {
50
-			$this->entityManager->persist( $doctrineApplication );
50
+			$this->entityManager->persist($doctrineApplication);
51 51
 			$this->entityManager->flush();
52 52
 		}
53
-		catch ( ORMException $ex ) {
54
-			throw new StoreMembershipApplicationException( $ex );
53
+		catch (ORMException $ex) {
54
+			throw new StoreMembershipApplicationException($ex);
55 55
 		}
56 56
 
57
-		$application->assignId( $doctrineApplication->getId() );
57
+		$application->assignId($doctrineApplication->getId());
58 58
 	}
59 59
 
60
-	private function updateApplication( MembershipApplication $application ) {
61
-		$doctrineApplication = $this->getDoctrineApplicationById( $application->getId() );
60
+	private function updateApplication(MembershipApplication $application) {
61
+		$doctrineApplication = $this->getDoctrineApplicationById($application->getId());
62 62
 
63
-		if ( $doctrineApplication === null ) {
63
+		if ($doctrineApplication === null) {
64 64
 			throw new StoreMembershipApplicationException();
65 65
 		}
66 66
 
67
-		$this->updateDoctrineApplication( $doctrineApplication, $application );
67
+		$this->updateDoctrineApplication($doctrineApplication, $application);
68 68
 
69 69
 		try {
70
-			$this->entityManager->persist( $doctrineApplication );
70
+			$this->entityManager->persist($doctrineApplication);
71 71
 			$this->entityManager->flush();
72 72
 		}
73
-		catch ( ORMException $ex ) {
74
-			throw new StoreMembershipApplicationException( $ex );
73
+		catch (ORMException $ex) {
74
+			throw new StoreMembershipApplicationException($ex);
75 75
 		}
76 76
 	}
77 77
 
78
-	private function updateDoctrineApplication( DoctrineApplication $doctrineApplication, MembershipApplication $application ) {
79
-		$doctrineApplication->setId( $application->getId() );
80
-		$doctrineApplication->setMembershipType( $application->getType() );
78
+	private function updateDoctrineApplication(DoctrineApplication $doctrineApplication, MembershipApplication $application) {
79
+		$doctrineApplication->setId($application->getId());
80
+		$doctrineApplication->setMembershipType($application->getType());
81 81
 
82
-		$this->setApplicantFields( $doctrineApplication, $application->getApplicant() );
83
-		$this->setPaymentFields( $doctrineApplication, $application->getPayment() );
82
+		$this->setApplicantFields($doctrineApplication, $application->getApplicant());
83
+		$this->setPaymentFields($doctrineApplication, $application->getPayment());
84 84
 
85
-		$doctrineApplication->setStatus( $this->getDoctrineStatus( $application ) );
85
+		$doctrineApplication->setStatus($this->getDoctrineStatus($application));
86 86
 	}
87 87
 
88
-	private function setApplicantFields( DoctrineApplication $application, MembershipApplicant $applicant ) {
89
-		$application->setApplicantFirstName( $applicant->getName()->getFirstName() );
90
-		$application->setApplicantLastName( $applicant->getName()->getLastName() );
91
-		$application->setApplicantSalutation( $applicant->getName()->getSalutation() );
92
-		$application->setApplicantTitle( $applicant->getName()->getTitle() );
88
+	private function setApplicantFields(DoctrineApplication $application, MembershipApplicant $applicant) {
89
+		$application->setApplicantFirstName($applicant->getName()->getFirstName());
90
+		$application->setApplicantLastName($applicant->getName()->getLastName());
91
+		$application->setApplicantSalutation($applicant->getName()->getSalutation());
92
+		$application->setApplicantTitle($applicant->getName()->getTitle());
93 93
 
94
-		$application->setApplicantDateOfBirth( $applicant->getDateOfBirth() );
94
+		$application->setApplicantDateOfBirth($applicant->getDateOfBirth());
95 95
 
96
-		$application->setApplicantEmailAddress( $applicant->getEmailAddress()->getFullAddress() );
97
-		$application->setApplicantPhoneNumber( $applicant->getPhoneNumber()->__toString() );
96
+		$application->setApplicantEmailAddress($applicant->getEmailAddress()->getFullAddress());
97
+		$application->setApplicantPhoneNumber($applicant->getPhoneNumber()->__toString());
98 98
 
99 99
 		$address = $applicant->getPhysicalAddress();
100 100
 
101
-		$application->setCity( $address->getCity() );
102
-		$application->setCountry( $address->getCountryCode() );
103
-		$application->setPostcode( $address->getPostalCode() );
104
-		$application->setAddress( $address->getStreetAddress() );
101
+		$application->setCity($address->getCity());
102
+		$application->setCountry($address->getCountryCode());
103
+		$application->setPostcode($address->getPostalCode());
104
+		$application->setAddress($address->getStreetAddress());
105 105
 	}
106 106
 
107
-	private function setPaymentFields( DoctrineApplication $application, MembershipPayment $payment ) {
108
-		$application->setPaymentIntervalInMonths( $payment->getIntervalInMonths() );
109
-		$application->setPaymentAmount( (int)$payment->getAmount()->getEuroFloat() );
107
+	private function setPaymentFields(DoctrineApplication $application, MembershipPayment $payment) {
108
+		$application->setPaymentIntervalInMonths($payment->getIntervalInMonths());
109
+		$application->setPaymentAmount((int)$payment->getAmount()->getEuroFloat());
110 110
 
111 111
 		$bankData = $payment->getBankData();
112 112
 
113
-		$application->setPaymentBankAccount( $bankData->getAccount() );
114
-		$application->setPaymentBankCode( $bankData->getBankCode() );
115
-		$application->setPaymentBankName( $bankData->getBankName() );
116
-		$application->setPaymentBic( $bankData->getBic() );
117
-		$application->setPaymentIban( $bankData->getIban()->toString() );
113
+		$application->setPaymentBankAccount($bankData->getAccount());
114
+		$application->setPaymentBankCode($bankData->getBankCode());
115
+		$application->setPaymentBankName($bankData->getBankName());
116
+		$application->setPaymentBic($bankData->getBic());
117
+		$application->setPaymentIban($bankData->getIban()->toString());
118 118
 	}
119 119
 
120
-	private function getDoctrineStatus( MembershipApplication $application ): int {
120
+	private function getDoctrineStatus(MembershipApplication $application): int {
121 121
 		$status = DoctrineApplication::STATUS_NEUTRAL;
122 122
 
123
-		if ( $application->needsModeration() ) {
123
+		if ($application->needsModeration()) {
124 124
 			$status += DoctrineApplication::STATUS_MODERATION;
125 125
 		}
126 126
 
127
-		if ( $application->isCancelled() ) {
127
+		if ($application->isCancelled()) {
128 128
 			$status += DoctrineApplication::STATUS_CANCELED;
129 129
 		}
130 130
 
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
 	 * @return \WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Model\MembershipApplication|null
138 138
 	 * @throws \WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Repositories\GetMembershipApplicationException
139 139
 	 */
140
-	public function getApplicationById( int $id ) {
140
+	public function getApplicationById(int $id) {
141 141
 		try {
142
-			$application = $this->getDoctrineApplicationById( $id );
142
+			$application = $this->getDoctrineApplicationById($id);
143 143
 		}
144
-		catch ( ORMException $ex ) {
145
-			throw new GetMembershipApplicationException( $ex );
144
+		catch (ORMException $ex) {
145
+			throw new GetMembershipApplicationException($ex);
146 146
 		}
147 147
 
148
-		if ( $application === null ) {
148
+		if ($application === null) {
149 149
 			return null;
150 150
 		}
151 151
 
152
-		return $this->newApplicationDomainEntity( $application );
152
+		return $this->newApplicationDomainEntity($application);
153 153
 	}
154 154
 
155 155
 	/**
@@ -157,61 +157,61 @@  discard block
 block discarded – undo
157 157
 	 * @return DoctrineApplication|null
158 158
 	 * @throws ORMException
159 159
 	 */
160
-	public function getDoctrineApplicationById( int $id ) {
161
-		return $this->entityManager->find( DoctrineApplication::class, $id );
160
+	public function getDoctrineApplicationById(int $id) {
161
+		return $this->entityManager->find(DoctrineApplication::class, $id);
162 162
 	}
163 163
 
164
-	private function newApplicationDomainEntity( DoctrineApplication $application ): MembershipApplication {
164
+	private function newApplicationDomainEntity(DoctrineApplication $application): MembershipApplication {
165 165
 		return new MembershipApplication(
166 166
 			$application->getId(),
167 167
 			$application->getMembershipType(),
168 168
 			new MembershipApplicant(
169
-				$this->newPersonName( $application ),
170
-				$this->newAddress( $application ),
171
-				new EmailAddress( $application->getApplicantEmailAddress() ),
172
-				new PhoneNumber( $application->getApplicantPhoneNumber() ),
169
+				$this->newPersonName($application),
170
+				$this->newAddress($application),
171
+				new EmailAddress($application->getApplicantEmailAddress()),
172
+				new PhoneNumber($application->getApplicantPhoneNumber()),
173 173
 				$application->getApplicantDateOfBirth()
174 174
 			),
175 175
 			new MembershipPayment(
176 176
 				$application->getPaymentIntervalInMonths(),
177
-				Euro::newFromFloat( $application->getPaymentAmount() ),
178
-				$this->newBankData( $application )
177
+				Euro::newFromFloat($application->getPaymentAmount()),
178
+				$this->newBankData($application)
179 179
 			),
180 180
 			$application->needsModeration(),
181 181
 			$application->isCancelled()
182 182
 		);
183 183
 	}
184 184
 
185
-	private function newPersonName( DoctrineApplication $application ): ApplicantName {
185
+	private function newPersonName(DoctrineApplication $application): ApplicantName {
186 186
 		$personName = ApplicantName::newPrivatePersonName();
187 187
 
188
-		$personName->setFirstName( $application->getApplicantFirstName() );
189
-		$personName->setLastName( $application->getApplicantLastName() );
190
-		$personName->setSalutation( $application->getApplicantSalutation() );
191
-		$personName->setTitle( $application->getApplicantTitle() );
188
+		$personName->setFirstName($application->getApplicantFirstName());
189
+		$personName->setLastName($application->getApplicantLastName());
190
+		$personName->setSalutation($application->getApplicantSalutation());
191
+		$personName->setTitle($application->getApplicantTitle());
192 192
 
193 193
 		return $personName->freeze()->assertNoNullFields();
194 194
 	}
195 195
 
196
-	private function newAddress( DoctrineApplication $application ): PhysicalAddress {
196
+	private function newAddress(DoctrineApplication $application): PhysicalAddress {
197 197
 		$address = new PhysicalAddress();
198 198
 
199
-		$address->setCity( $application->getCity() );
200
-		$address->setCountryCode( $application->getCountry() );
201
-		$address->setPostalCode( $application->getPostcode() );
202
-		$address->setStreetAddress( $application->getAddress() );
199
+		$address->setCity($application->getCity());
200
+		$address->setCountryCode($application->getCountry());
201
+		$address->setPostalCode($application->getPostcode());
202
+		$address->setStreetAddress($application->getAddress());
203 203
 
204 204
 		return $address->freeze()->assertNoNullFields();
205 205
 	}
206 206
 
207
-	private function newBankData( DoctrineApplication $application ): BankData {
207
+	private function newBankData(DoctrineApplication $application): BankData {
208 208
 		$bankData = new BankData();
209 209
 
210
-		$bankData->setAccount( $application->getPaymentBankAccount() );
211
-		$bankData->setBankCode( $application->getPaymentBankCode() );
212
-		$bankData->setBankName( $application->getPaymentBankName() );
213
-		$bankData->setBic( $application->getPaymentBic() );
214
-		$bankData->setIban( new Iban( $application->getPaymentIban() ) );
210
+		$bankData->setAccount($application->getPaymentBankAccount());
211
+		$bankData->setBankCode($application->getPaymentBankCode());
212
+		$bankData->setBankName($application->getPaymentBankName());
213
+		$bankData->setBic($application->getPaymentBic());
214
+		$bankData->setIban(new Iban($application->getPaymentIban()));
215 215
 
216 216
 		return $bankData->freeze()->assertNoNullFields();
217 217
 	}
Please login to merge, or discard this patch.
UseCases/ApplyForMembership/MembershipApplicationBuilder.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\UseCases\ApplyForMembership;
6 6
 
@@ -21,60 +21,60 @@  discard block
 block discarded – undo
21 21
 
22 22
 	const COMPANY_APPLICANT_TYPE = 'firma';
23 23
 
24
-	public function newApplicationFromRequest( ApplyForMembershipRequest $request ): MembershipApplication {
24
+	public function newApplicationFromRequest(ApplyForMembershipRequest $request): MembershipApplication {
25 25
 		return MembershipApplication::newApplication(
26 26
 			$request->getMembershipType(),
27
-			$this->newApplicant( $request ),
28
-			$this->newPayment( $request )
27
+			$this->newApplicant($request),
28
+			$this->newPayment($request)
29 29
 		);
30 30
 	}
31 31
 
32
-	private function newApplicant( ApplyForMembershipRequest $request ): MembershipApplicant {
32
+	private function newApplicant(ApplyForMembershipRequest $request): MembershipApplicant {
33 33
 		return new MembershipApplicant(
34
-			$this->newPersonName( $request ),
35
-			$this->newAddress( $request ),
36
-			new EmailAddress( $request->getApplicantEmailAddress() ),
37
-			new PhoneNumber( $request->getApplicantPhoneNumber() ),
38
-			( $request->getApplicantDateOfBirth() === '' ) ? null : new \DateTime( $request->getApplicantDateOfBirth() )
34
+			$this->newPersonName($request),
35
+			$this->newAddress($request),
36
+			new EmailAddress($request->getApplicantEmailAddress()),
37
+			new PhoneNumber($request->getApplicantPhoneNumber()),
38
+			($request->getApplicantDateOfBirth() === '') ? null : new \DateTime($request->getApplicantDateOfBirth())
39 39
 		);
40 40
 	}
41 41
 
42
-	private function newPersonName( ApplyForMembershipRequest $request ): ApplicantName {
43
-		$personName = $this->newBasePersonName( $request );
42
+	private function newPersonName(ApplyForMembershipRequest $request): ApplicantName {
43
+		$personName = $this->newBasePersonName($request);
44 44
 
45
-		$personName->setFirstName( $request->getApplicantFirstName() );
46
-		$personName->setLastName( $request->getApplicantLastName() );
47
-		$personName->setSalutation( $request->getApplicantSalutation() );
48
-		$personName->setTitle( $request->getApplicantTitle() );
45
+		$personName->setFirstName($request->getApplicantFirstName());
46
+		$personName->setLastName($request->getApplicantLastName());
47
+		$personName->setSalutation($request->getApplicantSalutation());
48
+		$personName->setTitle($request->getApplicantTitle());
49 49
 
50 50
 		return $personName->freeze()->assertNoNullFields();
51 51
 	}
52 52
 
53
-	private function newBasePersonName( ApplyForMembershipRequest $request ): ApplicantName {
54
-		if ( $request->isCompanyApplication() ) {
53
+	private function newBasePersonName(ApplyForMembershipRequest $request): ApplicantName {
54
+		if ($request->isCompanyApplication()) {
55 55
 			$personName = ApplicantName::newCompanyName();
56
-			$personName->setCompanyName( $request->getApplicantCompanyName() );
56
+			$personName->setCompanyName($request->getApplicantCompanyName());
57 57
 			return $personName;
58 58
 		}
59 59
 
60 60
 		return ApplicantName::newPrivatePersonName();
61 61
 	}
62 62
 
63
-	private function newAddress( ApplyForMembershipRequest $request ): PhysicalAddress {
63
+	private function newAddress(ApplyForMembershipRequest $request): PhysicalAddress {
64 64
 		$address = new PhysicalAddress();
65 65
 
66
-		$address->setCity( $request->getApplicantCity() );
67
-		$address->setCountryCode( $request->getApplicantCountryCode() );
68
-		$address->setPostalCode( $request->getApplicantPostalCode() );
69
-		$address->setStreetAddress( $request->getApplicantStreetAddress() );
66
+		$address->setCity($request->getApplicantCity());
67
+		$address->setCountryCode($request->getApplicantCountryCode());
68
+		$address->setPostalCode($request->getApplicantPostalCode());
69
+		$address->setStreetAddress($request->getApplicantStreetAddress());
70 70
 
71 71
 		return $address->freeze()->assertNoNullFields();
72 72
 	}
73 73
 
74
-	private function newPayment( ApplyForMembershipRequest $request ): MembershipPayment {
74
+	private function newPayment(ApplyForMembershipRequest $request): MembershipPayment {
75 75
 		return new MembershipPayment(
76 76
 			$request->getPaymentIntervalInMonths(),
77
-			Euro::newFromString( $request->getPaymentAmountInEuros() ),
77
+			Euro::newFromString($request->getPaymentAmountInEuros()),
78 78
 			$request->getPaymentBankData()
79 79
 		);
80 80
 	}
Please login to merge, or discard this patch.
src/DonatingContext/Domain/Model/Donor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\DonatingContext\Domain\Model;
6 6
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	private $physicalAddress;
17 17
 	private $emailAddress;
18 18
 
19
-	public function __construct( DonorName $name, PhysicalAddress $address, string $emailAddress ) {
19
+	public function __construct(DonorName $name, PhysicalAddress $address, string $emailAddress) {
20 20
 		$this->personName = $name;
21 21
 		$this->physicalAddress = $address;
22 22
 		$this->emailAddress = $emailAddress;
Please login to merge, or discard this patch.
src/DonatingContext/DataAccess/DoctrineDonationRepository.php 1 patch
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\DonatingContext\DataAccess;
6 6
 
@@ -40,113 +40,113 @@  discard block
 block discarded – undo
40 40
 
41 41
 	private $entityManager;
42 42
 
43
-	public function __construct( EntityManager $entityManager ) {
43
+	public function __construct(EntityManager $entityManager) {
44 44
 		$this->entityManager = $entityManager;
45 45
 	}
46 46
 
47
-	public function storeDonation( Donation $donation ) {
48
-		if ( $donation->getId() === null ) {
49
-			$this->insertDonation( $donation );
47
+	public function storeDonation(Donation $donation) {
48
+		if ($donation->getId() === null) {
49
+			$this->insertDonation($donation);
50 50
 		}
51 51
 		else {
52
-			$this->updateDonation( $donation );
52
+			$this->updateDonation($donation);
53 53
 		}
54 54
 	}
55 55
 
56
-	private function insertDonation( Donation $donation ) {
56
+	private function insertDonation(Donation $donation) {
57 57
 		$doctrineDonation = new DoctrineDonation();
58
-		$this->updateDonationEntity( $doctrineDonation, $donation );
58
+		$this->updateDonationEntity($doctrineDonation, $donation);
59 59
 
60 60
 		try {
61
-			$this->entityManager->persist( $doctrineDonation );
61
+			$this->entityManager->persist($doctrineDonation);
62 62
 			$this->entityManager->flush();
63 63
 		}
64
-		catch ( ORMException $ex ) {
65
-			throw new StoreDonationException( $ex );
64
+		catch (ORMException $ex) {
65
+			throw new StoreDonationException($ex);
66 66
 		}
67 67
 
68
-		$donation->assignId( $doctrineDonation->getId() );
68
+		$donation->assignId($doctrineDonation->getId());
69 69
 	}
70 70
 
71
-	private function updateDonation( Donation $donation ) {
72
-		$doctrineDonation = $this->getDoctrineDonationById( $donation->getId() );
71
+	private function updateDonation(Donation $donation) {
72
+		$doctrineDonation = $this->getDoctrineDonationById($donation->getId());
73 73
 
74
-		if ( $doctrineDonation === null ) {
74
+		if ($doctrineDonation === null) {
75 75
 			throw new StoreDonationException();
76 76
 		}
77 77
 
78
-		$this->updateDonationEntity( $doctrineDonation, $donation );
78
+		$this->updateDonationEntity($doctrineDonation, $donation);
79 79
 
80 80
 		try {
81
-			$this->entityManager->persist( $doctrineDonation );
81
+			$this->entityManager->persist($doctrineDonation);
82 82
 			$this->entityManager->flush();
83 83
 		}
84
-		catch ( ORMException $ex ) {
85
-			throw new StoreDonationException( $ex );
84
+		catch (ORMException $ex) {
85
+			throw new StoreDonationException($ex);
86 86
 		}
87 87
 	}
88 88
 
89
-	private function updateDonationEntity( DoctrineDonation $doctrineDonation, Donation $donation ) {
90
-		$doctrineDonation->setId( $donation->getId() );
91
-		$this->updatePaymentInformation( $doctrineDonation, $donation );
92
-		$this->updateDonorInformation( $doctrineDonation, $donation->getDonor() );
93
-		$this->updateComment( $doctrineDonation, $donation->getComment() );
94
-		$doctrineDonation->setDonorOptsIntoNewsletter( $donation->getOptsIntoNewsletter() );
89
+	private function updateDonationEntity(DoctrineDonation $doctrineDonation, Donation $donation) {
90
+		$doctrineDonation->setId($donation->getId());
91
+		$this->updatePaymentInformation($doctrineDonation, $donation);
92
+		$this->updateDonorInformation($doctrineDonation, $donation->getDonor());
93
+		$this->updateComment($doctrineDonation, $donation->getComment());
94
+		$doctrineDonation->setDonorOptsIntoNewsletter($donation->getOptsIntoNewsletter());
95 95
 
96
-		$doctrineDonation->encodeAndSetData( array_merge(
96
+		$doctrineDonation->encodeAndSetData(array_merge(
97 97
 			$doctrineDonation->getDecodedData(),
98
-			$this->getDataMap( $donation )
99
-		) );
98
+			$this->getDataMap($donation)
99
+		));
100 100
 	}
101 101
 
102
-	private function updatePaymentInformation( DoctrineDonation $doctrineDonation, Donation $donation ) {
103
-		$doctrineDonation->setStatus( $donation->getStatus() );
104
-		$doctrineDonation->setAmount( $donation->getAmount()->getEuroString() );
105
-		$doctrineDonation->setPaymentIntervalInMonths( $donation->getPaymentIntervalInMonths() );
102
+	private function updatePaymentInformation(DoctrineDonation $doctrineDonation, Donation $donation) {
103
+		$doctrineDonation->setStatus($donation->getStatus());
104
+		$doctrineDonation->setAmount($donation->getAmount()->getEuroString());
105
+		$doctrineDonation->setPaymentIntervalInMonths($donation->getPaymentIntervalInMonths());
106 106
 
107
-		$doctrineDonation->setPaymentType( $donation->getPaymentType() );
108
-		$doctrineDonation->setBankTransferCode( $this->getBankTransferCode( $donation->getPaymentMethod() ) );
107
+		$doctrineDonation->setPaymentType($donation->getPaymentType());
108
+		$doctrineDonation->setBankTransferCode($this->getBankTransferCode($donation->getPaymentMethod()));
109 109
 	}
110 110
 
111
-	private function updateDonorInformation( DoctrineDonation $doctrineDonation, Donor $donor = null ) {
112
-		if ( $donor === null ) {
113
-			$doctrineDonation->setDonorFullName( 'Anonym' );
111
+	private function updateDonorInformation(DoctrineDonation $doctrineDonation, Donor $donor = null) {
112
+		if ($donor === null) {
113
+			$doctrineDonation->setDonorFullName('Anonym');
114 114
 		} else {
115
-			$doctrineDonation->setDonorCity( $donor->getPhysicalAddress()->getCity() );
116
-			$doctrineDonation->setDonorEmail( $donor->getEmailAddress() );
117
-			$doctrineDonation->setDonorFullName( $donor->getPersonName()->getFullName() );
115
+			$doctrineDonation->setDonorCity($donor->getPhysicalAddress()->getCity());
116
+			$doctrineDonation->setDonorEmail($donor->getEmailAddress());
117
+			$doctrineDonation->setDonorFullName($donor->getPersonName()->getFullName());
118 118
 		}
119 119
 	}
120 120
 
121
-	private function updateComment( DoctrineDonation $doctrineDonation, DonationComment $comment = null ) {
122
-		if ( $comment === null ) {
123
-			$doctrineDonation->setIsPublic( false );
124
-			$doctrineDonation->setComment( '' );
125
-			$doctrineDonation->setPublicRecord( '' );
121
+	private function updateComment(DoctrineDonation $doctrineDonation, DonationComment $comment = null) {
122
+		if ($comment === null) {
123
+			$doctrineDonation->setIsPublic(false);
124
+			$doctrineDonation->setComment('');
125
+			$doctrineDonation->setPublicRecord('');
126 126
 		} else {
127
-			$doctrineDonation->setIsPublic( $comment->isPublic() );
128
-			$doctrineDonation->setComment( $comment->getCommentText() );
129
-			$doctrineDonation->setPublicRecord( $comment->getAuthorDisplayName() );
127
+			$doctrineDonation->setIsPublic($comment->isPublic());
128
+			$doctrineDonation->setComment($comment->getCommentText());
129
+			$doctrineDonation->setPublicRecord($comment->getAuthorDisplayName());
130 130
 		}
131 131
 	}
132 132
 
133
-	private function getBankTransferCode( PaymentMethod $paymentMethod ): string {
134
-		if ( $paymentMethod instanceof BankTransferPayment ) {
133
+	private function getBankTransferCode(PaymentMethod $paymentMethod): string {
134
+		if ($paymentMethod instanceof BankTransferPayment) {
135 135
 			return $paymentMethod->getBankTransferCode();
136 136
 		}
137 137
 
138 138
 		return '';
139 139
 	}
140 140
 
141
-	private function getDataMap( Donation $donation ): array {
141
+	private function getDataMap(Donation $donation): array {
142 142
 		return array_merge(
143
-			$this->getDataFieldsFromTrackingInfo( $donation->getTrackingInfo() ),
144
-			$this->getDataFieldsForPaymentData( $donation->getPaymentMethod() ),
145
-			$this->getDataFieldsFromDonor( $donation->getDonor() )
143
+			$this->getDataFieldsFromTrackingInfo($donation->getTrackingInfo()),
144
+			$this->getDataFieldsForPaymentData($donation->getPaymentMethod()),
145
+			$this->getDataFieldsFromDonor($donation->getDonor())
146 146
 		);
147 147
 	}
148 148
 
149
-	private function getDataFieldsFromTrackingInfo( DonationTrackingInfo $trackingInfo ): array {
149
+	private function getDataFieldsFromTrackingInfo(DonationTrackingInfo $trackingInfo): array {
150 150
 		return [
151 151
 			'layout' => $trackingInfo->getLayout(),
152 152
 			'impCount' => $trackingInfo->getTotalImpressionCount(),
@@ -158,23 +158,23 @@  discard block
 block discarded – undo
158 158
 		];
159 159
 	}
160 160
 
161
-	private function getDataFieldsForPaymentData( PaymentMethod $paymentMethod ): array {
162
-		if ( $paymentMethod instanceof DirectDebitPayment ) {
163
-			return $this->getDataFieldsFromBankData( $paymentMethod->getBankData() );
161
+	private function getDataFieldsForPaymentData(PaymentMethod $paymentMethod): array {
162
+		if ($paymentMethod instanceof DirectDebitPayment) {
163
+			return $this->getDataFieldsFromBankData($paymentMethod->getBankData());
164 164
 		}
165 165
 
166
-		if ( $paymentMethod instanceof PayPalPayment ) {
167
-			return $this->getDataFieldsFromPayPalData( $paymentMethod->getPayPalData() );
166
+		if ($paymentMethod instanceof PayPalPayment) {
167
+			return $this->getDataFieldsFromPayPalData($paymentMethod->getPayPalData());
168 168
 		}
169 169
 
170
-		if ( $paymentMethod instanceof CreditCardPayment ) {
171
-			return $this->getDataFieldsFromCreditCardData( $paymentMethod->getCreditCardData() );
170
+		if ($paymentMethod instanceof CreditCardPayment) {
171
+			return $this->getDataFieldsFromCreditCardData($paymentMethod->getCreditCardData());
172 172
 		}
173 173
 
174 174
 		return [];
175 175
 	}
176 176
 
177
-	private function getDataFieldsFromBankData( BankData $bankData ): array {
177
+	private function getDataFieldsFromBankData(BankData $bankData): array {
178 178
 		return [
179 179
 			'iban' => $bankData->getIban()->toString(),
180 180
 			'bic' => $bankData->getBic(),
@@ -184,19 +184,19 @@  discard block
 block discarded – undo
184 184
 		];
185 185
 	}
186 186
 
187
-	private function getDataFieldsFromDonor( Donor $personalInfo = null ): array {
188
-		if ( $personalInfo === null ) {
189
-			return [ 'adresstyp' => 'anonym' ];
187
+	private function getDataFieldsFromDonor(Donor $personalInfo = null): array {
188
+		if ($personalInfo === null) {
189
+			return ['adresstyp' => 'anonym'];
190 190
 		}
191 191
 
192 192
 		return array_merge(
193
-			$this->getDataFieldsFromPersonName( $personalInfo->getPersonName() ),
194
-			$this->getDataFieldsFromAddress( $personalInfo->getPhysicalAddress() ),
195
-			[ 'email' => $personalInfo->getEmailAddress() ]
193
+			$this->getDataFieldsFromPersonName($personalInfo->getPersonName()),
194
+			$this->getDataFieldsFromAddress($personalInfo->getPhysicalAddress()),
195
+			['email' => $personalInfo->getEmailAddress()]
196 196
 		);
197 197
 	}
198 198
 
199
-	private function getDataFieldsFromPersonName( DonorName $name ) {
199
+	private function getDataFieldsFromPersonName(DonorName $name) {
200 200
 		return [
201 201
 			'adresstyp' => $name->getPersonType(),
202 202
 			'anrede' => $name->getSalutation(),
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		];
208 208
 	}
209 209
 
210
-	private function getDataFieldsFromAddress( PhysicalAddress $address ) {
210
+	private function getDataFieldsFromAddress(PhysicalAddress $address) {
211 211
 		return [
212 212
 			'strasse' => $address->getStreetAddress(),
213 213
 			'plz' => $address->getPostalCode(),
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		];
217 217
 	}
218 218
 
219
-	private function getDataFieldsFromPayPalData( PayPalData $payPalData ) {
219
+	private function getDataFieldsFromPayPalData(PayPalData $payPalData) {
220 220
 		return [
221 221
 			'paypal_payer_id' => $payPalData->getPayerId(),
222 222
 			'paypal_subscr_id' => $payPalData->getSubscriberId(),
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 		];
239 239
 	}
240 240
 
241
-	private function getDataFieldsFromCreditCardData( CreditCardTransactionData $ccData ) {
241
+	private function getDataFieldsFromCreditCardData(CreditCardTransactionData $ccData) {
242 242
 		return [
243 243
 			'ext_payment_id' => $ccData->getTransactionId(),
244 244
 			'ext_payment_status' => $ccData->getTransactionStatus(),
245
-			'ext_payment_timestamp' => $ccData->getTransactionTimestamp()->format( \DateTime::ATOM ),
245
+			'ext_payment_timestamp' => $ccData->getTransactionTimestamp()->format(\DateTime::ATOM),
246 246
 			'mcp_amount' => $ccData->getAmount()->getEuroString(),
247 247
 			'ext_payment_account' => $ccData->getCustomerId(),
248 248
 			'mcp_sessionid' => $ccData->getSessionId(),
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 			'mcp_title' => $ccData->getTitle(),
251 251
 			'mcp_country' => $ccData->getCountryCode(),
252 252
 			'mcp_currency' => $ccData->getCurrencyCode(),
253
-			'mcp_cc_expiry_date' => $this->getExpirationDateAsString( $ccData->getCardExpiry() )
253
+			'mcp_cc_expiry_date' => $this->getExpirationDateAsString($ccData->getCardExpiry())
254 254
 		];
255 255
 	}
256 256
 
257
-	private function getExpirationDateAsString( CreditCardExpiry $cardExpiry = null ): string {
258
-		if ( $cardExpiry === null ) {
257
+	private function getExpirationDateAsString(CreditCardExpiry $cardExpiry = null): string {
258
+		if ($cardExpiry === null) {
259 259
 			return '';
260 260
 		}
261 261
 
262
-		return implode( '/', [ $cardExpiry->getMonth(), $cardExpiry->getYear() ] );
262
+		return implode('/', [$cardExpiry->getMonth(), $cardExpiry->getYear()]);
263 263
 	}
264 264
 
265 265
 	/**
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	 * @return \WMDE\Fundraising\Frontend\DonatingContext\Domain\Model\Donation|null
269 269
 	 * @throws GetDonationException
270 270
 	 */
271
-	public function getDonationById( int $id ) {
271
+	public function getDonationById(int $id) {
272 272
 		try {
273
-			$donation = $this->getDoctrineDonationById( $id );
273
+			$donation = $this->getDoctrineDonationById($id);
274 274
 		}
275
-		catch ( ORMException $ex ) {
276
-			throw new GetDonationException( $ex );
275
+		catch (ORMException $ex) {
276
+			throw new GetDonationException($ex);
277 277
 		}
278 278
 
279
-		if ( $donation === null ) {
279
+		if ($donation === null) {
280 280
 			return null;
281 281
 		}
282 282
 
283
-		return $this->newDonationDomainObject( $donation );
283
+		return $this->newDonationDomainObject($donation);
284 284
 	}
285 285
 
286 286
 	/**
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
 	 * @return DoctrineDonation|null
289 289
 	 * @throws ORMException
290 290
 	 */
291
-	public function getDoctrineDonationById( int $id ) {
292
-		return $this->entityManager->getRepository( DoctrineDonation::class )->findOneBy( [
291
+	public function getDoctrineDonationById(int $id) {
292
+		return $this->entityManager->getRepository(DoctrineDonation::class)->findOneBy([
293 293
 			'id' => $id,
294 294
 			'deletionTime' => null
295
-		] );
295
+		]);
296 296
 	}
297 297
 
298
-	private function newDonationDomainObject( DoctrineDonation $dd ): Donation {
298
+	private function newDonationDomainObject(DoctrineDonation $dd): Donation {
299 299
 		return new Donation(
300 300
 			$dd->getId(),
301 301
 			$dd->getStatus(),
302
-			$this->getDonorFromEntity( $dd ),
303
-			$this->getPaymentFromEntity( $dd ),
302
+			$this->getDonorFromEntity($dd),
303
+			$this->getPaymentFromEntity($dd),
304 304
 			(bool)$dd->getDonorOptsIntoNewsletter(),
305
-			$this->getTrackingInfoFromEntity( $dd ),
306
-			$this->getCommentFromEntity( $dd )
305
+			$this->getTrackingInfoFromEntity($dd),
306
+			$this->getCommentFromEntity($dd)
307 307
 		);
308 308
 	}
309 309
 
@@ -312,70 +312,70 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return \WMDE\Fundraising\Frontend\DonatingContext\Domain\Model\Donor|null
314 314
 	 */
315
-	private function getDonorFromEntity( DoctrineDonation $dd ) {
316
-		if ( $dd->getDonorEmail() === null ) {
315
+	private function getDonorFromEntity(DoctrineDonation $dd) {
316
+		if ($dd->getDonorEmail() === null) {
317 317
 			return null;
318 318
 		}
319 319
 
320 320
 		return new Donor(
321
-			$this->getPersonNameFromEntity( $dd ),
322
-			$this->getPhysicalAddressFromEntity( $dd ),
321
+			$this->getPersonNameFromEntity($dd),
322
+			$this->getPhysicalAddressFromEntity($dd),
323 323
 			$dd->getDonorEmail()
324 324
 		);
325 325
 	}
326 326
 
327
-	private function getPaymentFromEntity( DoctrineDonation $dd ): DonationPayment {
327
+	private function getPaymentFromEntity(DoctrineDonation $dd): DonationPayment {
328 328
 		return new DonationPayment(
329
-			Euro::newFromString( $dd->getAmount() ),
329
+			Euro::newFromString($dd->getAmount()),
330 330
 			$dd->getPaymentIntervalInMonths(),
331
-			$this->getPaymentMethodFromEntity( $dd )
331
+			$this->getPaymentMethodFromEntity($dd)
332 332
 		);
333 333
 	}
334 334
 
335
-	private function getPaymentMethodFromEntity( DoctrineDonation $dd ): PaymentMethod {
336
-		if ( $dd->getPaymentType() === PaymentType::BANK_TRANSFER ) {
337
-			return new BankTransferPayment( $dd->getBankTransferCode() );
335
+	private function getPaymentMethodFromEntity(DoctrineDonation $dd): PaymentMethod {
336
+		if ($dd->getPaymentType() === PaymentType::BANK_TRANSFER) {
337
+			return new BankTransferPayment($dd->getBankTransferCode());
338 338
 		}
339 339
 
340
-		if ( $dd->getPaymentType() === PaymentType::DIRECT_DEBIT ) {
341
-			return new DirectDebitPayment( $this->getBankDataFromEntity( $dd ) );
340
+		if ($dd->getPaymentType() === PaymentType::DIRECT_DEBIT) {
341
+			return new DirectDebitPayment($this->getBankDataFromEntity($dd));
342 342
 		}
343 343
 
344
-		if ( $dd->getPaymentType() === PaymentType::PAYPAL ) {
345
-			return new PayPalPayment( $this->getPayPalDataFromEntity( $dd ) );
344
+		if ($dd->getPaymentType() === PaymentType::PAYPAL) {
345
+			return new PayPalPayment($this->getPayPalDataFromEntity($dd));
346 346
 		}
347 347
 
348
-		if ( $dd->getPaymentType() === PaymentType::CREDIT_CARD ) {
349
-			return new CreditCardPayment( $this->getCreditCardDataFromEntity( $dd ) );
348
+		if ($dd->getPaymentType() === PaymentType::CREDIT_CARD) {
349
+			return new CreditCardPayment($this->getCreditCardDataFromEntity($dd));
350 350
 		}
351 351
 
352
-		return new PaymentWithoutAssociatedData( $dd->getPaymentType() );
352
+		return new PaymentWithoutAssociatedData($dd->getPaymentType());
353 353
 	}
354 354
 
355
-	private function getPersonNameFromEntity( DoctrineDonation $dd ): DonorName {
355
+	private function getPersonNameFromEntity(DoctrineDonation $dd): DonorName {
356 356
 		$data = $dd->getDecodedData();
357 357
 
358 358
 		$name = $data['adresstyp'] === DonorName::PERSON_COMPANY
359 359
 			? DonorName::newCompanyName() : DonorName::newPrivatePersonName();
360 360
 
361
-		$name->setSalutation( $data['anrede'] );
362
-		$name->setTitle( $data['titel'] );
363
-		$name->setFirstName( $data['vorname'] );
364
-		$name->setLastName( $data['nachname'] );
365
-		$name->setCompanyName( $data['firma'] );
361
+		$name->setSalutation($data['anrede']);
362
+		$name->setTitle($data['titel']);
363
+		$name->setFirstName($data['vorname']);
364
+		$name->setLastName($data['nachname']);
365
+		$name->setCompanyName($data['firma']);
366 366
 
367 367
 		return $name->freeze()->assertNoNullFields();
368 368
 	}
369 369
 
370
-	private function getPhysicalAddressFromEntity( DoctrineDonation $dd ): PhysicalAddress {
370
+	private function getPhysicalAddressFromEntity(DoctrineDonation $dd): PhysicalAddress {
371 371
 		$data = $dd->getDecodedData();
372 372
 
373 373
 		$address = new PhysicalAddress();
374 374
 
375
-		$address->setStreetAddress( $data['strasse'] );
376
-		$address->setCity( $data['ort'] );
377
-		$address->setPostalCode( $data['plz'] );
378
-		$address->setCountryCode( $data['country'] );
375
+		$address->setStreetAddress($data['strasse']);
376
+		$address->setCity($data['ort']);
377
+		$address->setPostalCode($data['plz']);
378
+		$address->setCountryCode($data['country']);
379 379
 
380 380
 		return $address->freeze()->assertNoNullFields();
381 381
 	}
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 *@return \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\BankData|null
387 387
 	 */
388
-	private function getBankDataFromEntity( DoctrineDonation $dd ) {
388
+	private function getBankDataFromEntity(DoctrineDonation $dd) {
389 389
 		$data = $dd->getDecodedData();
390 390
 
391
-		if ( array_key_exists( 'iban', $data ) ) {
391
+		if (array_key_exists('iban', $data)) {
392 392
 			$bankData = new BankData();
393 393
 
394
-			$bankData->setIban( new Iban( $data['iban'] ) );
395
-			$bankData->setBic( $data['bic'] );
396
-			$bankData->setAccount( $data['konto'] );
397
-			$bankData->setBankCode( $data['blz'] );
398
-			$bankData->setBankName( $data['bankname'] );
394
+			$bankData->setIban(new Iban($data['iban']));
395
+			$bankData->setBic($data['bic']);
396
+			$bankData->setAccount($data['konto']);
397
+			$bankData->setBankCode($data['blz']);
398
+			$bankData->setBankName($data['bankname']);
399 399
 
400 400
 			return $bankData->freeze()->assertNoNullFields();
401 401
 		}
@@ -403,18 +403,18 @@  discard block
 block discarded – undo
403 403
 		return null;
404 404
 	}
405 405
 
406
-	private function getTrackingInfoFromEntity( DoctrineDonation $dd ): DonationTrackingInfo {
406
+	private function getTrackingInfoFromEntity(DoctrineDonation $dd): DonationTrackingInfo {
407 407
 		$data = $dd->getDecodedData();
408 408
 
409 409
 		$trackingInfo = new DonationTrackingInfo();
410 410
 
411
-		$trackingInfo->setLayout( $data['layout'] );
412
-		$trackingInfo->setTotalImpressionCount( $data['impCount'] );
413
-		$trackingInfo->setSingleBannerImpressionCount( $data['bImpCount'] );
414
-		$trackingInfo->setTracking( $data['tracking'] );
415
-		$trackingInfo->setSkin( $data['skin'] );
416
-		$trackingInfo->setColor( $data['color'] );
417
-		$trackingInfo->setSource( $data['source'] );
411
+		$trackingInfo->setLayout($data['layout']);
412
+		$trackingInfo->setTotalImpressionCount($data['impCount']);
413
+		$trackingInfo->setSingleBannerImpressionCount($data['bImpCount']);
414
+		$trackingInfo->setTracking($data['tracking']);
415
+		$trackingInfo->setSkin($data['skin']);
416
+		$trackingInfo->setColor($data['color']);
417
+		$trackingInfo->setSource($data['source']);
418 418
 
419 419
 		return $trackingInfo->freeze()->assertNoNullFields();
420 420
 	}
@@ -423,26 +423,26 @@  discard block
 block discarded – undo
423 423
 	 * @param DoctrineDonation $dd
424 424
 	 * @return PayPalData|null
425 425
 	 */
426
-	private function getPayPalDataFromEntity( DoctrineDonation $dd ) {
426
+	private function getPayPalDataFromEntity(DoctrineDonation $dd) {
427 427
 		$data = $dd->getDecodedData();
428 428
 
429
-		if ( array_key_exists( 'paypal_payer_id', $data ) ) {
430
-			return ( new PayPalData() )
431
-				->setPayerId( $data['paypal_payer_id'] )
432
-				->setSubscriberId( $data['paypal_subscr_id'] )
433
-				->setPayerStatus( $data['paypal_payer_status'] )
434
-				->setAddressStatus( $data['paypal_address_status'] )
435
-				->setAmount( Euro::newFromString( $data['paypal_mc_gross'] ) )
436
-				->setCurrencyCode( $data['paypal_mc_currency'] )
437
-				->setFee( Euro::newFromString( $data['paypal_mc_fee'] ) )
438
-				->setSettleAmount( Euro::newFromString( $data['paypal_settle_amount'] ) )
439
-				->setFirstName( $data['paypal_first_name'] )
440
-				->setLastName( $data['paypal_last_name'] )
441
-				->setAddressName( $data['paypal_address_name'] )
442
-				->setPaymentId( $data['ext_payment_id'] )
443
-				->setPaymentType( $data['ext_payment_type'] )
444
-				->setPaymentStatus( $data['ext_payment_status'] )
445
-				->setPaymentTimestamp( $data['ext_payment_timestamp'] )
429
+		if (array_key_exists('paypal_payer_id', $data)) {
430
+			return (new PayPalData())
431
+				->setPayerId($data['paypal_payer_id'])
432
+				->setSubscriberId($data['paypal_subscr_id'])
433
+				->setPayerStatus($data['paypal_payer_status'])
434
+				->setAddressStatus($data['paypal_address_status'])
435
+				->setAmount(Euro::newFromString($data['paypal_mc_gross']))
436
+				->setCurrencyCode($data['paypal_mc_currency'])
437
+				->setFee(Euro::newFromString($data['paypal_mc_fee']))
438
+				->setSettleAmount(Euro::newFromString($data['paypal_settle_amount']))
439
+				->setFirstName($data['paypal_first_name'])
440
+				->setLastName($data['paypal_last_name'])
441
+				->setAddressName($data['paypal_address_name'])
442
+				->setPaymentId($data['ext_payment_id'])
443
+				->setPaymentType($data['ext_payment_type'])
444
+				->setPaymentStatus($data['ext_payment_status'])
445
+				->setPaymentTimestamp($data['ext_payment_timestamp'])
446 446
 				->freeze()->assertNoNullFields();
447 447
 		}
448 448
 
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
 	 * @param DoctrineDonation $dd
454 454
 	 * @return CreditCardTransactionData|null
455 455
 	 */
456
-	private function getCreditCardDataFromEntity( DoctrineDonation $dd ) {
456
+	private function getCreditCardDataFromEntity(DoctrineDonation $dd) {
457 457
 		$data = $dd->getDecodedData();
458 458
 
459
-		if ( array_key_exists( 'mcp_auth', $data ) ) {
460
-			return ( new CreditCardTransactionData() )
461
-				->setTransactionId( $data['ext_payment_id'] )
462
-				->setTransactionStatus( $data['ext_payment_status'] )
463
-				->setTransactionTimestamp( new \DateTime( $data['ext_payment_timestamp'] ) )
464
-				->setAmount( Euro::newFromString( $data['mcp_amount'] ) )
465
-				->setCustomerId( $data['ext_payment_account'] )
466
-				->setSessionId( $data['mcp_sessionid'] )
467
-				->setAuthId( $data['mcp_auth'] )
468
-				->setCardExpiry( CreditCardExpiry::newFromString( $data['mcp_cc_expiry_date'] ) )
469
-				->setTitle( $data['mcp_title'] )
470
-				->setCountryCode( $data['mcp_country'] )
471
-				->setCurrencyCode( $data['mcp_currency'] )
459
+		if (array_key_exists('mcp_auth', $data)) {
460
+			return (new CreditCardTransactionData())
461
+				->setTransactionId($data['ext_payment_id'])
462
+				->setTransactionStatus($data['ext_payment_status'])
463
+				->setTransactionTimestamp(new \DateTime($data['ext_payment_timestamp']))
464
+				->setAmount(Euro::newFromString($data['mcp_amount']))
465
+				->setCustomerId($data['ext_payment_account'])
466
+				->setSessionId($data['mcp_sessionid'])
467
+				->setAuthId($data['mcp_auth'])
468
+				->setCardExpiry(CreditCardExpiry::newFromString($data['mcp_cc_expiry_date']))
469
+				->setTitle($data['mcp_title'])
470
+				->setCountryCode($data['mcp_country'])
471
+				->setCurrencyCode($data['mcp_currency'])
472 472
 				->freeze();
473 473
 		}
474 474
 
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param DoctrineDonation $dd
480 480
 	 * @return DonationComment|null
481 481
 	 */
482
-	private function getCommentFromEntity( DoctrineDonation $dd ) {
483
-		if ( $dd->getComment() === '' ) {
482
+	private function getCommentFromEntity(DoctrineDonation $dd) {
483
+		if ($dd->getComment() === '') {
484 484
 			return null;
485 485
 		}
486 486
 
Please login to merge, or discard this patch.
HandlePayPalPaymentNotification/HandlePayPalPaymentNotificationUseCase.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\DonatingContext\UseCases\HandlePayPalPaymentNotification;
6 6
 
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	private $logger;
34 34
 	private $donationEventLogger;
35 35
 
36
-	public function __construct( DonationRepository $repository, DonationAuthorizer $authorizationService,
36
+	public function __construct(DonationRepository $repository, DonationAuthorizer $authorizationService,
37 37
 								 DonationConfirmationMailer $mailer, LoggerInterface $logger,
38
-								 DonationEventLogger $donationEventLogger ) {
38
+								 DonationEventLogger $donationEventLogger) {
39 39
 		$this->repository = $repository;
40 40
 		$this->authorizationService = $authorizationService;
41 41
 		$this->mailer = $mailer;
@@ -43,189 +43,189 @@  discard block
 block discarded – undo
43 43
 		$this->donationEventLogger = $donationEventLogger;
44 44
 	}
45 45
 
46
-	public function handleNotification( PayPalNotificationRequest $request ): bool {
47
-		if ( !$this->requestCanBeHandled( $request ) ) {
46
+	public function handleNotification(PayPalNotificationRequest $request): bool {
47
+		if (!$this->requestCanBeHandled($request)) {
48 48
 			return false;
49 49
 		}
50 50
 
51 51
 		try {
52
-			$donation = $this->repository->getDonationById( $request->getDonationId() );
53
-		} catch ( GetDonationException $ex ) {
52
+			$donation = $this->repository->getDonationById($request->getDonationId());
53
+		} catch (GetDonationException $ex) {
54 54
 			return false;
55 55
 		}
56 56
 
57
-		if ( $donation === null ) {
58
-			return $this->handleRequestWithoutDonation( $request );
57
+		if ($donation === null) {
58
+			return $this->handleRequestWithoutDonation($request);
59 59
 		}
60 60
 
61
-		if ( $donation->isBooked() && $request->isRecurringPaymentCompletion() ) {
62
-			return $this->handleRequestWithoutDonation( $request );
61
+		if ($donation->isBooked() && $request->isRecurringPaymentCompletion()) {
62
+			return $this->handleRequestWithoutDonation($request);
63 63
 		}
64 64
 
65
-		return $this->handleRequestForDonation( $request, $donation );
65
+		return $this->handleRequestForDonation($request, $donation);
66 66
 	}
67 67
 
68
-	private function requestCanBeHandled( PayPalNotificationRequest $request ): bool {
69
-		if ( !$request->isSuccessfulPaymentNotification() ) {
70
-			$this->logUnhandledStatus( $request );
68
+	private function requestCanBeHandled(PayPalNotificationRequest $request): bool {
69
+		if (!$request->isSuccessfulPaymentNotification()) {
70
+			$this->logUnhandledStatus($request);
71 71
 			return false;
72 72
 		}
73 73
 
74
-		if ( $this->transactionIsSubscriptionRelatedButNotAPayment( $request ) ) {
75
-			$this->logUnhandledNonPayment( $request );
74
+		if ($this->transactionIsSubscriptionRelatedButNotAPayment($request)) {
75
+			$this->logUnhandledNonPayment($request);
76 76
 			return false;
77 77
 		}
78 78
 		return true;
79 79
 	}
80 80
 
81
-	private function handleRequestWithoutDonation( PayPalNotificationRequest $request ): bool {
82
-		$donation = $this->newDonationFromRequest( $request );
81
+	private function handleRequestWithoutDonation(PayPalNotificationRequest $request): bool {
82
+		$donation = $this->newDonationFromRequest($request);
83 83
 
84 84
 		try {
85
-			$this->repository->storeDonation( $donation );
86
-		} catch ( StoreDonationException $ex ) {
85
+			$this->repository->storeDonation($donation);
86
+		} catch (StoreDonationException $ex) {
87 87
 			return false;
88 88
 		}
89 89
 
90
-		$this->sendConfirmationEmailFor( $donation );
91
-		$this->donationEventLogger->log( $donation->getId(), 'paypal_handler: booked' );
90
+		$this->sendConfirmationEmailFor($donation);
91
+		$this->donationEventLogger->log($donation->getId(), 'paypal_handler: booked');
92 92
 
93 93
 		return true;
94 94
 	}
95 95
 
96
-	private function handleRequestForDonation( PayPalNotificationRequest $request, Donation $donation ): bool {
97
-		if ( !( $donation->getPayment()->getPaymentMethod() instanceof PayPalPayment ) ) {
96
+	private function handleRequestForDonation(PayPalNotificationRequest $request, Donation $donation): bool {
97
+		if (!($donation->getPayment()->getPaymentMethod() instanceof PayPalPayment)) {
98 98
 			return false;
99 99
 		}
100 100
 
101
-		if ( !$this->authorizationService->systemCanModifyDonation( $request->getDonationId() ) ) {
101
+		if (!$this->authorizationService->systemCanModifyDonation($request->getDonationId())) {
102 102
 			return false;
103 103
 		}
104
-		if ( $this->donationWasBookedWithDifferentTransactionId( $donation, $request ) ) {
105
-			$childDonation = $this->createChildDonation( $donation, $request );
104
+		if ($this->donationWasBookedWithDifferentTransactionId($donation, $request)) {
105
+			$childDonation = $this->createChildDonation($donation, $request);
106 106
 			return $childDonation !== null;
107 107
 		}
108 108
 
109
-		$donation->addPayPalData( $this->newPayPalDataFromRequest( $request ) );
109
+		$donation->addPayPalData($this->newPayPalDataFromRequest($request));
110 110
 
111 111
 		try {
112 112
 			$donation->confirmBooked();
113
-		} catch ( \RuntimeException $ex ) {
113
+		} catch (\RuntimeException $ex) {
114 114
 			return false;
115 115
 		}
116 116
 
117 117
 		try {
118
-			$this->repository->storeDonation( $donation );
118
+			$this->repository->storeDonation($donation);
119 119
 		}
120
-		catch ( StoreDonationException $ex ) {
120
+		catch (StoreDonationException $ex) {
121 121
 			return false;
122 122
 		}
123 123
 
124
-		$this->sendConfirmationEmailFor( $donation );
125
-		$this->donationEventLogger->log( $donation->getId(), 'paypal_handler: booked' );
124
+		$this->sendConfirmationEmailFor($donation);
125
+		$this->donationEventLogger->log($donation->getId(), 'paypal_handler: booked');
126 126
 
127 127
 		return true;
128 128
 	}
129 129
 
130
-	private function logUnhandledStatus( PayPalNotificationRequest $request ) {
130
+	private function logUnhandledStatus(PayPalNotificationRequest $request) {
131 131
 		$logContext = [
132 132
 			'payment_status' => $request->getPaymentStatus(),
133 133
 			'txn_id' => $request->getTransactionId()
134 134
 		];
135
-		$this->logger->info( 'Unhandled PayPal notification: ' . $request->getPaymentStatus(), $logContext );
135
+		$this->logger->info('Unhandled PayPal notification: ' . $request->getPaymentStatus(), $logContext);
136 136
 	}
137 137
 
138
-	private function logUnhandledNonPayment( PayPalNotificationRequest $request ) {
138
+	private function logUnhandledNonPayment(PayPalNotificationRequest $request) {
139 139
 		$logContext = [
140 140
 			'transaction_type' => $request->getTransactionType(),
141 141
 			'txn_id' => $request->getTransactionId()
142 142
 		];
143
-		$this->logger->info( 'Unhandled PayPal subscription notification: ' . $request->getTransactionType(), $logContext );
143
+		$this->logger->info('Unhandled PayPal subscription notification: ' . $request->getTransactionType(), $logContext);
144 144
 	}
145 145
 
146
-	private function sendConfirmationEmailFor( Donation $donation ) {
147
-		if ( $donation->getDonor() !== null ) {
146
+	private function sendConfirmationEmailFor(Donation $donation) {
147
+		if ($donation->getDonor() !== null) {
148 148
 			try {
149
-				$this->mailer->sendConfirmationMailFor( $donation );
150
-			} catch ( \RuntimeException $ex ) {
149
+				$this->mailer->sendConfirmationMailFor($donation);
150
+			} catch (\RuntimeException $ex) {
151 151
 				// no need to re-throw or return false, this is not a fatal error, only a minor inconvenience
152 152
 			}
153 153
 		}
154 154
 	}
155 155
 
156
-	private function transactionIsSubscriptionRelatedButNotAPayment( PayPalNotificationRequest $request ): bool {
156
+	private function transactionIsSubscriptionRelatedButNotAPayment(PayPalNotificationRequest $request): bool {
157 157
 		return $request->isForRecurringPayment() && !$request->isRecurringPaymentCompletion();
158 158
 	}
159 159
 
160
-	private function newPayPalDataFromRequest( PayPalNotificationRequest $request ): PayPalData {
161
-		return ( new PayPalData() )
162
-			->setPayerId( $request->getPayerId() )
163
-			->setSubscriberId( $request->getSubscriberId() )
164
-			->setPayerStatus( $request->getPayerStatus() )
165
-			->setAddressStatus( $request->getPayerAddressStatus() )
166
-			->setAmount( $request->getAmountGross() )
167
-			->setCurrencyCode( $request->getCurrencyCode() )
168
-			->setFee( $request->getTransactionFee() )
169
-			->setSettleAmount( $request->getSettleAmount() )
170
-			->setFirstName( $request->getPayerFirstName() )
171
-			->setLastName( $request->getPayerLastName() )
172
-			->setAddressName( $request->getPayerAddressName() )
173
-			->setPaymentId( $request->getTransactionId() )
174
-			->setPaymentType( $request->getPaymentType() )
175
-			->setPaymentStatus( implode( '/', [ $request->getPaymentStatus(), $request->getTransactionType() ] ) )
176
-			->setPaymentTimestamp( $request->getPaymentTimestamp() );
160
+	private function newPayPalDataFromRequest(PayPalNotificationRequest $request): PayPalData {
161
+		return (new PayPalData())
162
+			->setPayerId($request->getPayerId())
163
+			->setSubscriberId($request->getSubscriberId())
164
+			->setPayerStatus($request->getPayerStatus())
165
+			->setAddressStatus($request->getPayerAddressStatus())
166
+			->setAmount($request->getAmountGross())
167
+			->setCurrencyCode($request->getCurrencyCode())
168
+			->setFee($request->getTransactionFee())
169
+			->setSettleAmount($request->getSettleAmount())
170
+			->setFirstName($request->getPayerFirstName())
171
+			->setLastName($request->getPayerLastName())
172
+			->setAddressName($request->getPayerAddressName())
173
+			->setPaymentId($request->getTransactionId())
174
+			->setPaymentType($request->getPaymentType())
175
+			->setPaymentStatus(implode('/', [$request->getPaymentStatus(), $request->getTransactionType()]))
176
+			->setPaymentTimestamp($request->getPaymentTimestamp());
177 177
 	}
178 178
 
179
-	private function donationWasBookedWithDifferentTransactionId( Donation $donation,
180
-																  PayPalNotificationRequest $request ): bool {
179
+	private function donationWasBookedWithDifferentTransactionId(Donation $donation,
180
+																  PayPalNotificationRequest $request): bool {
181 181
 		/**
182 182
 		 * @var PayPalPayment $payment
183 183
 		 */
184 184
 		$payment = $donation->getPaymentMethod();
185 185
 
186
-		if ( !$donation->isBooked() ) {
186
+		if (!$donation->isBooked()) {
187 187
 			return false;
188 188
 		}
189 189
 
190
-		if ( $request->getTransactionId() === $payment->getPayPalData()->getPaymentId() ) {
190
+		if ($request->getTransactionId() === $payment->getPayPalData()->getPaymentId()) {
191 191
 			return false;
192 192
 		}
193 193
 
194
-		if ( $payment->getPayPalData()->hasChildPayment( $request->getTransactionId() ) ) {
194
+		if ($payment->getPayPalData()->hasChildPayment($request->getTransactionId())) {
195 195
 			return false;
196 196
 		}
197 197
 
198 198
 		return true;
199 199
 	}
200 200
 
201
-	private function createChildDonation( Donation $donation, PayPalNotificationRequest $request ) {
202
-		$childPaymentMethod = new PayPalPayment( $this->newPayPalDataFromRequest( $request ) );
201
+	private function createChildDonation(Donation $donation, PayPalNotificationRequest $request) {
202
+		$childPaymentMethod = new PayPalPayment($this->newPayPalDataFromRequest($request));
203 203
 		$payment = $donation->getPayment();
204 204
 		$childDonation = new Donation(
205 205
 			null,
206 206
 			Donation::STATUS_EXTERNAL_BOOKED,
207 207
 			$donation->getDonor(),
208
-			new DonationPayment( $payment->getAmount(), $payment->getIntervalInMonths(), $childPaymentMethod ),
208
+			new DonationPayment($payment->getAmount(), $payment->getIntervalInMonths(), $childPaymentMethod),
209 209
 			$donation->getOptsIntoNewsletter(), $donation->getTrackingInfo()
210 210
 		);
211 211
 		try {
212
-			$this->repository->storeDonation( $childDonation );
213
-		} catch ( StoreDonationException $ex ) {
212
+			$this->repository->storeDonation($childDonation);
213
+		} catch (StoreDonationException $ex) {
214 214
 			return null;
215 215
 		}
216 216
 		/** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $paymentMethod */
217 217
 		$paymentMethod = $payment->getPaymentMethod();
218
-		$paymentMethod->getPayPalData()->addChildPayment( $request->getTransactionId(), $childDonation->getId() );
218
+		$paymentMethod->getPayPalData()->addChildPayment($request->getTransactionId(), $childDonation->getId());
219 219
 		try {
220
-			$this->repository->storeDonation( $donation );
221
-		} catch ( StoreDonationException $ex ) {
220
+			$this->repository->storeDonation($donation);
221
+		} catch (StoreDonationException $ex) {
222 222
 			return null;
223 223
 		}
224
-		$this->logChildDonationCreatedEvent( $donation->getId(), $childDonation->getId() );
224
+		$this->logChildDonationCreatedEvent($donation->getId(), $childDonation->getId());
225 225
 		return $childDonation;
226 226
 	}
227 227
 
228
-	private function logChildDonationCreatedEvent( $parentId, $childId ) {
228
+	private function logChildDonationCreatedEvent($parentId, $childId) {
229 229
 		$this->donationEventLogger->log(
230 230
 			$parentId,
231 231
 			"paypal_handler: new transaction id to corresponding child donation: $childId"
@@ -236,43 +236,43 @@  discard block
 block discarded – undo
236 236
 		);
237 237
 	}
238 238
 
239
-	private function newDonorFromRequest( PayPalNotificationRequest $request ): Donor {
239
+	private function newDonorFromRequest(PayPalNotificationRequest $request): Donor {
240 240
 		return new Donor(
241
-			$this->newPersonNameFromRequest( $request ),
242
-			$this->newPhysicalAddressFromRequest( $request ),
241
+			$this->newPersonNameFromRequest($request),
242
+			$this->newPhysicalAddressFromRequest($request),
243 243
 			$request->getPayerEmail()
244 244
 		);
245 245
 	}
246 246
 
247
-	private function newPersonNameFromRequest( PayPalNotificationRequest $request ): DonorName {
247
+	private function newPersonNameFromRequest(PayPalNotificationRequest $request): DonorName {
248 248
 		$name = DonorName::newPrivatePersonName();
249
-		$name->setFirstName( $request->getPayerFirstName() );
250
-		$name->setLastName( $request->getPayerLastName() );
249
+		$name->setFirstName($request->getPayerFirstName());
250
+		$name->setLastName($request->getPayerLastName());
251 251
 		$name->freeze();
252 252
 		return $name;
253 253
 	}
254 254
 
255
-	private function newPhysicalAddressFromRequest( PayPalNotificationRequest $request ): PhysicalAddress {
255
+	private function newPhysicalAddressFromRequest(PayPalNotificationRequest $request): PhysicalAddress {
256 256
 		$address = new PhysicalAddress();
257
-		$address->setStreetAddress( $request->getPayerAddressStreet() );
258
-		$address->setCity( $request->getPayerAddressCity() );
259
-		$address->setPostalCode( $request->getPayerAddressPostalCode() );
260
-		$address->setCountryCode( $request->getPayerAddressCountryCode() );
257
+		$address->setStreetAddress($request->getPayerAddressStreet());
258
+		$address->setCity($request->getPayerAddressCity());
259
+		$address->setPostalCode($request->getPayerAddressPostalCode());
260
+		$address->setCountryCode($request->getPayerAddressCountryCode());
261 261
 		$address->freeze();
262 262
 		return $address;
263 263
 	}
264 264
 
265
-	private function newDonationFromRequest( PayPalNotificationRequest $request ): Donation {
266
-		$payment = new DonationPayment( $request->getAmountGross(), 0, new PayPalPayment() );
265
+	private function newDonationFromRequest(PayPalNotificationRequest $request): Donation {
266
+		$payment = new DonationPayment($request->getAmountGross(), 0, new PayPalPayment());
267 267
 		$donation = new Donation(
268 268
 			null,
269 269
 			Donation::STATUS_EXTERNAL_BOOKED,
270
-			$this->newDonorFromRequest( $request ),
270
+			$this->newDonorFromRequest($request),
271 271
 			$payment,
272 272
 			Donation::DOES_NOT_OPT_INTO_NEWSLETTER,
273 273
 			new DonationTrackingInfo()
274 274
 		);
275
-		$donation->addPayPalData( $this->newPayPalDataFromRequest( $request ) );
275
+		$donation->addPayPalData($this->newPayPalDataFromRequest($request));
276 276
 		return $donation;
277 277
 	}
278 278
 }
Please login to merge, or discard this patch.
src/DonatingContext/UseCases/AddDonation/AddDonationUseCase.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\DonatingContext\UseCases\AddDonation;
6 6
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 	private $transferCodeGenerator;
38 38
 	private $tokenFetcher;
39 39
 
40
-	public function __construct( DonationRepository $donationRepository, AddDonationValidator $donationValidator,
40
+	public function __construct(DonationRepository $donationRepository, AddDonationValidator $donationValidator,
41 41
 								 AddDonationPolicyValidator $policyValidator, ReferrerGeneralizer $referrerGeneralizer,
42 42
 								 DonationConfirmationMailer $mailer, TransferCodeGenerator $transferCodeGenerator,
43
-								 DonationTokenFetcher $tokenFetcher ) {
43
+								 DonationTokenFetcher $tokenFetcher) {
44 44
 		$this->donationRepository = $donationRepository;
45 45
 		$this->donationValidator = $donationValidator;
46 46
 		$this->policyValidator = $policyValidator;
@@ -51,26 +51,26 @@  discard block
 block discarded – undo
51 51
 		$this->tokenFetcher = $tokenFetcher;
52 52
 	}
53 53
 
54
-	public function addDonation( AddDonationRequest $donationRequest ): AddDonationResponse {
55
-		$validationResult = $this->donationValidator->validate( $donationRequest );
54
+	public function addDonation(AddDonationRequest $donationRequest): AddDonationResponse {
55
+		$validationResult = $this->donationValidator->validate($donationRequest);
56 56
 
57
-		if ( $validationResult->hasViolations() ) {
58
-			return AddDonationResponse::newFailureResponse( $validationResult->getViolations() );
57
+		if ($validationResult->hasViolations()) {
58
+			return AddDonationResponse::newFailureResponse($validationResult->getViolations());
59 59
 		}
60 60
 
61
-		$donation = $this->newDonationFromRequest( $donationRequest );
61
+		$donation = $this->newDonationFromRequest($donationRequest);
62 62
 
63
-		if ( $this->policyValidator->needsModeration( $donationRequest ) ) {
63
+		if ($this->policyValidator->needsModeration($donationRequest)) {
64 64
 			$donation->markForModeration();
65 65
 		}
66 66
 
67 67
 		// TODO: handle exceptions
68
-		$this->donationRepository->storeDonation( $donation );
68
+		$this->donationRepository->storeDonation($donation);
69 69
 
70 70
 		// TODO: handle exceptions
71
-		$tokens = $this->tokenFetcher->getTokens( $donation->getId() );
71
+		$tokens = $this->tokenFetcher->getTokens($donation->getId());
72 72
 
73
-		$this->sendDonationConfirmationEmail( $donation );
73
+		$this->sendDonationConfirmationEmail($donation);
74 74
 
75 75
 		return AddDonationResponse::newSuccessResponse(
76 76
 			$donation,
@@ -79,97 +79,97 @@  discard block
 block discarded – undo
79 79
 		);
80 80
 	}
81 81
 
82
-	private function newDonationFromRequest( AddDonationRequest $donationRequest ): Donation {
82
+	private function newDonationFromRequest(AddDonationRequest $donationRequest): Donation {
83 83
 		return new Donation(
84 84
 			null,
85
-			$this->getInitialDonationStatus( $donationRequest->getPaymentType() ),
86
-			$this->getPersonalInfoFromRequest( $donationRequest ),
87
-			$this->getPaymentFromRequest( $donationRequest ),
85
+			$this->getInitialDonationStatus($donationRequest->getPaymentType()),
86
+			$this->getPersonalInfoFromRequest($donationRequest),
87
+			$this->getPaymentFromRequest($donationRequest),
88 88
 			$donationRequest->getOptIn() === '1',
89
-			$this->newTrackingInfoFromRequest( $donationRequest )
89
+			$this->newTrackingInfoFromRequest($donationRequest)
90 90
 		);
91 91
 	}
92 92
 
93
-	private function getPersonalInfoFromRequest( AddDonationRequest $request ) {
94
-		if ( $request->donorIsAnonymous() ) {
93
+	private function getPersonalInfoFromRequest(AddDonationRequest $request) {
94
+		if ($request->donorIsAnonymous()) {
95 95
 			return null;
96 96
 		}
97 97
 		return new Donor(
98
-			$this->getNameFromRequest( $request ),
99
-			$this->getPhysicalAddressFromRequest( $request ),
98
+			$this->getNameFromRequest($request),
99
+			$this->getPhysicalAddressFromRequest($request),
100 100
 			$request->getDonorEmailAddress()
101 101
 		);
102 102
 	}
103 103
 
104
-	private function getPhysicalAddressFromRequest( AddDonationRequest $request ): PhysicalAddress {
104
+	private function getPhysicalAddressFromRequest(AddDonationRequest $request): PhysicalAddress {
105 105
 		$address = new PhysicalAddress();
106 106
 
107
-		$address->setStreetAddress( $request->getDonorStreetAddress() );
108
-		$address->setPostalCode( $request->getDonorPostalCode() );
109
-		$address->setCity( $request->getDonorCity() );
110
-		$address->setCountryCode( $request->getDonorCountryCode() );
107
+		$address->setStreetAddress($request->getDonorStreetAddress());
108
+		$address->setPostalCode($request->getDonorPostalCode());
109
+		$address->setCity($request->getDonorCity());
110
+		$address->setCountryCode($request->getDonorCountryCode());
111 111
 
112 112
 		return $address->freeze()->assertNoNullFields();
113 113
 	}
114 114
 
115
-	private function getNameFromRequest( AddDonationRequest $request ): DonorName {
115
+	private function getNameFromRequest(AddDonationRequest $request): DonorName {
116 116
 		$name = $request->donorIsCompany() ? DonorName::newCompanyName() : DonorName::newPrivatePersonName();
117 117
 
118
-		$name->setSalutation( $request->getDonorSalutation() );
119
-		$name->setTitle( $request->getDonorTitle() );
120
-		$name->setCompanyName( $request->getDonorCompany() );
121
-		$name->setFirstName( $request->getDonorFirstName() );
122
-		$name->setLastName( $request->getDonorLastName() );
118
+		$name->setSalutation($request->getDonorSalutation());
119
+		$name->setTitle($request->getDonorTitle());
120
+		$name->setCompanyName($request->getDonorCompany());
121
+		$name->setFirstName($request->getDonorFirstName());
122
+		$name->setLastName($request->getDonorLastName());
123 123
 
124 124
 		return $name->freeze()->assertNoNullFields();
125 125
 	}
126 126
 
127
-	private function getInitialDonationStatus( string $paymentType ): string {
128
-		if ( $paymentType === PaymentType::DIRECT_DEBIT ) {
127
+	private function getInitialDonationStatus(string $paymentType): string {
128
+		if ($paymentType === PaymentType::DIRECT_DEBIT) {
129 129
 			return Donation::STATUS_NEW;
130 130
 		}
131 131
 
132
-		if ( $paymentType === PaymentType::BANK_TRANSFER ) {
132
+		if ($paymentType === PaymentType::BANK_TRANSFER) {
133 133
 			return Donation::STATUS_PROMISE;
134 134
 		}
135 135
 
136 136
 		return Donation::STATUS_EXTERNAL_INCOMPLETE;
137 137
 	}
138 138
 
139
-	private function getPaymentFromRequest( AddDonationRequest $donationRequest ): DonationPayment {
139
+	private function getPaymentFromRequest(AddDonationRequest $donationRequest): DonationPayment {
140 140
 		return new DonationPayment(
141 141
 			$donationRequest->getAmount(),
142 142
 			$donationRequest->getInterval(),
143
-			$this->getPaymentMethodFromRequest( $donationRequest )
143
+			$this->getPaymentMethodFromRequest($donationRequest)
144 144
 		);
145 145
 	}
146 146
 
147
-	private function getPaymentMethodFromRequest( AddDonationRequest $donationRequest ): PaymentMethod {
148
-		if ( $donationRequest->getPaymentType() === PaymentType::BANK_TRANSFER ) {
149
-			return new BankTransferPayment( $this->transferCodeGenerator->generateTransferCode() );
147
+	private function getPaymentMethodFromRequest(AddDonationRequest $donationRequest): PaymentMethod {
148
+		if ($donationRequest->getPaymentType() === PaymentType::BANK_TRANSFER) {
149
+			return new BankTransferPayment($this->transferCodeGenerator->generateTransferCode());
150 150
 		}
151 151
 
152
-		if ( $donationRequest->getPaymentType() === PaymentType::DIRECT_DEBIT ) {
153
-			return new DirectDebitPayment( $donationRequest->getBankData() );
152
+		if ($donationRequest->getPaymentType() === PaymentType::DIRECT_DEBIT) {
153
+			return new DirectDebitPayment($donationRequest->getBankData());
154 154
 		}
155 155
 
156
-		if ( $donationRequest->getPaymentType() === PaymentType::PAYPAL ) {
157
-			return new PayPalPayment( new PayPalData() );
156
+		if ($donationRequest->getPaymentType() === PaymentType::PAYPAL) {
157
+			return new PayPalPayment(new PayPalData());
158 158
 		}
159 159
 
160
-		return new PaymentWithoutAssociatedData( $donationRequest->getPaymentType() );
160
+		return new PaymentWithoutAssociatedData($donationRequest->getPaymentType());
161 161
 	}
162 162
 
163
-	private function newTrackingInfoFromRequest( AddDonationRequest $request ): DonationTrackingInfo {
163
+	private function newTrackingInfoFromRequest(AddDonationRequest $request): DonationTrackingInfo {
164 164
 		$trackingInfo = new DonationTrackingInfo();
165 165
 
166
-		$trackingInfo->setTracking( $request->getTracking() );
167
-		$trackingInfo->setSource( $this->referrerGeneralizer->generalize( $request->getSource() ) );
168
-		$trackingInfo->setTotalImpressionCount( $request->getTotalImpressionCount() );
169
-		$trackingInfo->setSingleBannerImpressionCount( $request->getSingleBannerImpressionCount() );
170
-		$trackingInfo->setColor( $request->getColor() );
171
-		$trackingInfo->setSkin( $request->getSkin() );
172
-		$trackingInfo->setLayout( $request->getLayout() );
166
+		$trackingInfo->setTracking($request->getTracking());
167
+		$trackingInfo->setSource($this->referrerGeneralizer->generalize($request->getSource()));
168
+		$trackingInfo->setTotalImpressionCount($request->getTotalImpressionCount());
169
+		$trackingInfo->setSingleBannerImpressionCount($request->getSingleBannerImpressionCount());
170
+		$trackingInfo->setColor($request->getColor());
171
+		$trackingInfo->setSkin($request->getSkin());
172
+		$trackingInfo->setLayout($request->getLayout());
173 173
 
174 174
 		return $trackingInfo->freeze()->assertNoNullFields();
175 175
 	}
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 * @throws \RuntimeException
181 181
 	 * TODO: handle exception
182 182
 	 */
183
-	private function sendDonationConfirmationEmail( Donation $donation ) {
184
-		if ( $donation->getDonor() !== null && !$donation->hasExternalPayment() ) {
185
-			$this->mailer->sendConfirmationMailFor( $donation );
183
+	private function sendDonationConfirmationEmail(Donation $donation) {
184
+		if ($donation->getDonor() !== null && !$donation->hasExternalPayment()) {
185
+			$this->mailer->sendConfirmationMailFor($donation);
186 186
 		}
187 187
 	}
188 188
 }
189 189
\ No newline at end of file
Please login to merge, or discard this patch.
src/MembershipApplicationContext/Domain/Model/ApplicantName.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Model;
6 6
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		return new self();
32 32
 	}
33 33
 
34
-	public function setCompanyName( string $companyName ) {
34
+	public function setCompanyName(string $companyName) {
35 35
 		$this->assertIsWritable();
36 36
 		$this->companyName = $companyName;
37 37
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		return $this->salutation;
41 41
 	}
42 42
 
43
-	public function setSalutation( string $salutation ) {
43
+	public function setSalutation(string $salutation) {
44 44
 		$this->assertIsWritable();
45 45
 		$this->salutation = $salutation;
46 46
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		return $this->title;
50 50
 	}
51 51
 
52
-	public function setTitle( string $title ) {
52
+	public function setTitle(string $title) {
53 53
 		$this->assertIsWritable();
54 54
 		$this->title = $title;
55 55
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		return $this->firstName;
59 59
 	}
60 60
 
61
-	public function setFirstName( string $firstName ) {
61
+	public function setFirstName(string $firstName) {
62 62
 		$this->assertIsWritable();
63 63
 		$this->firstName = $firstName;
64 64
 	}
@@ -67,24 +67,24 @@  discard block
 block discarded – undo
67 67
 		return $this->lastName;
68 68
 	}
69 69
 
70
-	public function setLastName( string $lastName ) {
70
+	public function setLastName(string $lastName) {
71 71
 		$this->assertIsWritable();
72 72
 		$this->lastName = $lastName;
73 73
 	}
74 74
 
75 75
 	public function getFullName(): string {
76
-		return join( ', ', array_filter( [
76
+		return join(', ', array_filter([
77 77
 			$this->getFullPrivatePersonName(),
78 78
 			$this->companyName
79
-		] ) );
79
+		]));
80 80
 	}
81 81
 
82 82
 	private function getFullPrivatePersonName(): string {
83
-		return join( ' ', array_filter( [
83
+		return join(' ', array_filter([
84 84
 			$this->getTitle(),
85 85
 			$this->getFirstName(),
86 86
 			$this->getLastName()
87
-		] ) );
87
+		]));
88 88
 	}
89 89
 
90 90
 }
Please login to merge, or discard this patch.