Completed
Pull Request — master (#867)
by Jeroen De
132:59 queued 68:13
created
app/RouteHandlers/AddSubscriptionHandler.php 1 patch
Spacing   +33 added lines, -33 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\App\RouteHandlers;
6 6
 
@@ -19,66 +19,66 @@  discard block
 block discarded – undo
19 19
 	private $ffFactory;
20 20
 	private $app;
21 21
 
22
-	public function __construct( FunFunFactory $ffFactory, Application $app ) {
22
+	public function __construct(FunFunFactory $ffFactory, Application $app) {
23 23
 		$this->ffFactory = $ffFactory;
24 24
 		$this->app = $app;
25 25
 	}
26 26
 
27
-	public function handle( Request $request ): Response {
27
+	public function handle(Request $request): Response {
28 28
 		$useCase = $this->ffFactory->newAddSubscriptionUseCase();
29 29
 
30
-		$responseModel = $useCase->addSubscription( $this->createSubscriptionRequest( $request ) );
30
+		$responseModel = $useCase->addSubscription($this->createSubscriptionRequest($request));
31 31
 
32
-		if ( $this->app['request_stack.is_json'] ) {
33
-			return $this->app->json( $this->ffFactory->newAddSubscriptionJsonPresenter()->present( $responseModel ) );
34
-		} elseif ( $request->query->has( 'callback' ) ) {
35
-			return $this->app->json( $this->ffFactory->newAddSubscriptionJsonPresenter()->present( $responseModel ) )
36
-				->setCallback( $request->query->get( 'callback' ) );
32
+		if ($this->app['request_stack.is_json']) {
33
+			return $this->app->json($this->ffFactory->newAddSubscriptionJsonPresenter()->present($responseModel));
34
+		} elseif ($request->query->has('callback')) {
35
+			return $this->app->json($this->ffFactory->newAddSubscriptionJsonPresenter()->present($responseModel))
36
+				->setCallback($request->query->get('callback'));
37 37
 		}
38 38
 
39
-		if ( $responseModel->isSuccessful() ) {
40
-			if ( $responseModel->needsModeration() ) {
41
-				return $this->app->redirect( $this->app['url_generator']->generate('page', [ 'pageName' => 'Subscription_Moderation' ] ) );
39
+		if ($responseModel->isSuccessful()) {
40
+			if ($responseModel->needsModeration()) {
41
+				return $this->app->redirect($this->app['url_generator']->generate('page', ['pageName' => 'Subscription_Moderation']));
42 42
 			}
43
-			return $this->app->redirect( $this->app['url_generator']->generate('page', [ 'pageName' => 'Subscription_Success' ] ) );
43
+			return $this->app->redirect($this->app['url_generator']->generate('page', ['pageName' => 'Subscription_Success']));
44 44
 		}
45 45
 
46 46
 		return new Response(
47
-			$this->ffFactory->newAddSubscriptionHtmlPresenter()->present( $responseModel, $request->request->all() )
47
+			$this->ffFactory->newAddSubscriptionHtmlPresenter()->present($responseModel, $request->request->all())
48 48
 		);
49 49
 	}
50 50
 
51
-	private function createSubscriptionRequest( Request $request ): SubscriptionRequest {
51
+	private function createSubscriptionRequest(Request $request): SubscriptionRequest {
52 52
 		$subscriptionRequest = new SubscriptionRequest();
53 53
 
54
-		$this->addAddressDataFromRequest( $subscriptionRequest, $request );
54
+		$this->addAddressDataFromRequest($subscriptionRequest, $request);
55 55
 
56
-		$subscriptionRequest->setEmail( $request->get( 'email', '' ) );
56
+		$subscriptionRequest->setEmail($request->get('email', ''));
57 57
 
58
-		$subscriptionRequest->setWikiloginFromValues( [
59
-			$request->request->get( 'wikilogin' ),
60
-			$request->cookies->get( 'spenden_wikilogin' ),
61
-		] );
58
+		$subscriptionRequest->setWikiloginFromValues([
59
+			$request->request->get('wikilogin'),
60
+			$request->cookies->get('spenden_wikilogin'),
61
+		]);
62 62
 
63
-		$this->addTrackingDataFromRequest( $subscriptionRequest, $request );
63
+		$this->addTrackingDataFromRequest($subscriptionRequest, $request);
64 64
 
65 65
 		return $subscriptionRequest;
66 66
 	}
67 67
 
68
-	private function addAddressDataFromRequest( SubscriptionRequest $subscriptionRequest, Request $request ) {
69
-		$subscriptionRequest->setAddress( $request->get( 'address', '' ) );
70
-		$subscriptionRequest->setCity( $request->get( 'city', '' ) );
71
-		$subscriptionRequest->setPostcode( $request->get( 'postcode', '' ) );
68
+	private function addAddressDataFromRequest(SubscriptionRequest $subscriptionRequest, Request $request) {
69
+		$subscriptionRequest->setAddress($request->get('address', ''));
70
+		$subscriptionRequest->setCity($request->get('city', ''));
71
+		$subscriptionRequest->setPostcode($request->get('postcode', ''));
72 72
 
73
-		$subscriptionRequest->setFirstName( $request->get( 'firstName', '' ) );
74
-		$subscriptionRequest->setLastName( $request->get( 'lastName', '' ) );
75
-		$subscriptionRequest->setSalutation( $request->get( 'salutation', '' ) );
76
-		$subscriptionRequest->setTitle( $request->get( 'title', '' ) );
73
+		$subscriptionRequest->setFirstName($request->get('firstName', ''));
74
+		$subscriptionRequest->setLastName($request->get('lastName', ''));
75
+		$subscriptionRequest->setSalutation($request->get('salutation', ''));
76
+		$subscriptionRequest->setTitle($request->get('title', ''));
77 77
 
78 78
 	}
79 79
 
80
-	private function addTrackingDataFromRequest( SubscriptionRequest $subscriptionRequest, Request $request ) {
81
-		$subscriptionRequest->setSource( $request->get( 'source', '' ) );
82
-		$subscriptionRequest->setTrackingString( $request->attributes->get( 'trackingCode', '' ) );
80
+	private function addTrackingDataFromRequest(SubscriptionRequest $subscriptionRequest, Request $request) {
81
+		$subscriptionRequest->setSource($request->get('source', ''));
82
+		$subscriptionRequest->setTrackingString($request->attributes->get('trackingCode', ''));
83 83
 	}
84 84
 }
85 85
\ No newline at end of file
Please login to merge, or discard this patch.
app/routes.php 1 patch
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @var \WMDE\Fundraising\Frontend\Factories\FunFunFactory $ffFactory
8 8
  */
9 9
 
10
-declare( strict_types = 1 );
10
+declare(strict_types = 1);
11 11
 
12 12
 use Silex\Application;
13 13
 use Symfony\Component\HttpFoundation\Request;
@@ -44,129 +44,129 @@  discard block
 block discarded – undo
44 44
 
45 45
 $app->post(
46 46
 	'validate-email',
47
-	function( Request $request ) use ( $app, $ffFactory ) {
48
-		$validationResult = $ffFactory->getEmailValidator()->validate( $request->request->get( 'email', '' ) );
49
-		return $app->json( [ 'status' => $validationResult->isSuccessful() ? 'OK' : 'ERR' ] );
47
+	function(Request $request) use ($app, $ffFactory) {
48
+		$validationResult = $ffFactory->getEmailValidator()->validate($request->request->get('email', ''));
49
+		return $app->json(['status' => $validationResult->isSuccessful() ? 'OK' : 'ERR']);
50 50
 	}
51 51
 );
52 52
 
53 53
 $app->post(
54 54
 	'validate-payment-data',
55
-	function( Request $request ) use ( $app, $ffFactory ) {
55
+	function(Request $request) use ($app, $ffFactory) {
56 56
 
57
-		$amount = (float) $ffFactory->newDecimalNumberFormatter()->parse( $request->get( 'amount', '0' ) );
57
+		$amount = (float)$ffFactory->newDecimalNumberFormatter()->parse($request->get('amount', '0'));
58 58
 		$validator = $ffFactory->newPaymentDataValidator();
59
-		$validationResult = $validator->validate( $amount, (string) $request->get( 'paymentType', '' ) );
59
+		$validationResult = $validator->validate($amount, (string)$request->get('paymentType', ''));
60 60
 
61
-		if ( $validationResult->isSuccessful() ) {
62
-			return $app->json( [ 'status' => 'OK' ] );
61
+		if ($validationResult->isSuccessful()) {
62
+			return $app->json(['status' => 'OK']);
63 63
 		} else {
64 64
 			$errors = [];
65
-			foreach( $validationResult->getViolations() as $violation ) {
66
-				$errors[ $violation->getSource() ] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() );
65
+			foreach ($validationResult->getViolations() as $violation) {
66
+				$errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier());
67 67
 			}
68
-			return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] );
68
+			return $app->json(['status' => 'ERR', 'messages' => $errors]);
69 69
 		}
70 70
 	}
71 71
 );
72 72
 
73 73
 $app->post(
74 74
 	'validate-address',
75
-	function( Request $request ) use ( $app, $ffFactory ) {
75
+	function(Request $request) use ($app, $ffFactory) {
76 76
 		$routeHandler = new class() {
77 77
 
78
-			public function handle( FunFunFactory $ffFactory, Application $app, Request $request ) {
79
-				if ( $request->get( 'adressType', '' ) === 'anonym' ) {
80
-					return $app->json( [ 'status' => 'OK' ] );
78
+			public function handle(FunFunFactory $ffFactory, Application $app, Request $request) {
79
+				if ($request->get('adressType', '') === 'anonym') {
80
+					return $app->json(['status' => 'OK']);
81 81
 				}
82 82
 
83
-				$personalInfo = $this->getPersonalInfoFromRequest( $request );
83
+				$personalInfo = $this->getPersonalInfoFromRequest($request);
84 84
 				$personalInfoValidator = $ffFactory->newPersonalInfoValidator();
85
-				$validationResult = $personalInfoValidator->validate( $personalInfo );
85
+				$validationResult = $personalInfoValidator->validate($personalInfo);
86 86
 
87
-				if ( $validationResult->isSuccessful() ) {
88
-					return $app->json( [ 'status' => 'OK' ] );
87
+				if ($validationResult->isSuccessful()) {
88
+					return $app->json(['status' => 'OK']);
89 89
 				} else {
90 90
 					$errors = [];
91
-					foreach( $validationResult->getViolations() as $violation ) {
92
-						$errors[$violation->getSource()] = $ffFactory->getTranslator()->trans( $violation->getMessageIdentifier() );
91
+					foreach ($validationResult->getViolations() as $violation) {
92
+						$errors[$violation->getSource()] = $ffFactory->getTranslator()->trans($violation->getMessageIdentifier());
93 93
 					}
94
-					return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] );
94
+					return $app->json(['status' => 'ERR', 'messages' => $errors]);
95 95
 				}
96 96
 			}
97 97
 
98
-			private function getPersonalInfoFromRequest( Request $request ): Donor {
98
+			private function getPersonalInfoFromRequest(Request $request): Donor {
99 99
 				return new Donor(
100
-					$this->getNameFromRequest( $request ),
101
-					$this->getPhysicalAddressFromRequest( $request ),
102
-					$request->get( 'email', '' )
100
+					$this->getNameFromRequest($request),
101
+					$this->getPhysicalAddressFromRequest($request),
102
+					$request->get('email', '')
103 103
 				);
104 104
 			}
105 105
 
106
-			private function getPhysicalAddressFromRequest( Request $request ): DonorAddress {
106
+			private function getPhysicalAddressFromRequest(Request $request): DonorAddress {
107 107
 				$address = new DonorAddress();
108 108
 
109
-				$address->setStreetAddress( $request->get( 'street', '' ) );
110
-				$address->setPostalCode( $request->get( 'postcode', '' ) );
111
-				$address->setCity( $request->get( 'city', '' ) );
112
-				$address->setCountryCode( $request->get( 'country', '' ) );
109
+				$address->setStreetAddress($request->get('street', ''));
110
+				$address->setPostalCode($request->get('postcode', ''));
111
+				$address->setCity($request->get('city', ''));
112
+				$address->setCountryCode($request->get('country', ''));
113 113
 
114 114
 				return $address->freeze()->assertNoNullFields();
115 115
 			}
116 116
 
117
-			private function getNameFromRequest( Request $request ): DonorName {
118
-				$name = $request->get( 'addressType', '' ) === 'firma'
117
+			private function getNameFromRequest(Request $request): DonorName {
118
+				$name = $request->get('addressType', '') === 'firma'
119 119
 					? DonorName::newCompanyName() : DonorName::newPrivatePersonName();
120 120
 
121
-				$name->setSalutation( $request->get( 'salutation', '' ) );
122
-				$name->setTitle( $request->get( 'title', '' ) );
123
-				$name->setCompanyName( $request->get( 'companyName', '' ) );
124
-				$name->setFirstName( $request->get( 'firstName', '' ) );
125
-				$name->setLastName( $request->get( 'lastName', '' ) );
121
+				$name->setSalutation($request->get('salutation', ''));
122
+				$name->setTitle($request->get('title', ''));
123
+				$name->setCompanyName($request->get('companyName', ''));
124
+				$name->setFirstName($request->get('firstName', ''));
125
+				$name->setLastName($request->get('lastName', ''));
126 126
 
127 127
 				return $name->freeze()->assertNoNullFields();
128 128
 			}
129 129
 		};
130 130
 
131
-		return $routeHandler->handle( $ffFactory, $app, $request );
131
+		return $routeHandler->handle($ffFactory, $app, $request);
132 132
 	}
133 133
 );
134 134
 
135 135
 $app->post(
136 136
 	'validate-fee',
137
-	function( Request $httpRequest ) use ( $app, $ffFactory ) {
137
+	function(Request $httpRequest) use ($app, $ffFactory) {
138 138
 		$validator = new MembershipFeeValidator();
139 139
 		$result = $validator->validate(
140
-			str_replace( ',', '.', $httpRequest->request->get( 'amount', '' ) ),
141
-			(int) $httpRequest->request->get( 'paymentIntervalInMonths', '0' ),
142
-			$httpRequest->request->get( 'addressType', '' )
140
+			str_replace(',', '.', $httpRequest->request->get('amount', '')),
141
+			(int)$httpRequest->request->get('paymentIntervalInMonths', '0'),
142
+			$httpRequest->request->get('addressType', '')
143 143
 		);
144 144
 
145
-		if ( $result->isSuccessful() ) {
146
-			return $app->json( [ 'status' => 'OK' ] );
145
+		if ($result->isSuccessful()) {
146
+			return $app->json(['status' => 'OK']);
147 147
 		} else {
148 148
 			$errors = $result->getViolations();
149
-			return $app->json( [ 'status' => 'ERR', 'messages' => $errors ] );
149
+			return $app->json(['status' => 'ERR', 'messages' => $errors]);
150 150
 		}
151 151
 	}
152 152
 );
153 153
 
154 154
 $app->get(
155 155
 	'list-comments.json',
156
-	function( Request $request ) use ( $app, $ffFactory ) {
156
+	function(Request $request) use ($app, $ffFactory) {
157 157
 		$response = $app->json(
158 158
 			$ffFactory->newCommentListJsonPresenter()->present(
159 159
 				$ffFactory->newListCommentsUseCase()->listComments(
160 160
 					new CommentListingRequest(
161
-						(int)$request->query->get( 'n', '10' ),
162
-						(int)$request->query->get( 'page', '1' )
161
+						(int)$request->query->get('n', '10'),
162
+						(int)$request->query->get('page', '1')
163 163
 					)
164 164
 				)
165 165
 			)
166 166
 		);
167 167
 
168
-		if ( $request->query->get( 'f' ) ) {
169
-			$response->setCallback( $request->query->get( 'f' ) );
168
+		if ($request->query->get('f')) {
169
+			$response->setCallback($request->query->get('f'));
170 170
 		}
171 171
 
172 172
 		return $response;
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 
176 176
 $app->get(
177 177
 	'list-comments.rss',
178
-	function() use ( $app, $ffFactory ) {
178
+	function() use ($app, $ffFactory) {
179 179
 		$rss = $ffFactory->newCommentListRssPresenter()->present(
180 180
 			$ffFactory->newListCommentsUseCase()->listComments(
181
-				new CommentListingRequest( 100, CommentListingRequest::FIRST_PAGE )
181
+				new CommentListingRequest(100, CommentListingRequest::FIRST_PAGE)
182 182
 			)
183 183
 		);
184 184
 
@@ -191,147 +191,147 @@  discard block
 block discarded – undo
191 191
 			]
192 192
 		);
193 193
 	}
194
-)->bind( 'list-comments.rss' );
194
+)->bind('list-comments.rss');
195 195
 
196 196
 $app->get(
197 197
 	'list-comments.html',
198
-	function( Request $request ) use ( $app, $ffFactory ) {
198
+	function(Request $request) use ($app, $ffFactory) {
199 199
 		return new Response(
200 200
 			$ffFactory->newCommentListHtmlPresenter()->present(
201 201
 				$ffFactory->newListCommentsUseCase()->listComments(
202 202
 					new CommentListingRequest(
203 203
 						10,
204
-						(int)$request->query->get( 'page', '1' )
204
+						(int)$request->query->get('page', '1')
205 205
 					)
206 206
 				),
207
-				(int)$request->query->get( 'page', '1' )
207
+				(int)$request->query->get('page', '1')
208 208
 			)
209 209
 		);
210 210
 	}
211
-)->bind( 'list-comments.html' );
211
+)->bind('list-comments.html');
212 212
 
213 213
 $app->get(
214 214
 	'page/{pageName}',
215
-	function( $pageName ) use ( $ffFactory ) {
216
-		if ( !$ffFactory->getTemplateNameValidator()->validate( $pageName . '.html.twig' )->isSuccessful() ) {
217
-			throw new NotFoundHttpException( "Page '$pageName' not found." );
215
+	function($pageName) use ($ffFactory) {
216
+		if (!$ffFactory->getTemplateNameValidator()->validate($pageName . '.html.twig')->isSuccessful()) {
217
+			throw new NotFoundHttpException("Page '$pageName' not found.");
218 218
 		}
219 219
 
220
-		return $ffFactory->getLayoutTemplate( 'Display_Page_Layout.twig' )->render( [
220
+		return $ffFactory->getLayoutTemplate('Display_Page_Layout.twig')->render([
221 221
 			'main_template' => $pageName . '.html.twig'
222
-		] );
222
+		]);
223 223
 	}
224 224
 )
225
-->bind( 'page' );
225
+->bind('page');
226 226
 
227 227
 // Form for this is provided by route page/Subscription_Form
228 228
 $app->match(
229 229
 	'contact/subscribe',
230
-	function( Application $app, Request $request ) use ( $ffFactory ) {
231
-		return ( new AddSubscriptionHandler( $ffFactory, $app ) )
232
-			->handle( $request );
230
+	function(Application $app, Request $request) use ($ffFactory) {
231
+		return (new AddSubscriptionHandler($ffFactory, $app))
232
+			->handle($request);
233 233
 	}
234 234
 )
235
-->method( 'GET|POST' )
236
-->bind( 'subscribe' );
235
+->method('GET|POST')
236
+->bind('subscribe');
237 237
 
238
-$app->get( 'contact/confirm-subscription/{confirmationCode}', function ( $confirmationCode ) use ( $ffFactory ) {
238
+$app->get('contact/confirm-subscription/{confirmationCode}', function($confirmationCode) use ($ffFactory) {
239 239
 	$useCase = $ffFactory->newConfirmSubscriptionUseCase();
240
-	$response = $useCase->confirmSubscription( $confirmationCode );
241
-	return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present( $response );
240
+	$response = $useCase->confirmSubscription($confirmationCode);
241
+	return $ffFactory->newConfirmSubscriptionHtmlPresenter()->present($response);
242 242
 } )
243
-->assert( 'confirmationCode', '^[0-9a-f]+$' )
244
-->bind( 'confirm-subscription' );
243
+->assert('confirmationCode', '^[0-9a-f]+$')
244
+->bind('confirm-subscription');
245 245
 
246 246
 $app->get(
247 247
 	'check-iban',
248
-	function( Request $request ) use ( $app, $ffFactory ) {
248
+	function(Request $request) use ($app, $ffFactory) {
249 249
 		$useCase = $ffFactory->newCheckIbanUseCase();
250
-		$checkIbanResponse = $useCase->checkIban( new Iban( $request->query->get( 'iban', '' ) ) );
251
-		return $app->json( $ffFactory->newIbanPresenter()->present( $checkIbanResponse ) );
250
+		$checkIbanResponse = $useCase->checkIban(new Iban($request->query->get('iban', '')));
251
+		return $app->json($ffFactory->newIbanPresenter()->present($checkIbanResponse));
252 252
 	}
253 253
 );
254 254
 
255 255
 $app->get(
256 256
 	'generate-iban',
257
-	function( Request $request ) use ( $app, $ffFactory ) {
257
+	function(Request $request) use ($app, $ffFactory) {
258 258
 		$generateIbanRequest = new GenerateIbanRequest(
259
-			$request->query->get( 'accountNumber', '' ),
260
-			$request->query->get( 'bankCode', '' )
259
+			$request->query->get('accountNumber', ''),
260
+			$request->query->get('bankCode', '')
261 261
 		);
262 262
 
263
-		$generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban( $generateIbanRequest );
264
-		return $app->json( $ffFactory->newIbanPresenter()->present( $generateIbanResponse ) );
263
+		$generateIbanResponse = $ffFactory->newGenerateIbanUseCase()->generateIban($generateIbanRequest);
264
+		return $app->json($ffFactory->newIbanPresenter()->present($generateIbanResponse));
265 265
 	}
266 266
 );
267 267
 
268 268
 $app->post(
269 269
 	'add-comment',
270
-	function( Request $request ) use ( $app, $ffFactory ) {
270
+	function(Request $request) use ($app, $ffFactory) {
271 271
 		$addCommentRequest = new AddCommentRequest();
272
-		$addCommentRequest->setCommentText( trim( $request->request->get( 'kommentar', '' ) ) );
273
-		$addCommentRequest->setIsPublic( $request->request->get( 'public', '0' ) === '1' );
274
-		$addCommentRequest->setAuthorDisplayName( trim( $request->request->get( 'eintrag', '' ) ) );
275
-		$addCommentRequest->setDonationId( (int)$request->request->get( 'sid', '' ) );
272
+		$addCommentRequest->setCommentText(trim($request->request->get('kommentar', '')));
273
+		$addCommentRequest->setIsPublic($request->request->get('public', '0') === '1');
274
+		$addCommentRequest->setAuthorDisplayName(trim($request->request->get('eintrag', '')));
275
+		$addCommentRequest->setDonationId((int)$request->request->get('sid', ''));
276 276
 		$addCommentRequest->freeze()->assertNoNullFields();
277 277
 
278
-		$updateToken = $request->request->get( 'utoken', '' );
278
+		$updateToken = $request->request->get('utoken', '');
279 279
 
280
-		if ( $updateToken === '' ) {
281
-			return $app->json( [
280
+		if ($updateToken === '') {
281
+			return $app->json([
282 282
 				'status' => 'ERR',
283
-				'message' => $ffFactory->getTranslator()->trans( 'comment_failure_access_denied' ),
284
-			] );
283
+				'message' => $ffFactory->getTranslator()->trans('comment_failure_access_denied'),
284
+			]);
285 285
 		}
286 286
 
287
-		$response = $ffFactory->newAddCommentUseCase( $updateToken )->addComment( $addCommentRequest );
287
+		$response = $ffFactory->newAddCommentUseCase($updateToken)->addComment($addCommentRequest);
288 288
 
289
-		if ( $response->isSuccessful() ) {
290
-			return $app->json( [
289
+		if ($response->isSuccessful()) {
290
+			return $app->json([
291 291
 				'status' => 'OK',
292
-				'message' => $ffFactory->getTranslator()->trans( $response->getSuccessMessage() ),
293
-			] );
292
+				'message' => $ffFactory->getTranslator()->trans($response->getSuccessMessage()),
293
+			]);
294 294
 		}
295 295
 
296
-		return $app->json( [
296
+		return $app->json([
297 297
 			'status' => 'ERR',
298
-			'message' => $ffFactory->getTranslator()->trans( $response->getErrorMessage() ),
299
-		] );
298
+			'message' => $ffFactory->getTranslator()->trans($response->getErrorMessage()),
299
+		]);
300 300
 	}
301 301
 );
302 302
 
303 303
 $app->post(
304 304
 	'contact/get-in-touch',
305
-	function( Request $request ) use ( $app, $ffFactory ) {
305
+	function(Request $request) use ($app, $ffFactory) {
306 306
 		$contactFormRequest = new GetInTouchRequest(
307
-			$request->get( 'firstname', '' ),
308
-			$request->get( 'lastname', '' ),
309
-			$request->get( 'email', '' ),
310
-			$request->get( 'subject', '' ),
311
-			$request->get( 'messageBody', '' )
307
+			$request->get('firstname', ''),
308
+			$request->get('lastname', ''),
309
+			$request->get('email', ''),
310
+			$request->get('subject', ''),
311
+			$request->get('messageBody', '')
312 312
 		);
313 313
 
314
-		$contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest( $contactFormRequest );
315
-		if ( $contactFormResponse->isSuccessful() ) {
316
-			return $app->redirect( $app['url_generator']->generate( 'page', [ 'pageName' => 'Kontakt_Bestaetigung' ] ) );
314
+		$contactFormResponse = $ffFactory->newGetInTouchUseCase()->processContactRequest($contactFormRequest);
315
+		if ($contactFormResponse->isSuccessful()) {
316
+			return $app->redirect($app['url_generator']->generate('page', ['pageName' => 'Kontakt_Bestaetigung']));
317 317
 		}
318
-		return $ffFactory->newGetInTouchHtmlPresenter()->present( $contactFormResponse, $request->request->all() );
318
+		return $ffFactory->newGetInTouchHtmlPresenter()->present($contactFormResponse, $request->request->all());
319 319
 	}
320 320
 );
321 321
 
322 322
 $app->post(
323 323
 	'donation/cancel',
324
-	function( Request $request ) use ( $app, $ffFactory ) {
324
+	function(Request $request) use ($app, $ffFactory) {
325 325
 		$cancellationRequest = new CancelDonationRequest(
326
-			(int)$request->request->get( 'sid', '' )
326
+			(int)$request->request->get('sid', '')
327 327
 		);
328 328
 
329
-		$responseModel = $ffFactory->newCancelDonationUseCase( $request->request->get( 'utoken', '' ) )
330
-			->cancelDonation( $cancellationRequest );
329
+		$responseModel = $ffFactory->newCancelDonationUseCase($request->request->get('utoken', ''))
330
+			->cancelDonation($cancellationRequest);
331 331
 
332
-		$httpResponse = new Response( $ffFactory->newCancelDonationHtmlPresenter()->present( $responseModel ) );
333
-		if ( $responseModel->cancellationSucceeded() ) {
334
-			$httpResponse->headers->clearCookie( 'donation_timestamp' );
332
+		$httpResponse = new Response($ffFactory->newCancelDonationHtmlPresenter()->present($responseModel));
333
+		if ($responseModel->cancellationSucceeded()) {
334
+			$httpResponse->headers->clearCookie('donation_timestamp');
335 335
 		}
336 336
 
337 337
 		return $httpResponse;
@@ -341,151 +341,151 @@  discard block
 block discarded – undo
341 341
 
342 342
 $app->post(
343 343
 	'donation/add',
344
-	function( Application $app, Request $request ) use ( $ffFactory ) {
345
-		return ( new AddDonationHandler( $ffFactory, $app ) )
346
-			->handle( $request );
344
+	function(Application $app, Request $request) use ($ffFactory) {
345
+		return (new AddDonationHandler($ffFactory, $app))
346
+			->handle($request);
347 347
 	}
348 348
 );
349 349
 
350 350
 // Show a donation form with pre-filled payment values, e.g. when coming from a banner
351
-$app->get( 'donation/new', function ( Request $request ) use ( $ffFactory ) {
351
+$app->get('donation/new', function(Request $request) use ($ffFactory) {
352 352
 	try {
353
-		$amount = Euro::newFromFloat( ( new AmountParser( 'en_EN' ) )->parseAsFloat(
354
-			$request->get( 'betrag_auswahl', $request->get( 'amountGiven', '' ) ) )
353
+		$amount = Euro::newFromFloat((new AmountParser('en_EN'))->parseAsFloat(
354
+			$request->get('betrag_auswahl', $request->get('amountGiven', '')) )
355 355
 		);
356
-	} catch ( \InvalidArgumentException $ex ) {
357
-		$amount = Euro::newFromCents( 0 );
356
+	} catch (\InvalidArgumentException $ex) {
357
+		$amount = Euro::newFromCents(0);
358 358
 	}
359
-	$validationResult = $ffFactory->newPaymentDataValidator()->validate( $amount, (string) $request->get( 'zahlweise', '' ) );
359
+	$validationResult = $ffFactory->newPaymentDataValidator()->validate($amount, (string)$request->get('zahlweise', ''));
360 360
 
361 361
 	$trackingInfo = new DonationTrackingInfo();
362
-	$trackingInfo->setTotalImpressionCount( intval( $request->get( 'impCount' ) ) );
363
-	$trackingInfo->setSingleBannerImpressionCount( intval( $request->get( 'bImpCount' ) ) );
362
+	$trackingInfo->setTotalImpressionCount(intval($request->get('impCount')));
363
+	$trackingInfo->setSingleBannerImpressionCount(intval($request->get('bImpCount')));
364 364
 
365 365
 	// TODO: don't we want to use newDonationFormViolationPresenter when !$validationResult->isSuccessful()?
366 366
 
367 367
 	return new Response(
368 368
 		$ffFactory->newDonationFormPresenter()->present(
369 369
 			$amount,
370
-			$request->get( 'zahlweise', '' ),
371
-			intval( $request->get( 'periode', 0 ) ),
370
+			$request->get('zahlweise', ''),
371
+			intval($request->get('periode', 0)),
372 372
 			$validationResult->isSuccessful(),
373 373
 			$trackingInfo,
374
-			$request->get( 'addressType', 'person' )
374
+			$request->get('addressType', 'person')
375 375
 		)
376 376
 	);
377
-} )->method( 'POST|GET' );
377
+} )->method('POST|GET');
378 378
 
379 379
 $app->post(
380 380
 	'apply-for-membership',
381
-	function( Application $app, Request $httpRequest ) use ( $ffFactory ) {
382
-		return ( new ApplyForMembershipHandler( $ffFactory, $app ) )->handle( $httpRequest );
381
+	function(Application $app, Request $httpRequest) use ($ffFactory) {
382
+		return (new ApplyForMembershipHandler($ffFactory, $app))->handle($httpRequest);
383 383
 	}
384 384
 );
385 385
 
386 386
 $app->get(
387 387
 	'show-membership-confirmation',
388
-	function( Request $request ) use ( $ffFactory ) {
389
-		$confirmationRequest = new ShowMembershipAppConfirmationRequest( (int)$request->query->get( 'id', 0 ) );
388
+	function(Request $request) use ($ffFactory) {
389
+		$confirmationRequest = new ShowMembershipAppConfirmationRequest((int)$request->query->get('id', 0));
390 390
 
391 391
 		return $ffFactory->newMembershipApplicationConfirmationHtmlPresenter()->present(
392
-			$ffFactory->newMembershipApplicationConfirmationUseCase( $request->query->get( 'accessToken', '' ) )
393
-				->showConfirmation( $confirmationRequest )
392
+			$ffFactory->newMembershipApplicationConfirmationUseCase($request->query->get('accessToken', ''))
393
+				->showConfirmation($confirmationRequest)
394 394
 		);
395 395
 	}
396
-)->bind( 'show-membership-confirmation' );
396
+)->bind('show-membership-confirmation');
397 397
 
398 398
 $app->get(
399 399
 	'cancel-membership-application',
400
-	function( Request $request ) use ( $ffFactory ) {
400
+	function(Request $request) use ($ffFactory) {
401 401
 		$cancellationRequest = new CancellationRequest(
402
-			(int)$request->query->get( 'id', '' )
402
+			(int)$request->query->get('id', '')
403 403
 		);
404 404
 
405 405
 		return $ffFactory->newCancelMembershipApplicationHtmlPresenter()->present(
406
-			$ffFactory->newCancelMembershipApplicationUseCase( $request->query->get( 'updateToken', '' ) )
407
-				->cancelApplication( $cancellationRequest )
406
+			$ffFactory->newCancelMembershipApplicationUseCase($request->query->get('updateToken', ''))
407
+				->cancelApplication($cancellationRequest)
408 408
 		);
409 409
 	}
410 410
 );
411 411
 
412 412
 $app->match(
413 413
 	'show-donation-confirmation',
414
-	function( Application $app, Request $request ) use ( $ffFactory ) {
415
-		return ( new ShowDonationConfirmationHandler( $ffFactory ) )->handle(
414
+	function(Application $app, Request $request) use ($ffFactory) {
415
+		return (new ShowDonationConfirmationHandler($ffFactory))->handle(
416 416
 			$request,
417
-			$app['session']->get( 'piwikTracking', [] )
417
+			$app['session']->get('piwikTracking', [])
418 418
 		);
419 419
 	}
420
-)->bind( 'show-donation-confirmation' )
421
-->method( 'GET|POST' );
420
+)->bind('show-donation-confirmation')
421
+->method('GET|POST');
422 422
 
423 423
 $app->post(
424 424
 	'handle-paypal-payment-notification',
425
-	function ( Request $request ) use ( $ffFactory ) {
426
-		return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request );
425
+	function(Request $request) use ($ffFactory) {
426
+		return (new PayPalNotificationHandler($ffFactory))->handle($request);
427 427
 	}
428 428
 );
429 429
 
430 430
 $app->get(
431 431
 	'handle-creditcard-payment-notification',
432
-	function ( Request $request ) use ( $ffFactory ) {
432
+	function(Request $request) use ($ffFactory) {
433 433
 		try {
434
-			$ffFactory->newCreditCardNotificationUseCase( $request->query->get( 'utoken', '' ) )
434
+			$ffFactory->newCreditCardNotificationUseCase($request->query->get('utoken', ''))
435 435
 				->handleNotification(
436
-					( new CreditCardPaymentNotificationRequest() )
437
-						->setTransactionId( $request->query->get( 'transactionId', '' ) )
438
-						->setDonationId( (int)$request->query->get( 'donation_id', '' ) )
439
-						->setAmount( Euro::newFromCents( (int)$request->query->get( 'amount' ) ) )
440
-						->setCustomerId( $request->query->get( 'customerId', '' ) )
441
-						->setSessionId( $request->query->get( 'sessionId', '' ) )
442
-						->setAuthId( $request->query->get(  'auth', '' ) )
443
-						->setTitle( $request->query->get( 'title', '' ) )
444
-						->setCountry( $request->query->get( 'country', '' ) )
445
-						->setCurrency( $request->query->get( 'currency', '' ) )
436
+					(new CreditCardPaymentNotificationRequest())
437
+						->setTransactionId($request->query->get('transactionId', ''))
438
+						->setDonationId((int)$request->query->get('donation_id', ''))
439
+						->setAmount(Euro::newFromCents((int)$request->query->get('amount')))
440
+						->setCustomerId($request->query->get('customerId', ''))
441
+						->setSessionId($request->query->get('sessionId', ''))
442
+						->setAuthId($request->query->get('auth', ''))
443
+						->setTitle($request->query->get('title', ''))
444
+						->setCountry($request->query->get('country', ''))
445
+						->setCurrency($request->query->get('currency', ''))
446 446
 				);
447 447
 
448 448
 			$response = CreditCardNotificationResponse::newSuccessResponse(
449
-				(int)$request->query->get( 'donation_id', '' ),
450
-				$request->query->get( 'token', '' )
449
+				(int)$request->query->get('donation_id', ''),
450
+				$request->query->get('token', '')
451 451
  			);
452
-		} catch ( CreditCardPaymentHandlerException $e ) {
453
-			$response = CreditCardNotificationResponse::newFailureResponse( $e->getMessage() );
452
+		} catch (CreditCardPaymentHandlerException $e) {
453
+			$response = CreditCardNotificationResponse::newFailureResponse($e->getMessage());
454 454
 		}
455 455
 
456
-		return new Response( $ffFactory->newCreditCardNotificationPresenter()->present( $response ) );
456
+		return new Response($ffFactory->newCreditCardNotificationPresenter()->present($response));
457 457
 	}
458 458
 );
459 459
 
460 460
 $app->get(
461 461
 	'donation-accepted',
462
-	function( Request $request ) use ( $app, $ffFactory ) {
462
+	function(Request $request) use ($app, $ffFactory) {
463 463
 
464
-		$eventHandler = $ffFactory->newDonationAcceptedEventHandler( $request->query->get( 'update_token', '' ) );
465
-		$result = $eventHandler->onDonationAccepted( (int)$request->query->get( 'donation_id', '' ) );
464
+		$eventHandler = $ffFactory->newDonationAcceptedEventHandler($request->query->get('update_token', ''));
465
+		$result = $eventHandler->onDonationAccepted((int)$request->query->get('donation_id', ''));
466 466
 
467 467
 		return $app->json(
468
-			$result === null ? [ 'status' => 'OK' ] : [ 'status' => 'ERR', 'message' => $result ]
468
+			$result === null ? ['status' => 'OK'] : ['status' => 'ERR', 'message' => $result]
469 469
 		);
470 470
 	}
471 471
 );
472 472
 
473 473
 $app->post(
474 474
 	'handle-paypal-membership-fee-payments',
475
-	function ( Request $request ) use ( $ffFactory ) {
476
-		return ( new PayPalNotificationHandlerForMembershipFee( $ffFactory ) )->handle( $request->request );
475
+	function(Request $request) use ($ffFactory) {
476
+		return (new PayPalNotificationHandlerForMembershipFee($ffFactory))->handle($request->request);
477 477
 	}
478 478
 );
479 479
 
480
-$app->get( '/', function ( Application $app, Request $request ) {
481
-	$app['session']->set( 'piwikTracking', array_filter(
480
+$app->get('/', function(Application $app, Request $request) {
481
+	$app['session']->set('piwikTracking', array_filter(
482 482
 			[
483
-				'paymentType' => $request->get( 'zahlweise', '' ),
484
-				'paymentAmount' => $request->get( 'betrag', '' ),
485
-				'paymentInterval' => $request->get( 'periode', '' )
483
+				'paymentType' => $request->get('zahlweise', ''),
484
+				'paymentAmount' => $request->get('betrag', ''),
485
+				'paymentInterval' => $request->get('periode', '')
486 486
 			],
487
-			function ( string $value ) {
488
-				return $value !== '' && strlen( $value ) < 20;
487
+			function(string $value) {
488
+				return $value !== '' && strlen($value) < 20;
489 489
 			} )
490 490
 	);
491 491
 
@@ -500,43 +500,43 @@  discard block
 block discarded – undo
500 500
 		),
501 501
 		HttpKernelInterface::SUB_REQUEST
502 502
 	);
503
-} )->bind( '/' );
503
+} )->bind('/');
504 504
 
505 505
 // TODO Figure out how to rewrite with Nginx
506 506
 // See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url
507 507
 $app->post(
508 508
 	'/spenden/paypal_handler.php',
509
-	function ( Request $request ) use ( $ffFactory ) {
510
-		return ( new PayPalNotificationHandler( $ffFactory ) )->handle( $request );
509
+	function(Request $request) use ($ffFactory) {
510
+		return (new PayPalNotificationHandler($ffFactory))->handle($request);
511 511
 	}
512 512
 );
513 513
 
514 514
 // redirect display page requests from old URLs
515
-$app->get( '/spenden/{page}', function( Application $app, Request $request, string $page ) {
515
+$app->get('/spenden/{page}', function(Application $app, Request $request, string $page) {
516 516
 	// Poor man's rewrite until someone has figured out how to do this with Nginx without breaking REQUEST_URI
517 517
 	// See https://serverfault.com/questions/805881/nginx-populate-request-uri-with-rewritten-url
518
-	switch ( $page ) {
518
+	switch ($page) {
519 519
 		case 'Mitgliedschaft':
520
-			return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/Membership_Application' );
520
+			return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/Membership_Application');
521 521
 		default:
522
-			return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/page/' . $page );
522
+			return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/page/' . $page);
523 523
 	}
524
-} )->assert( 'page', '[a-zA-Z_\-\s\x7f-\xff]+' );
524
+} )->assert('page', '[a-zA-Z_\-\s\x7f-\xff]+');
525 525
 
526 526
 // redirect different formats of comment lists
527
-$app->get( '/spenden/{outputFormat}.php', function( Application $app, Request $request, string $outputFormat ) {
528
-	return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle(
529
-		'/list-comments.' . ( $outputFormat === 'list' ? 'html' : $outputFormat )
527
+$app->get('/spenden/{outputFormat}.php', function(Application $app, Request $request, string $outputFormat) {
528
+	return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle(
529
+		'/list-comments.' . ($outputFormat === 'list' ? 'html' : $outputFormat)
530 530
 	);
531
-} )->assert( 'outputFormat', 'list|rss|json' );
531
+} )->assert('outputFormat', 'list|rss|json');
532 532
 
533 533
 // redirect all other calls to default route
534
-$app->get( '/spenden{page}', function( Application $app, Request $request ) {
535
-	return ( new RouteRedirectionHandler( $app, $request->getQueryString() ) )->handle( '/' );
536
-} )->assert( 'page', '/?([a-z]+\.php)?' );
534
+$app->get('/spenden{page}', function(Application $app, Request $request) {
535
+	return (new RouteRedirectionHandler($app, $request->getQueryString()))->handle('/');
536
+} )->assert('page', '/?([a-z]+\.php)?');
537 537
 
538
-$app->get( '/purge-cache', function( Request $request ) use ( $ffFactory ) {
539
-	$response = $ffFactory->newAuthorizedCachePurger()->purgeCache( $request->query->get( 'secret', '' ) );
538
+$app->get('/purge-cache', function(Request $request) use ($ffFactory) {
539
+	$response = $ffFactory->newAuthorizedCachePurger()->purgeCache($request->query->get('secret', ''));
540 540
 
541 541
 	return new Response(
542 542
 		[
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	);
548 548
 } );
549 549
 
550
-$app->get( 'status', function() {
550
+$app->get('status', function() {
551 551
 	return 'Status: OK (Online)';
552 552
 } );
553 553
 
Please login to merge, or discard this patch.
app/bootstrap.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var \WMDE\Fundraising\Frontend\Factories\FunFunFactory $ffFactory
7 7
  */
8 8
 
9
-declare( strict_types = 1 );
9
+declare(strict_types = 1);
10 10
 
11 11
 use Silex\Application;
12 12
 use Silex\Provider\RoutingServiceProvider;
@@ -21,101 +21,101 @@  discard block
 block discarded – undo
21 21
 
22 22
 $app = new Application();
23 23
 
24
-$app->register( new SessionServiceProvider() );
25
-$app->register( new RoutingServiceProvider() );
26
-$app->register( new TwigServiceProvider() );
24
+$app->register(new SessionServiceProvider());
25
+$app->register(new RoutingServiceProvider());
26
+$app->register(new TwigServiceProvider());
27 27
 
28 28
 $app->before(
29
-	function ( Request $request, Application $app ) {
30
-		$app['request_stack.is_json'] = in_array( 'application/json', $request->getAcceptableContentTypes() );
29
+	function(Request $request, Application $app) {
30
+		$app['request_stack.is_json'] = in_array('application/json', $request->getAcceptableContentTypes());
31 31
 
32
-		$request->attributes->set( 'trackingCode', TrackingDataSelector::getFirstNonEmptyValue( [
33
-			$request->cookies->get( 'spenden_tracking' ),
34
-			$request->request->get( 'tracking' ),
32
+		$request->attributes->set('trackingCode', TrackingDataSelector::getFirstNonEmptyValue([
33
+			$request->cookies->get('spenden_tracking'),
34
+			$request->request->get('tracking'),
35 35
 			TrackingDataSelector::concatTrackingFromVarTuple(
36
-				$request->get( 'piwik_campaign', '' ),
37
-				$request->get( 'piwik_kwd', '' )
36
+				$request->get('piwik_campaign', ''),
37
+				$request->get('piwik_kwd', '')
38 38
 			)
39
-		] ) );
39
+		]));
40 40
 
41
-		$request->attributes->set( 'trackingSource', TrackingDataSelector::getFirstNonEmptyValue( [
42
-			$request->cookies->get( 'spenden_source' ),
43
-			$request->request->get( 'source' ),
44
-			$request->server->get( 'HTTP_REFERER' )
45
-		] ) );
41
+		$request->attributes->set('trackingSource', TrackingDataSelector::getFirstNonEmptyValue([
42
+			$request->cookies->get('spenden_source'),
43
+			$request->request->get('source'),
44
+			$request->server->get('HTTP_REFERER')
45
+		]));
46 46
 	},
47 47
 	Application::EARLY_EVENT
48 48
 );
49 49
 
50
-$app->before( function( Request $request ) {
51
-	foreach ( [ $request->request, $request->query ] as $parameterBag ) {
52
-		foreach ( $parameterBag->keys() as $key ) {
53
-			if ( is_string( $parameterBag->get( $key ) ) ) {
54
-				$parameterBag->set( $key, trim( $parameterBag->get( $key ) ) );
50
+$app->before(function(Request $request) {
51
+	foreach ([$request->request, $request->query] as $parameterBag) {
52
+		foreach ($parameterBag->keys() as $key) {
53
+			if (is_string($parameterBag->get($key))) {
54
+				$parameterBag->set($key, trim($parameterBag->get($key)));
55 55
 			}
56 56
 		}
57 57
 	}
58
-}, Application::EARLY_EVENT );
58
+}, Application::EARLY_EVENT);
59 59
 
60 60
 
61
-$app->after( function( Request $request, Response $response, Application $app ) {
62
-	if( $response instanceof JsonResponse ) {
63
-		$response->setEncodingOptions( JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES );
61
+$app->after(function(Request $request, Response $response, Application $app) {
62
+	if ($response instanceof JsonResponse) {
63
+		$response->setEncodingOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
64 64
 	}
65 65
 
66 66
 	// Set cookie with original tracking data
67
-	if ( (string)$request->cookies->get( 'spenden_tracking' ) === '' &&
68
-			(string)$request->get( 'piwik_campaign' ) !== '' && (string)$request->get( 'piwik_kwd' ) !== '' ) {
69
-		$response->headers->setCookie( new \Symfony\Component\HttpFoundation\Cookie(
67
+	if ((string)$request->cookies->get('spenden_tracking') === '' &&
68
+			(string)$request->get('piwik_campaign') !== '' && (string)$request->get('piwik_kwd') !== '') {
69
+		$response->headers->setCookie(new \Symfony\Component\HttpFoundation\Cookie(
70 70
 			'spenden_tracking',
71
-			$request->get( 'piwik_campaign' ) . '/' . $request->get( 'piwik_kwd' )
72
-		) );
71
+			$request->get('piwik_campaign') . '/' . $request->get('piwik_kwd')
72
+		));
73 73
 	}
74 74
 
75 75
 	return $response;
76 76
 } );
77 77
 
78
-$app->error( function ( AccessDeniedException $e ) use ( $ffFactory ) {
78
+$app->error(function(AccessDeniedException $e) use ($ffFactory) {
79 79
 	return new Response(
80
-		$ffFactory->newAccessDeniedHtmlPresenter()->present( $e ),
80
+		$ffFactory->newAccessDeniedHtmlPresenter()->present($e),
81 81
 		403,
82
-		[ 'X-Status-Code' => 403 ]
82
+		['X-Status-Code' => 403]
83 83
 	);
84 84
 } );
85 85
 
86
-$app->error( function ( NotFoundHttpException $e ) use ( $ffFactory, $app ) {
87
-	if ( $app['request_stack.is_json'] ) {
88
-		return $app->json( [ 'ERR' => $e->getMessage() ], 404, [ 'X-Status-Code' => 404 ] );
86
+$app->error(function(NotFoundHttpException $e) use ($ffFactory, $app) {
87
+	if ($app['request_stack.is_json']) {
88
+		return $app->json(['ERR' => $e->getMessage()], 404, ['X-Status-Code' => 404]);
89 89
 	}
90 90
 
91 91
 	return new Response(
92 92
 		$ffFactory->newPageNotFoundHtmlPresenter()->present(),
93 93
 		404,
94
-		[ 'X-Status-Code' => 404 ]
94
+		['X-Status-Code' => 404]
95 95
 	);
96 96
 } );
97 97
 
98 98
 
99
-$app->error( function ( \Exception $e, Request $request, $code ) use ( $ffFactory, $app ) {
100
-	if ( $app['debug'] ) {
99
+$app->error(function(\Exception $e, Request $request, $code) use ($ffFactory, $app) {
100
+	if ($app['debug']) {
101 101
 		throw $e;
102 102
 	}
103 103
 
104
-	$ffFactory->getLogger()->error( $e->getMessage(), [
104
+	$ffFactory->getLogger()->error($e->getMessage(), [
105 105
 		'code' => $e->getCode(),
106 106
 		'file' => $e->getFile(),
107 107
 		'line' => $e->getLine(),
108 108
 		'stack_trace' => $e->getTraceAsString()
109
-	] );
109
+	]);
110 110
 
111
-	if ( $app['request_stack.is_json'] ) {
112
-		return $app->json( [
111
+	if ($app['request_stack.is_json']) {
112
+		return $app->json([
113 113
 			'ERR' => $e->getMessage()
114
-		] );
114
+		]);
115 115
 	}
116 116
 
117 117
 	return new Response(
118
-		$ffFactory->newInternalErrorHtmlPresenter()->present( $e ),
118
+		$ffFactory->newInternalErrorHtmlPresenter()->present($e),
119 119
 		$code
120 120
 	);
121 121
 } );
Please login to merge, or discard this patch.
HandlePayPalPaymentNotification/HandlePayPalPaymentNotificationUseCase.php 1 patch
Spacing   +96 added lines, -96 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\DonationContext\UseCases\HandlePayPalPaymentNotification;
6 6
 
@@ -34,173 +34,173 @@  discard block
 block discarded – undo
34 34
 	private $mailer;
35 35
 	private $donationEventLogger;
36 36
 
37
-	public function __construct( DonationRepository $repository, DonationAuthorizer $authorizationService,
38
-								 DonationConfirmationMailer $mailer, DonationEventLogger $donationEventLogger ) {
37
+	public function __construct(DonationRepository $repository, DonationAuthorizer $authorizationService,
38
+								 DonationConfirmationMailer $mailer, DonationEventLogger $donationEventLogger) {
39 39
 		$this->repository = $repository;
40 40
 		$this->authorizationService = $authorizationService;
41 41
 		$this->mailer = $mailer;
42 42
 		$this->donationEventLogger = $donationEventLogger;
43 43
 	}
44 44
 
45
-	public function handleNotification( PayPalPaymentNotificationRequest $request ): PaypalNotificationResponse {
46
-		if ( !$request->isSuccessfulPaymentNotification() ) {
47
-			return $this->createUnhandledResponse( 'Unhandled PayPal instant payment notification' );
45
+	public function handleNotification(PayPalPaymentNotificationRequest $request): PaypalNotificationResponse {
46
+		if (!$request->isSuccessfulPaymentNotification()) {
47
+			return $this->createUnhandledResponse('Unhandled PayPal instant payment notification');
48 48
 		}
49 49
 
50
-		if ( $this->isSubscriptionRelatedNonPaymentTransaction( $request ) ) {
51
-			return $this->createUnhandledResponse( 'Unhandled PayPal subscription notification' );
50
+		if ($this->isSubscriptionRelatedNonPaymentTransaction($request)) {
51
+			return $this->createUnhandledResponse('Unhandled PayPal subscription notification');
52 52
 		}
53 53
 
54 54
 		try {
55
-			$donation = $this->repository->getDonationById( $request->getInternalId() );
56
-		} catch ( GetDonationException $ex ) {
57
-			return $this->createErrorResponse( $ex );
55
+			$donation = $this->repository->getDonationById($request->getInternalId());
56
+		} catch (GetDonationException $ex) {
57
+			return $this->createErrorResponse($ex);
58 58
 		}
59 59
 
60
-		if ( $donation === null ) {
61
-			return $this->handleRequestWithoutDonation( $request );
60
+		if ($donation === null) {
61
+			return $this->handleRequestWithoutDonation($request);
62 62
 		}
63 63
 
64
-		return $this->handleRequestForDonation( $request, $donation );
64
+		return $this->handleRequestForDonation($request, $donation);
65 65
 	}
66 66
 
67
-	private function handleRequestWithoutDonation( PayPalPaymentNotificationRequest $request ): PaypalNotificationResponse {
68
-		$donation = $this->newDonationFromRequest( $request );
67
+	private function handleRequestWithoutDonation(PayPalPaymentNotificationRequest $request): PaypalNotificationResponse {
68
+		$donation = $this->newDonationFromRequest($request);
69 69
 
70 70
 		try {
71
-			$this->repository->storeDonation( $donation );
72
-		} catch ( StoreDonationException $ex ) {
73
-			return $this->createErrorResponse( $ex );
71
+			$this->repository->storeDonation($donation);
72
+		} catch (StoreDonationException $ex) {
73
+			return $this->createErrorResponse($ex);
74 74
 		}
75 75
 
76
-		$this->sendConfirmationEmailFor( $donation );
77
-		$this->donationEventLogger->log( $donation->getId(), 'paypal_handler: booked' );
76
+		$this->sendConfirmationEmailFor($donation);
77
+		$this->donationEventLogger->log($donation->getId(), 'paypal_handler: booked');
78 78
 
79 79
 		return PaypalNotificationResponse::newSuccessResponse();
80 80
 	}
81 81
 
82
-	private function handleRequestForDonation( PayPalPaymentNotificationRequest $request, Donation $donation ): PaypalNotificationResponse {
83
-		if ( !( $donation->getPayment()->getPaymentMethod() instanceof PayPalPayment ) ) {
84
-			return $this->createUnhandledResponse( 'Trying to handle IPN for non-Paypal donation' );
82
+	private function handleRequestForDonation(PayPalPaymentNotificationRequest $request, Donation $donation): PaypalNotificationResponse {
83
+		if (!($donation->getPayment()->getPaymentMethod() instanceof PayPalPayment)) {
84
+			return $this->createUnhandledResponse('Trying to handle IPN for non-Paypal donation');
85 85
 		}
86 86
 
87
-		if ( !$this->authorizationService->systemCanModifyDonation( $request->getInternalId() ) ) {
88
-			return $this->createUnhandledResponse( 'Wrong access code for donation' );
87
+		if (!$this->authorizationService->systemCanModifyDonation($request->getInternalId())) {
88
+			return $this->createUnhandledResponse('Wrong access code for donation');
89 89
 		}
90
-		if ( $this->donationWasBookedWithDifferentTransactionId( $donation, $request ) ) {
91
-			return $this->createChildDonation( $donation, $request );
90
+		if ($this->donationWasBookedWithDifferentTransactionId($donation, $request)) {
91
+			return $this->createChildDonation($donation, $request);
92 92
 		}
93 93
 
94
-		$donation->addPayPalData( $this->newPayPalDataFromRequest( $request ) );
94
+		$donation->addPayPalData($this->newPayPalDataFromRequest($request));
95 95
 
96 96
 		try {
97 97
 			$donation->confirmBooked();
98
-		} catch ( \RuntimeException $ex ) {
99
-			return $this->createErrorResponse( $ex );
98
+		} catch (\RuntimeException $ex) {
99
+			return $this->createErrorResponse($ex);
100 100
 		}
101 101
 
102 102
 		try {
103
-			$this->repository->storeDonation( $donation );
103
+			$this->repository->storeDonation($donation);
104 104
 		}
105
-		catch ( StoreDonationException $ex ) {
106
-			return $this->createErrorResponse( $ex );
105
+		catch (StoreDonationException $ex) {
106
+			return $this->createErrorResponse($ex);
107 107
 		}
108 108
 
109
-		$this->sendConfirmationEmailFor( $donation );
110
-		$this->donationEventLogger->log( $donation->getId(), 'paypal_handler: booked' );
109
+		$this->sendConfirmationEmailFor($donation);
110
+		$this->donationEventLogger->log($donation->getId(), 'paypal_handler: booked');
111 111
 
112 112
 		return PaypalNotificationResponse::newSuccessResponse();
113 113
 	}
114 114
 
115
-	private function createUnhandledResponse( string $reason ): PaypalNotificationResponse {
116
-		return PaypalNotificationResponse::newUnhandledResponse( [
115
+	private function createUnhandledResponse(string $reason): PaypalNotificationResponse {
116
+		return PaypalNotificationResponse::newUnhandledResponse([
117 117
 			'message' => $reason
118
-		] );
118
+		]);
119 119
 	}
120 120
 
121
-	private function sendConfirmationEmailFor( Donation $donation ) {
122
-		if ( $donation->getDonor() !== null ) {
121
+	private function sendConfirmationEmailFor(Donation $donation) {
122
+		if ($donation->getDonor() !== null) {
123 123
 			try {
124
-				$this->mailer->sendConfirmationMailFor( $donation );
125
-			} catch ( \RuntimeException $ex ) {
124
+				$this->mailer->sendConfirmationMailFor($donation);
125
+			} catch (\RuntimeException $ex) {
126 126
 				// no need to re-throw or return false, this is not a fatal error, only a minor inconvenience
127 127
 			}
128 128
 		}
129 129
 	}
130 130
 
131
-	private function isSubscriptionRelatedNonPaymentTransaction( PayPalPaymentNotificationRequest $request ): bool {
131
+	private function isSubscriptionRelatedNonPaymentTransaction(PayPalPaymentNotificationRequest $request): bool {
132 132
 		return $request->isForRecurringPayment() && !$request->isRecurringPaymentCompletion();
133 133
 	}
134 134
 
135
-	private function newPayPalDataFromRequest( PayPalPaymentNotificationRequest $request ): PayPalData {
136
-		return ( new PayPalData() )
137
-			->setPayerId( $request->getPayerId() )
138
-			->setSubscriberId( $request->getSubscriptionId() )
139
-			->setPayerStatus( $request->getPayerStatus() )
140
-			->setAddressStatus( $request->getPayerAddressStatus() )
141
-			->setAmount( $request->getAmountGross() )
142
-			->setCurrencyCode( $request->getCurrencyCode() )
143
-			->setFee( Euro::newFromString( $request->getTransactionFee() ) )
144
-			->setSettleAmount( $request->getSettleAmount() )
145
-			->setFirstName( $request->getPayerFirstName() )
146
-			->setLastName( $request->getPayerLastName() )
147
-			->setAddressName( $request->getPayerAddressName() )
148
-			->setPaymentId( $request->getTransactionId() )
149
-			->setPaymentType( $request->getPaymentType() )
150
-			->setPaymentStatus( implode( '/', [ $request->getPaymentStatus(), $request->getTransactionType() ] ) )
151
-			->setPaymentTimestamp( $request->getPaymentTimestamp() );
135
+	private function newPayPalDataFromRequest(PayPalPaymentNotificationRequest $request): PayPalData {
136
+		return (new PayPalData())
137
+			->setPayerId($request->getPayerId())
138
+			->setSubscriberId($request->getSubscriptionId())
139
+			->setPayerStatus($request->getPayerStatus())
140
+			->setAddressStatus($request->getPayerAddressStatus())
141
+			->setAmount($request->getAmountGross())
142
+			->setCurrencyCode($request->getCurrencyCode())
143
+			->setFee(Euro::newFromString($request->getTransactionFee()))
144
+			->setSettleAmount($request->getSettleAmount())
145
+			->setFirstName($request->getPayerFirstName())
146
+			->setLastName($request->getPayerLastName())
147
+			->setAddressName($request->getPayerAddressName())
148
+			->setPaymentId($request->getTransactionId())
149
+			->setPaymentType($request->getPaymentType())
150
+			->setPaymentStatus(implode('/', [$request->getPaymentStatus(), $request->getTransactionType()]))
151
+			->setPaymentTimestamp($request->getPaymentTimestamp());
152 152
 	}
153 153
 
154
-	private function donationWasBookedWithDifferentTransactionId( Donation $donation,
155
-																  PayPalPaymentNotificationRequest $request ): bool {
154
+	private function donationWasBookedWithDifferentTransactionId(Donation $donation,
155
+																  PayPalPaymentNotificationRequest $request): bool {
156 156
 		/**
157 157
 		 * @var PayPalPayment $payment
158 158
 		 */
159 159
 		$payment = $donation->getPaymentMethod();
160 160
 
161
-		if ( !$donation->isBooked() ) {
161
+		if (!$donation->isBooked()) {
162 162
 			return false;
163 163
 		}
164 164
 
165
-		if ( $request->getTransactionId() === $payment->getPayPalData()->getPaymentId() ) {
165
+		if ($request->getTransactionId() === $payment->getPayPalData()->getPaymentId()) {
166 166
 			return false;
167 167
 		}
168 168
 
169
-		if ( $payment->getPayPalData()->hasChildPayment( $request->getTransactionId() ) ) {
169
+		if ($payment->getPayPalData()->hasChildPayment($request->getTransactionId())) {
170 170
 			return false;
171 171
 		}
172 172
 
173 173
 		return true;
174 174
 	}
175 175
 
176
-	private function createChildDonation( Donation $donation, PayPalPaymentNotificationRequest $request ): PaypalNotificationResponse {
177
-		$childPaymentMethod = new PayPalPayment( $this->newPayPalDataFromRequest( $request ) );
176
+	private function createChildDonation(Donation $donation, PayPalPaymentNotificationRequest $request): PaypalNotificationResponse {
177
+		$childPaymentMethod = new PayPalPayment($this->newPayPalDataFromRequest($request));
178 178
 		$payment = $donation->getPayment();
179 179
 		$childDonation = new Donation(
180 180
 			null,
181 181
 			Donation::STATUS_EXTERNAL_BOOKED,
182 182
 			$donation->getDonor(),
183
-			new DonationPayment( $payment->getAmount(), $payment->getIntervalInMonths(), $childPaymentMethod ),
183
+			new DonationPayment($payment->getAmount(), $payment->getIntervalInMonths(), $childPaymentMethod),
184 184
 			$donation->getOptsIntoNewsletter(), $donation->getTrackingInfo()
185 185
 		);
186 186
 		try {
187
-			$this->repository->storeDonation( $childDonation );
188
-		} catch ( StoreDonationException $ex ) {
189
-			return $this->createErrorResponse( $ex );
187
+			$this->repository->storeDonation($childDonation);
188
+		} catch (StoreDonationException $ex) {
189
+			return $this->createErrorResponse($ex);
190 190
 		}
191 191
 		/** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $paymentMethod */
192 192
 		$paymentMethod = $payment->getPaymentMethod();
193
-		$paymentMethod->getPayPalData()->addChildPayment( $request->getTransactionId(), $childDonation->getId() );
193
+		$paymentMethod->getPayPalData()->addChildPayment($request->getTransactionId(), $childDonation->getId());
194 194
 		try {
195
-			$this->repository->storeDonation( $donation );
196
-		} catch ( StoreDonationException $ex ) {
197
-			return $this->createErrorResponse( $ex );
195
+			$this->repository->storeDonation($donation);
196
+		} catch (StoreDonationException $ex) {
197
+			return $this->createErrorResponse($ex);
198 198
 		}
199
-		$this->logChildDonationCreatedEvent( $donation->getId(), $childDonation->getId() );
199
+		$this->logChildDonationCreatedEvent($donation->getId(), $childDonation->getId());
200 200
 		return PaypalNotificationResponse::newSuccessResponse();
201 201
 	}
202 202
 
203
-	private function logChildDonationCreatedEvent( $parentId, $childId ) {
203
+	private function logChildDonationCreatedEvent($parentId, $childId) {
204 204
 		$this->donationEventLogger->log(
205 205
 			$parentId,
206 206
 			"paypal_handler: new transaction id to corresponding child donation: $childId"
@@ -211,51 +211,51 @@  discard block
 block discarded – undo
211 211
 		);
212 212
 	}
213 213
 
214
-	private function newDonorFromRequest( PayPalPaymentNotificationRequest $request ): Donor {
214
+	private function newDonorFromRequest(PayPalPaymentNotificationRequest $request): Donor {
215 215
 		return new Donor(
216
-			$this->newPersonNameFromRequest( $request ),
217
-			$this->newPhysicalAddressFromRequest( $request ),
216
+			$this->newPersonNameFromRequest($request),
217
+			$this->newPhysicalAddressFromRequest($request),
218 218
 			$request->getPayerEmail()
219 219
 		);
220 220
 	}
221 221
 
222
-	private function newPersonNameFromRequest( PayPalPaymentNotificationRequest $request ): DonorName {
222
+	private function newPersonNameFromRequest(PayPalPaymentNotificationRequest $request): DonorName {
223 223
 		$name = DonorName::newPrivatePersonName();
224
-		$name->setFirstName( $request->getPayerFirstName() );
225
-		$name->setLastName( $request->getPayerLastName() );
224
+		$name->setFirstName($request->getPayerFirstName());
225
+		$name->setLastName($request->getPayerLastName());
226 226
 		$name->freeze();
227 227
 		return $name;
228 228
 	}
229 229
 
230
-	private function newPhysicalAddressFromRequest( PayPalPaymentNotificationRequest $request ): DonorAddress {
230
+	private function newPhysicalAddressFromRequest(PayPalPaymentNotificationRequest $request): DonorAddress {
231 231
 		$address = new DonorAddress();
232
-		$address->setStreetAddress( $request->getPayerAddressStreet() );
233
-		$address->setCity( $request->getPayerAddressCity() );
234
-		$address->setPostalCode( $request->getPayerAddressPostalCode() );
235
-		$address->setCountryCode( $request->getPayerAddressCountryCode() );
232
+		$address->setStreetAddress($request->getPayerAddressStreet());
233
+		$address->setCity($request->getPayerAddressCity());
234
+		$address->setPostalCode($request->getPayerAddressPostalCode());
235
+		$address->setCountryCode($request->getPayerAddressCountryCode());
236 236
 		$address->freeze();
237 237
 		return $address;
238 238
 	}
239 239
 
240
-	private function newDonationFromRequest( PayPalPaymentNotificationRequest $request ): Donation {
241
-		$payment = new DonationPayment( $request->getAmountGross(), 0, new PayPalPayment() );
240
+	private function newDonationFromRequest(PayPalPaymentNotificationRequest $request): Donation {
241
+		$payment = new DonationPayment($request->getAmountGross(), 0, new PayPalPayment());
242 242
 		$donation = new Donation(
243 243
 			null,
244 244
 			Donation::STATUS_EXTERNAL_BOOKED,
245
-			$this->newDonorFromRequest( $request ),
245
+			$this->newDonorFromRequest($request),
246 246
 			$payment,
247 247
 			Donation::DOES_NOT_OPT_INTO_NEWSLETTER,
248 248
 			DonationTrackingInfo::newBlankTrackingInfo()->freeze()->assertNoNullFields()
249 249
 		);
250
-		$donation->addPayPalData( $this->newPayPalDataFromRequest( $request ) );
250
+		$donation->addPayPalData($this->newPayPalDataFromRequest($request));
251 251
 		return $donation;
252 252
 	}
253 253
 
254
-	private function createErrorResponse( \Exception $ex ): PaypalNotificationResponse {
255
-		return PaypalNotificationResponse::newFailureResponse( [
254
+	private function createErrorResponse(\Exception $ex): PaypalNotificationResponse {
255
+		return PaypalNotificationResponse::newFailureResponse([
256 256
 			'message' => $ex->getMessage(),
257 257
 			'stackTrace' => $ex->getTraceAsString()
258
-		] );
258
+		]);
259 259
 	}
260 260
 
261 261
 }
Please login to merge, or discard this patch.
src/Factories/FunFunFactory.php 1 patch
Spacing   +163 added lines, -163 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\Factories;
6 6
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	private $profiler = null;
175 175
 
176
-	public function __construct( array $config ) {
176
+	public function __construct(array $config) {
177 177
 		$this->config = $config;
178 178
 		$this->pimple = $this->newPimple();
179 179
 	}
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
 		};
195 195
 
196 196
 		$pimple['dbal_connection'] = function() {
197
-			return DriverManager::getConnection( $this->config['db'] );
197
+			return DriverManager::getConnection($this->config['db']);
198 198
 		};
199 199
 
200 200
 		$pimple['entity_manager'] = function() {
201
-			$entityManager = ( new StoreFactory( $this->getConnection(), $this->getVarPath() . '/doctrine_proxies' ) )
201
+			$entityManager = (new StoreFactory($this->getConnection(), $this->getVarPath() . '/doctrine_proxies'))
202 202
 				->getEntityManager();
203
-			if ( $this->addDoctrineSubscribers ) {
204
-				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() );
205
-				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() );
203
+			if ($this->addDoctrineSubscribers) {
204
+				$entityManager->getEventManager()->addEventSubscriber($this->newDoctrineDonationPrePersistSubscriber());
205
+				$entityManager->getEventManager()->addEventSubscriber($this->newDoctrineMembershipApplicationPrePersistSubscriber());
206 206
 			}
207 207
 
208 208
 			return $entityManager;
@@ -210,53 +210,53 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$pimple['subscription_repository'] = function() {
212 212
 			return new LoggingSubscriptionRepository(
213
-				new DoctrineSubscriptionRepository( $this->getEntityManager() ),
213
+				new DoctrineSubscriptionRepository($this->getEntityManager()),
214 214
 				$this->getLogger()
215 215
 			);
216 216
 		};
217 217
 
218 218
 		$pimple['donation_repository'] = function() {
219 219
 			return new LoggingDonationRepository(
220
-				new DoctrineDonationRepository( $this->getEntityManager() ),
220
+				new DoctrineDonationRepository($this->getEntityManager()),
221 221
 				$this->getLogger()
222 222
 			);
223 223
 		};
224 224
 
225 225
 		$pimple['membership_application_repository'] = function() {
226 226
 			return new LoggingApplicationRepository(
227
-				new DoctrineApplicationRepository( $this->getEntityManager() ),
227
+				new DoctrineApplicationRepository($this->getEntityManager()),
228 228
 				$this->getLogger()
229 229
 			);
230 230
 		};
231 231
 
232 232
 		$pimple['comment_repository'] = function() {
233 233
 			$finder = new LoggingCommentFinder(
234
-				new DoctrineCommentFinder( $this->getEntityManager() ),
234
+				new DoctrineCommentFinder($this->getEntityManager()),
235 235
 				$this->getLogger()
236 236
 			);
237 237
 
238
-			return $this->addProfilingDecorator( $finder, 'CommentFinder' );
238
+			return $this->addProfilingDecorator($finder, 'CommentFinder');
239 239
 		};
240 240
 
241 241
 		$pimple['mail_validator'] = function() {
242
-			return new EmailValidator( new InternetDomainNameValidator() );
242
+			return new EmailValidator(new InternetDomainNameValidator());
243 243
 		};
244 244
 
245 245
 		$pimple['subscription_validator'] = function() {
246 246
 			return new SubscriptionValidator(
247 247
 				$this->getEmailValidator(),
248
-				$this->newTextPolicyValidator( 'fields' ),
248
+				$this->newTextPolicyValidator('fields'),
249 249
 				$this->newSubscriptionDuplicateValidator(),
250 250
 				$this->newHonorificValidator()
251 251
 			);
252 252
 		};
253 253
 
254 254
 		$pimple['template_name_validator'] = function() {
255
-			return new TemplateNameValidator( $this->getTwig() );
255
+			return new TemplateNameValidator($this->getTwig());
256 256
 		};
257 257
 
258 258
 		$pimple['contact_validator'] = function() {
259
-			return new GetInTouchValidator( $this->getEmailValidator() );
259
+			return new GetInTouchValidator($this->getEmailValidator());
260 260
 		};
261 261
 
262 262
 		$pimple['greeting_generator'] = function() {
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 
266 266
 		$pimple['guzzle_client'] = function() {
267 267
 			$middlewareFactory = new MiddlewareFactory();
268
-			$middlewareFactory->setLogger( $this->getLogger() );
268
+			$middlewareFactory->setLogger($this->getLogger());
269 269
 
270
-			$handlerStack = HandlerStack::create( new CurlHandler() );
271
-			$handlerStack->push( $middlewareFactory->retry() );
270
+			$handlerStack = HandlerStack::create(new CurlHandler());
271
+			$handlerStack->push($middlewareFactory->retry());
272 272
 
273
-			$guzzle = new Client( [
273
+			$guzzle = new Client([
274 274
 				'cookies' => true,
275 275
 				'handler' => $handlerStack,
276
-				'headers' => [ 'User-Agent' => 'WMDE Fundraising Frontend' ],
277
-			] );
276
+				'headers' => ['User-Agent' => 'WMDE Fundraising Frontend'],
277
+			]);
278 278
 
279
-			return $this->addProfilingDecorator( $guzzle, 'Guzzle Client' );
279
+			return $this->addProfilingDecorator($guzzle, 'Guzzle Client');
280 280
 		};
281 281
 
282 282
 		$pimple['translator'] = function() {
@@ -286,27 +286,27 @@  discard block
 block discarded – undo
286 286
 			];
287 287
 			$locale = $this->config['locale'];
288 288
 			$messagesPath = __DIR__ . '/../../' . $this->config['i18n-base-path'] . '/' . $locale;
289
-			$translator = $translationFactory->create( $loaders, $locale );
290
-			$translator->addResource( 'json', $messagesPath . '/messages.json', $locale );
291
-			$translator->addResource( 'json', $messagesPath . '/paymentTypes.json', $locale, 'paymentTypes' );
292
-			$translator->addResource( 'json', $messagesPath . '/paymentIntervals.json', $locale, 'paymentIntervals' );
293
-			$translator->addResource( 'json', $messagesPath . '/paymentStatus.json', $locale, 'paymentStatus' );
294
-			$translator->addResource( 'json', $messagesPath . '/validations.json', $locale, 'validations' );
289
+			$translator = $translationFactory->create($loaders, $locale);
290
+			$translator->addResource('json', $messagesPath . '/messages.json', $locale);
291
+			$translator->addResource('json', $messagesPath . '/paymentTypes.json', $locale, 'paymentTypes');
292
+			$translator->addResource('json', $messagesPath . '/paymentIntervals.json', $locale, 'paymentIntervals');
293
+			$translator->addResource('json', $messagesPath . '/paymentStatus.json', $locale, 'paymentStatus');
294
+			$translator->addResource('json', $messagesPath . '/validations.json', $locale, 'validations');
295 295
 
296 296
 			return $translator;
297 297
 		};
298 298
 
299 299
 		// In the future, this could be locale-specific or filled from a DB table
300 300
 		$pimple['honorifics'] = function() {
301
-			return new Honorifics( [
301
+			return new Honorifics([
302 302
 				'' => 'Kein Titel',
303 303
 				'Dr.' => 'Dr.',
304 304
 				'Prof.' => 'Prof.',
305 305
 				'Prof. Dr.' => 'Prof. Dr.'
306
-			] );
306
+			]);
307 307
 		};
308 308
 
309
-		$pimple['twig_factory'] = function () {
309
+		$pimple['twig_factory'] = function() {
310 310
 			return new TwigEnvironmentConfigurator(
311 311
 				$this->pimple['twig_environment'],
312 312
 				$this->config['twig'],
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 
318 318
 		$pimple['twig'] = function() {
319 319
 			$twigFactory = $this->getTwigFactory();
320
-			$loaders = array_filter( [
320
+			$loaders = array_filter([
321 321
 				$twigFactory->newFileSystemLoader(),
322 322
 				$twigFactory->newArrayLoader(), // This is just a fallback for testing
323
-			] );
323
+			]);
324 324
 			$extensions = [
325
-				$twigFactory->newTranslationExtension( $this->getTranslator() ),
325
+				$twigFactory->newTranslationExtension($this->getTranslator()),
326 326
 				new Twig_Extensions_Extension_Intl()
327 327
 			];
328 328
 			$filters = [
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 				)
332 332
 			];
333 333
 
334
-			return $twigFactory->getEnvironment( $loaders, $extensions, $filters );
334
+			return $twigFactory->getEnvironment($loaders, $extensions, $filters);
335 335
 		};
336 336
 
337 337
 		$pimple['messenger_suborganization'] = function() {
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		};
352 352
 
353 353
 		$pimple['confirmation-page-selector'] = function() {
354
-			return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] );
354
+			return new DonationConfirmationPageSelector($this->config['confirmation-pages']);
355 355
 		};
356 356
 
357 357
 		$pimple['paypal-payment-notification-verifier'] = function() {
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 		$pimple['token_generator'] = function() {
391 391
 			return new RandomTokenGenerator(
392 392
 				$this->config['token-length'],
393
-				new \DateInterval( $this->config['token-validity-timestamp'] )
393
+				new \DateInterval($this->config['token-validity-timestamp'])
394 394
 			);
395 395
 		};
396 396
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 			return new VoidCache();
403 403
 		};
404 404
 
405
-		$pimple['page_view_tracker'] = function () {
406
-			return new PageViewTracker( $this->newServerSideTracker(), $this->config['piwik']['siteUrlBase'] );
405
+		$pimple['page_view_tracker'] = function() {
406
+			return new PageViewTracker($this->newServerSideTracker(), $this->config['piwik']['siteUrlBase']);
407 407
 		};
408 408
 
409 409
 		return $pimple;
@@ -419,17 +419,17 @@  discard block
 block discarded – undo
419 419
 
420 420
 	private function newDonationEventLogger(): DonationEventLogger {
421 421
 		return new BestEffortDonationEventLogger(
422
-			new DoctrineDonationEventLogger( $this->getEntityManager() ),
422
+			new DoctrineDonationEventLogger($this->getEntityManager()),
423 423
 			$this->getLogger()
424 424
 		);
425 425
 	}
426 426
 
427 427
 	public function newInstaller(): Installer {
428
-		return ( new StoreFactory( $this->getConnection() ) )->newInstaller();
428
+		return (new StoreFactory($this->getConnection()))->newInstaller();
429 429
 	}
430 430
 
431 431
 	public function newListCommentsUseCase(): ListCommentsUseCase {
432
-		return new ListCommentsUseCase( $this->getCommentFinder() );
432
+		return new ListCommentsUseCase($this->getCommentFinder());
433 433
 	}
434 434
 
435 435
 	public function newCommentListJsonPresenter(): CommentListJsonPresenter {
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	public function newCommentListRssPresenter(): CommentListRssPresenter {
440
-		return new CommentListRssPresenter( new TwigTemplate(
440
+		return new CommentListRssPresenter(new TwigTemplate(
441 441
 			$this->getTwig(),
442 442
 			'Comment_List.rss.twig'
443
-		) );
443
+		));
444 444
 	}
445 445
 
446 446
 	public function newCommentListHtmlPresenter(): CommentListHtmlPresenter {
447
-		return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'Comment_List.html.twig', [ 'piwikGoals' => [ 1 ] ] ) );
447
+		return new CommentListHtmlPresenter($this->getLayoutTemplate('Comment_List.html.twig', ['piwikGoals' => [1]]));
448 448
 	}
449 449
 
450 450
 	private function getCommentFinder(): CommentFinder {
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		return $this->pimple['subscription_repository'];
456 456
 	}
457 457
 
458
-	public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) {
458
+	public function setSubscriptionRepository(SubscriptionRepository $subscriptionRepository) {
459 459
 		$this->pimple['subscription_repository'] = $subscriptionRepository;
460 460
 	}
461 461
 
@@ -472,25 +472,25 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 
474 474
 	public function newAddSubscriptionHtmlPresenter(): AddSubscriptionHtmlPresenter {
475
-		return new AddSubscriptionHtmlPresenter( $this->getIncludeTemplate( 'Subscription_Form.html.twig' ), $this->getTranslator() );
475
+		return new AddSubscriptionHtmlPresenter($this->getIncludeTemplate('Subscription_Form.html.twig'), $this->getTranslator());
476 476
 	}
477 477
 
478 478
 	public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter {
479 479
 		return new ConfirmSubscriptionHtmlPresenter(
480
-			$this->getLayoutTemplate( 'Confirm_Subscription.twig' ),
480
+			$this->getLayoutTemplate('Confirm_Subscription.twig'),
481 481
 			$this->getTranslator()
482 482
 		);
483 483
 	}
484 484
 
485 485
 	public function newAddSubscriptionJsonPresenter(): AddSubscriptionJsonPresenter {
486
-		return new AddSubscriptionJsonPresenter( $this->getTranslator() );
486
+		return new AddSubscriptionJsonPresenter($this->getTranslator());
487 487
 	}
488 488
 
489 489
 	public function newGetInTouchHtmlPresenter(): GetInTouchHtmlPresenter {
490
-		return new GetInTouchHtmlPresenter( $this->getIncludeTemplate( 'Kontaktformular.html.twig' ), $this->getTranslator() );
490
+		return new GetInTouchHtmlPresenter($this->getIncludeTemplate('Kontaktformular.html.twig'), $this->getTranslator());
491 491
 	}
492 492
 
493
-	public function setTwigEnvironment( Twig_Environment $twig ) {
493
+	public function setTwigEnvironment(Twig_Environment $twig) {
494 494
 		$this->pimple['twig_environment'] = $twig;
495 495
 	}
496 496
 
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
 	 * @param array $context Additional variables for the template
506 506
 	 * @return TwigTemplate
507 507
 	 */
508
-	public function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate {
508
+	public function getLayoutTemplate(string $templateName, array $context = []): TwigTemplate {
509 509
 		 return new TwigTemplate(
510 510
 			$this->getTwig(),
511 511
 			$templateName,
512
-			array_merge( $this->getDefaultTwigVariables(), $context )
512
+			array_merge($this->getDefaultTwigVariables(), $context)
513 513
 		);
514 514
 	}
515 515
 
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 	 * @param string $templateName Template to include
520 520
 	 * @return TwigTemplate
521 521
 	 */
522
-	private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate {
522
+	private function getIncludeTemplate(string $templateName, array $context = []): TwigTemplate {
523 523
 		return new TwigTemplate(
524 524
 			$this->getTwig(),
525 525
 			'Include_in_Layout.twig',
526 526
 			array_merge(
527 527
 				$this->getDefaultTwigVariables(),
528
-				[ 'main_template' => $templateName ],
528
+				['main_template' => $templateName],
529 529
 				$context
530 530
 			)
531 531
 		);
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 			$this->getLogger()
561 561
 		);
562 562
 
563
-		return $this->addProfilingDecorator( $pageRetriever, 'PageRetriever' );
563
+		return $this->addProfilingDecorator($pageRetriever, 'PageRetriever');
564 564
 	}
565 565
 
566 566
 	public function getLogger(): LoggerInterface {
@@ -623,22 +623,22 @@  discard block
 block discarded – undo
623 623
 			new TwigTemplate(
624 624
 					$this->getTwig(),
625 625
 					'Mail_Subscription_Confirmation.txt.twig',
626
-					[ 'greeting_generator' => $this->getGreetingGenerator() ]
626
+					['greeting_generator' => $this->getGreetingGenerator()]
627 627
 			),
628 628
 			'mail_subject_subscription_confirmed'
629 629
 		);
630 630
 	}
631 631
 
632
-	private function newTemplateMailer( Messenger $messenger, TwigTemplate $template, string $messageKey ): TemplateBasedMailer {
632
+	private function newTemplateMailer(Messenger $messenger, TwigTemplate $template, string $messageKey): TemplateBasedMailer {
633 633
 		$mailer = new TemplateBasedMailer(
634 634
 			$messenger,
635 635
 			$template,
636
-			$this->getTranslator()->trans( $messageKey )
636
+			$this->getTranslator()->trans($messageKey)
637 637
 		);
638 638
 
639
-		$mailer = new LoggingMailer( $mailer, $this->getLogger() );
639
+		$mailer = new LoggingMailer($mailer, $this->getLogger());
640 640
 
641
-		return $this->addProfilingDecorator( $mailer, 'Mailer' );
641
+		return $this->addProfilingDecorator($mailer, 'Mailer');
642 642
 	}
643 643
 
644 644
 	public function getGreetingGenerator() {
@@ -646,11 +646,11 @@  discard block
 block discarded – undo
646 646
 	}
647 647
 
648 648
 	public function newCheckIbanUseCase(): CheckIbanUseCase {
649
-		return new CheckIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
649
+		return new CheckIbanUseCase($this->newBankDataConverter(), $this->newIbanValidator());
650 650
 	}
651 651
 
652 652
 	public function newGenerateIbanUseCase(): GenerateIbanUseCase {
653
-		return new GenerateIbanUseCase( $this->newBankDataConverter(), $this->newIbanValidator() );
653
+		return new GenerateIbanUseCase($this->newBankDataConverter(), $this->newIbanValidator());
654 654
 	}
655 655
 
656 656
 	public function newIbanPresenter(): IbanPresenter {
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
 	}
659 659
 
660 660
 	public function newBankDataConverter() {
661
-		return new BankDataConverter( $this->config['bank-data-file'] );
661
+		return new BankDataConverter($this->config['bank-data-file']);
662 662
 	}
663 663
 
664
-	public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) {
664
+	public function setSubscriptionValidator(SubscriptionValidator $subscriptionValidator) {
665 665
 		$this->pimple['subscription_validator'] = $subscriptionValidator;
666 666
 	}
667 667
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	private function newContactUserMailer(): TemplateBasedMailer {
677 677
 		return $this->newTemplateMailer(
678 678
 			$this->getSuborganizationMessenger(),
679
-			new TwigTemplate( $this->getTwig(), 'Mail_Contact_Confirm_to_User.txt.twig' ),
679
+			new TwigTemplate($this->getTwig(), 'Mail_Contact_Confirm_to_User.txt.twig'),
680 680
 			'mail_subject_getintouch'
681 681
 		);
682 682
 	}
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	private function newContactOperatorMailer(): OperatorMailer {
685 685
 		return new OperatorMailer(
686 686
 			$this->getSuborganizationMessenger(),
687
-			new TwigTemplate( $this->getTwig(), 'Mail_Contact_Forward_to_Operator.txt.twig' ),
688
-			$this->getTranslator()->trans( 'mail_subject_getintouch_forward' )
687
+			new TwigTemplate($this->getTwig(), 'Mail_Contact_Forward_to_Operator.txt.twig'),
688
+			$this->getTranslator()->trans('mail_subject_getintouch_forward')
689 689
 		);
690 690
 	}
691 691
 
@@ -702,12 +702,12 @@  discard block
 block discarded – undo
702 702
 
703 703
 	private function newSubscriptionDuplicateCutoffDate(): \DateTime {
704 704
 		$cutoffDateTime = new \DateTime();
705
-		$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) );
705
+		$cutoffDateTime->sub(new \DateInterval($this->config['subscription-interval']));
706 706
 		return $cutoffDateTime;
707 707
 	}
708 708
 
709 709
 	private function newHonorificValidator(): AllowedValuesValidator {
710
-		return new AllowedValuesValidator( $this->getHonorifics()->getKeys() );
710
+		return new AllowedValuesValidator($this->getHonorifics()->getKeys());
711 711
 	}
712 712
 
713 713
 	private function getHonorifics(): Honorifics {
@@ -716,20 +716,20 @@  discard block
 block discarded – undo
716 716
 
717 717
 	public function newAuthorizedCachePurger(): AuthorizedCachePurger {
718 718
 		return new AuthorizedCachePurger(
719
-			new AllOfTheCachePurger( $this->getTwig(), $this->getPageCache(), $this->getRenderedPageCache() ),
719
+			new AllOfTheCachePurger($this->getTwig(), $this->getPageCache(), $this->getRenderedPageCache()),
720 720
 			$this->config['purging-secret']
721 721
 		);
722 722
 	}
723 723
 
724 724
 	private function newBankDataValidator(): BankDataValidator {
725
-		return new BankDataValidator( $this->newIbanValidator() );
725
+		return new BankDataValidator($this->newIbanValidator());
726 726
 	}
727 727
 
728 728
 	private function getSuborganizationMessenger(): Messenger {
729 729
 		return $this->pimple['messenger_suborganization'];
730 730
 	}
731 731
 
732
-	public function setSuborganizationMessenger( Messenger $messenger ) {
732
+	public function setSuborganizationMessenger(Messenger $messenger) {
733 733
 		$this->pimple['messenger_suborganization'] = $messenger;
734 734
 	}
735 735
 
@@ -737,42 +737,42 @@  discard block
 block discarded – undo
737 737
 		return $this->pimple['messenger_organization'];
738 738
 	}
739 739
 
740
-	public function setOrganizationMessenger( Messenger $messenger ) {
740
+	public function setOrganizationMessenger(Messenger $messenger) {
741 741
 		$this->pimple['messenger_organization'] = $messenger;
742 742
 	}
743 743
 
744 744
 	public function setNullMessenger() {
745
-		$this->setSuborganizationMessenger( new Messenger(
745
+		$this->setSuborganizationMessenger(new Messenger(
746 746
 			Swift_NullTransport::newInstance(),
747 747
 			$this->getSubOrganizationEmailAddress()
748
-		) );
749
-		$this->setOrganizationMessenger( new Messenger(
748
+		));
749
+		$this->setOrganizationMessenger(new Messenger(
750 750
 			Swift_NullTransport::newInstance(),
751 751
 			$this->getOrganizationEmailAddress()
752
-		) );
752
+		));
753 753
 	}
754 754
 
755 755
 	public function getSubOrganizationEmailAddress(): EmailAddress {
756
-		return new EmailAddress( $this->config['contact-info']['suborganization']['email'] );
756
+		return new EmailAddress($this->config['contact-info']['suborganization']['email']);
757 757
 	}
758 758
 
759 759
 	public function getOrganizationEmailAddress() {
760
-		return new EmailAddress( $this->config['contact-info']['organization']['email'] );
760
+		return new EmailAddress($this->config['contact-info']['organization']['email']);
761 761
 	}
762 762
 
763 763
 	public function newInternalErrorHtmlPresenter(): InternalErrorHtmlPresenter {
764
-		return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'Error_Page.html.twig' ) );
764
+		return new InternalErrorHtmlPresenter($this->getIncludeTemplate('Error_Page.html.twig'));
765 765
 	}
766 766
 
767 767
 	public function newAccessDeniedHtmlPresenter(): InternalErrorHtmlPresenter {
768
-		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'Access_Denied.twig' ) );
768
+		return new InternalErrorHtmlPresenter($this->getLayoutTemplate('Access_Denied.twig'));
769 769
 	}
770 770
 
771 771
 	public function getTranslator(): TranslatorInterface {
772 772
 		return $this->pimple['translator'];
773 773
 	}
774 774
 
775
-	public function setTranslator( TranslatorInterface $translator ) {
775
+	public function setTranslator(TranslatorInterface $translator) {
776 776
 		$this->pimple['translator'] = $translator;
777 777
 	}
778 778
 
@@ -780,24 +780,24 @@  discard block
 block discarded – undo
780 780
 		return $this->pimple['twig_factory'];
781 781
 	}
782 782
 
783
-	private function newTextPolicyValidator( string $policyName ): TextPolicyValidator {
783
+	private function newTextPolicyValidator(string $policyName): TextPolicyValidator {
784 784
 		$contentProvider = $this->newLocalFilePageRetriever();
785 785
 		$textPolicyConfig = $this->config['text-policies'][$policyName];
786 786
 		return new TextPolicyValidator(
787
-			new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['badwords'] ?? '' ),
788
-			new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['whitewords'] ?? '' )
787
+			new PageRetrieverBasedStringList($contentProvider, $textPolicyConfig['badwords'] ?? ''),
788
+			new PageRetrieverBasedStringList($contentProvider, $textPolicyConfig['whitewords'] ?? '')
789 789
 		);
790 790
 	}
791 791
 
792 792
 	private function newCommentPolicyValidator(): TextPolicyValidator {
793
-		return $this->newTextPolicyValidator( 'comment' );
793
+		return $this->newTextPolicyValidator('comment');
794 794
 	}
795 795
 
796
-	public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase {
796
+	public function newCancelDonationUseCase(string $updateToken): CancelDonationUseCase {
797 797
 		return new CancelDonationUseCase(
798 798
 			$this->getDonationRepository(),
799 799
 			$this->newCancelDonationMailer(),
800
-			$this->newDonationAuthorizer( $updateToken ),
800
+			$this->newDonationAuthorizer($updateToken),
801 801
 			$this->newDonationEventLogger()
802 802
 		);
803 803
 	}
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 			new TwigTemplate(
809 809
 				$this->getTwig(),
810 810
 				'Mail_Donation_Cancellation_Confirmation.txt.twig',
811
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
811
+				['greeting_generator' => $this->getGreetingGenerator()]
812 812
 			),
813 813
 			'mail_subject_confirm_cancellation'
814 814
 		);
@@ -867,27 +867,27 @@  discard block
 block discarded – undo
867 867
 	}
868 868
 
869 869
 	public function newPayPalUrlGeneratorForDonations() {
870
-		return new PayPalUrlGenerator( $this->getPayPalUrlConfigForDonations() );
870
+		return new PayPalUrlGenerator($this->getPayPalUrlConfigForDonations());
871 871
 	}
872 872
 
873 873
 	public function newPayPalUrlGeneratorForMembershipApplications() {
874
-		return new PayPalUrlGenerator( $this->getPayPalUrlConfigForMembershipApplications() );
874
+		return new PayPalUrlGenerator($this->getPayPalUrlConfigForMembershipApplications());
875 875
 	}
876 876
 
877 877
 	private function getPayPalUrlConfigForDonations() {
878
-		return PayPalUrlConfig::newFromConfig( $this->config['paypal-donation'] );
878
+		return PayPalUrlConfig::newFromConfig($this->config['paypal-donation']);
879 879
 	}
880 880
 
881 881
 	private function getPayPalUrlConfigForMembershipApplications() {
882
-		return PayPalUrlConfig::newFromConfig( $this->config['paypal-membership'] );
882
+		return PayPalUrlConfig::newFromConfig($this->config['paypal-membership']);
883 883
 	}
884 884
 
885 885
 	private function newCreditCardUrlGenerator() {
886
-		return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() );
886
+		return new CreditCardUrlGenerator($this->newCreditCardUrlConfig());
887 887
 	}
888 888
 
889 889
 	private function newCreditCardUrlConfig() {
890
-		return CreditCardUrlConfig::newFromConfig( $this->config['creditcard'] );
890
+		return CreditCardUrlConfig::newFromConfig($this->config['creditcard']);
891 891
 	}
892 892
 
893 893
 	public function getDonationRepository(): DonationRepository {
@@ -895,27 +895,27 @@  discard block
 block discarded – undo
895 895
 	}
896 896
 
897 897
 	public function newPaymentDataValidator(): PaymentDataValidator {
898
-		return new PaymentDataValidator( $this->config['donation-minimum-amount'], $this->config['donation-maximum-amount'] );
898
+		return new PaymentDataValidator($this->config['donation-minimum-amount'], $this->config['donation-maximum-amount']);
899 899
 	}
900 900
 
901 901
 	private function newAmountFormatter(): AmountFormatter {
902
-		return new AmountFormatter( $this->config['locale'] );
902
+		return new AmountFormatter($this->config['locale']);
903 903
 	}
904 904
 
905 905
 	public function newDecimalNumberFormatter(): NumberFormatter {
906
-		return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL );
906
+		return new NumberFormatter($this->config['locale'], NumberFormatter::DECIMAL);
907 907
 	}
908 908
 
909
-	public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase {
909
+	public function newAddCommentUseCase(string $updateToken): AddCommentUseCase {
910 910
 		return new AddCommentUseCase(
911 911
 			$this->getDonationRepository(),
912
-			$this->newDonationAuthorizer( $updateToken ),
912
+			$this->newDonationAuthorizer($updateToken),
913 913
 			$this->newCommentPolicyValidator(),
914 914
 			$this->newAddCommentValidator()
915 915
 		);
916 916
 	}
917 917
 
918
-	private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer {
918
+	private function newDonationAuthorizer(string $updateToken = null, string $accessToken = null): DonationAuthorizer {
919 919
 		return new DoctrineDonationAuthorizer(
920 920
 			$this->getEntityManager(),
921 921
 			$updateToken,
@@ -929,13 +929,13 @@  discard block
 block discarded – undo
929 929
 
930 930
 	public function newDonationConfirmationPresenter() {
931 931
 		return new DonationConfirmationHtmlPresenter(
932
-			$this->getIncludeTemplate( 'Donation_Confirmation.html.twig', [ 'piwikGoals' => [ 3 ] ] )
932
+			$this->getIncludeTemplate('Donation_Confirmation.html.twig', ['piwikGoals' => [3]])
933 933
 		);
934 934
 	}
935 935
 
936 936
 	public function newCreditCardPaymentHtmlPresenter() {
937 937
 		return new CreditCardPaymentHtmlPresenter(
938
-			$this->getIncludeTemplate( 'Credit_Card_Payment_Iframe.html.twig' ),
938
+			$this->getIncludeTemplate('Credit_Card_Payment_Iframe.html.twig'),
939 939
 			$this->getTranslator(),
940 940
 			$this->newCreditCardUrlGenerator()
941 941
 		);
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 
944 944
 	public function newCancelDonationHtmlPresenter() {
945 945
 		return new CancelDonationHtmlPresenter(
946
-			$this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.html.twig' )
946
+			$this->getIncludeTemplate('Donation_Cancellation_Confirmation.html.twig')
947 947
 		);
948 948
 	}
949 949
 
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 			new TwigTemplate(
966 966
 				$this->getTwig(),
967 967
 				'Mail_Membership_Application_Confirmation.txt.twig',
968
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
968
+				['greeting_generator' => $this->getGreetingGenerator()]
969 969
 			),
970 970
 			'mail_subject_confirm_membership_application'
971 971
 		);
@@ -980,23 +980,23 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	private function newMembershipApplicationTracker(): ApplicationTracker {
983
-		return new DoctrineApplicationTracker( $this->getEntityManager() );
983
+		return new DoctrineApplicationTracker($this->getEntityManager());
984 984
 	}
985 985
 
986 986
 	private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker {
987
-		return new DoctrineApplicationPiwikTracker( $this->getEntityManager() );
987
+		return new DoctrineApplicationPiwikTracker($this->getEntityManager());
988 988
 	}
989 989
 
990 990
 	private function newApplyForMembershipPolicyValidator(): ApplyForMembershipPolicyValidator {
991 991
 		return new ApplyForMembershipPolicyValidator(
992
-			$this->newTextPolicyValidator( 'fields' ),
992
+			$this->newTextPolicyValidator('fields'),
993 993
 			$this->config['email-address-blacklist']
994 994
 		);
995 995
 	}
996 996
 
997
-	public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase {
997
+	public function newCancelMembershipApplicationUseCase(string $updateToken): CancelMembershipApplicationUseCase {
998 998
 		return new CancelMembershipApplicationUseCase(
999
-			$this->newMembershipApplicationAuthorizer( $updateToken ),
999
+			$this->newMembershipApplicationAuthorizer($updateToken),
1000 1000
 			$this->getMembershipApplicationRepository(),
1001 1001
 			$this->newCancelMembershipApplicationMailer()
1002 1002
 		);
@@ -1022,28 +1022,28 @@  discard block
 block discarded – undo
1022 1022
 			new TwigTemplate(
1023 1023
 				$this->getTwig(),
1024 1024
 				'Mail_Membership_Application_Cancellation_Confirmation.txt.twig',
1025
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
1025
+				['greeting_generator' => $this->getGreetingGenerator()]
1026 1026
 			),
1027 1027
 			'mail_subject_confirm_membership_application_cancellation'
1028 1028
 		);
1029 1029
 	}
1030 1030
 
1031
-	public function newMembershipApplicationConfirmationUseCase( string $accessToken ) {
1031
+	public function newMembershipApplicationConfirmationUseCase(string $accessToken) {
1032 1032
 		return new ShowMembershipApplicationConfirmationUseCase(
1033
-			$this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(),
1033
+			$this->newMembershipApplicationAuthorizer(null, $accessToken), $this->getMembershipApplicationRepository(),
1034 1034
 			$this->newMembershipApplicationTokenFetcher()
1035 1035
 		);
1036 1036
 	}
1037 1037
 
1038
-	public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase {
1038
+	public function newShowDonationConfirmationUseCase(string $accessToken): ShowDonationConfirmationUseCase {
1039 1039
 		return new ShowDonationConfirmationUseCase(
1040
-			$this->newDonationAuthorizer( null, $accessToken ),
1040
+			$this->newDonationAuthorizer(null, $accessToken),
1041 1041
 			$this->newDonationTokenFetcher(),
1042 1042
 			$this->getDonationRepository()
1043 1043
 		);
1044 1044
 	}
1045 1045
 
1046
-	public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) {
1046
+	public function setDonationConfirmationPageSelector(DonationConfirmationPageSelector $selector) {
1047 1047
 		$this->pimple['confirmation-page-selector'] = $selector;
1048 1048
 	}
1049 1049
 
@@ -1054,39 +1054,39 @@  discard block
 block discarded – undo
1054 1054
 	public function newDonationFormViolationPresenter() {
1055 1055
 		// TODO make the template name dependent on the 'form' value from the HTTP POST request
1056 1056
 		// (we need different form pages for A/B testing)
1057
-		$template = $this->getLayoutTemplate( 'Display_Page_Layout.twig', [ 'main_template' => 'Donation_Form.html.twig' ] );
1058
-		return new DonationFormViolationPresenter( $template, $this->newAmountFormatter() );
1057
+		$template = $this->getLayoutTemplate('Display_Page_Layout.twig', ['main_template' => 'Donation_Form.html.twig']);
1058
+		return new DonationFormViolationPresenter($template, $this->newAmountFormatter());
1059 1059
 	}
1060 1060
 
1061 1061
 	public function newDonationFormPresenter() {
1062 1062
 		// TODO make the template name dependent on the 'form' value from the HTTP POST request
1063 1063
 		// (we need different form pages for A/B testing)
1064
-		$template = $this->getLayoutTemplate( 'Display_Page_Layout.twig', [ 'main_template' => 'Donation_Form.html.twig' ] );
1065
-		return new DonationFormPresenter( $template, $this->newAmountFormatter() );
1064
+		$template = $this->getLayoutTemplate('Display_Page_Layout.twig', ['main_template' => 'Donation_Form.html.twig']);
1065
+		return new DonationFormPresenter($template, $this->newAmountFormatter());
1066 1066
 	}
1067 1067
 
1068
-	public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) {
1068
+	public function newHandlePayPalPaymentNotificationUseCase(string $updateToken) {
1069 1069
 		return new HandlePayPalPaymentNotificationUseCase(
1070 1070
 			$this->getDonationRepository(),
1071
-			$this->newDonationAuthorizer( $updateToken ),
1071
+			$this->newDonationAuthorizer($updateToken),
1072 1072
 			$this->newDonationConfirmationMailer(),
1073 1073
 			$this->newDonationEventLogger()
1074 1074
 		);
1075 1075
 	}
1076 1076
 
1077
-	public function newMembershipApplicationSubscriptionSignupNotificationUseCase( string $updateToken ) {
1077
+	public function newMembershipApplicationSubscriptionSignupNotificationUseCase(string $updateToken) {
1078 1078
 		return new HandleSubscriptionSignupNotificationUseCase(
1079 1079
 			$this->getMembershipApplicationRepository(),
1080
-			$this->newMembershipApplicationAuthorizer( $updateToken ),
1080
+			$this->newMembershipApplicationAuthorizer($updateToken),
1081 1081
 			$this->newApplyForMembershipMailer(),
1082 1082
 			$this->getLogger()
1083 1083
 		);
1084 1084
 	}
1085 1085
 
1086
-	public function newMembershipApplicationSubscriptionPaymentNotificationUseCase( string $updateToken ) {
1086
+	public function newMembershipApplicationSubscriptionPaymentNotificationUseCase(string $updateToken) {
1087 1087
 		return new HandleSubscriptionPaymentNotificationUseCase(
1088 1088
 			$this->getMembershipApplicationRepository(),
1089
-			$this->newMembershipApplicationAuthorizer( $updateToken ),
1089
+			$this->newMembershipApplicationAuthorizer($updateToken),
1090 1090
 			$this->newApplyForMembershipMailer(),
1091 1091
 			$this->getLogger()
1092 1092
 		);
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 		return $this->pimple['paypal-payment-notification-verifier'];
1097 1097
 	}
1098 1098
 
1099
-	public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) {
1099
+	public function setPayPalPaymentNotificationVerifier(PaymentNotificationVerifier $verifier) {
1100 1100
 		$this->pimple['paypal-payment-notification-verifier'] = $verifier;
1101 1101
 	}
1102 1102
 
@@ -1104,14 +1104,14 @@  discard block
 block discarded – undo
1104 1104
 		return $this->pimple['paypal-membership-fee-notification-verifier'];
1105 1105
 	}
1106 1106
 
1107
-	public function setPayPalMembershipFeeNotificationVerifier( PaymentNotificationVerifier $verifier ) {
1107
+	public function setPayPalMembershipFeeNotificationVerifier(PaymentNotificationVerifier $verifier) {
1108 1108
 		$this->pimple['paypal-membership-fee-notification-verifier'] = $verifier;
1109 1109
 	}
1110 1110
 
1111
-	public function newCreditCardNotificationUseCase( string $updateToken ) {
1111
+	public function newCreditCardNotificationUseCase(string $updateToken) {
1112 1112
 		return new CreditCardNotificationUseCase(
1113 1113
 			$this->getDonationRepository(),
1114
-			$this->newDonationAuthorizer( $updateToken ),
1114
+			$this->newDonationAuthorizer($updateToken),
1115 1115
 			$this->getCreditCardService(),
1116 1116
 			$this->newDonationConfirmationMailer(),
1117 1117
 			$this->getLogger(),
@@ -1121,23 +1121,23 @@  discard block
 block discarded – undo
1121 1121
 
1122 1122
 	public function newCancelMembershipApplicationHtmlPresenter() {
1123 1123
 		return new CancelMembershipApplicationHtmlPresenter(
1124
-			$this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.html.twig' )
1124
+			$this->getIncludeTemplate('Membership_Application_Cancellation_Confirmation.html.twig')
1125 1125
 		);
1126 1126
 	}
1127 1127
 
1128 1128
 	public function newMembershipApplicationConfirmationHtmlPresenter() {
1129 1129
 		return new MembershipApplicationConfirmationHtmlPresenter(
1130
-			$this->getIncludeTemplate( 'Membership_Application_Confirmation.html.twig' )
1130
+			$this->getIncludeTemplate('Membership_Application_Confirmation.html.twig')
1131 1131
 		);
1132 1132
 	}
1133 1133
 
1134 1134
 	public function newMembershipFormViolationPresenter() {
1135 1135
 		return new MembershipFormViolationPresenter(
1136
-			$this->getIncludeTemplate( 'Membership_Application.html.twig' )
1136
+			$this->getIncludeTemplate('Membership_Application.html.twig')
1137 1137
 		);
1138 1138
 	}
1139 1139
 
1140
-	public function setCreditCardService( CreditCardService $ccService ) {
1140
+	public function setCreditCardService(CreditCardService $ccService) {
1141 1141
 		$this->pimple['credit-card-api-service'] = $ccService;
1142 1142
 	}
1143 1143
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 			new TwigTemplate(
1151 1151
 				$this->getTwig(),
1152 1152
 				'Credit_Card_Payment_Notification.txt.twig',
1153
-				[ 'returnUrl' => $this->config['creditcard']['return-url'] ]
1153
+				['returnUrl' => $this->config['creditcard']['return-url']]
1154 1154
 			)
1155 1155
 		);
1156 1156
 	}
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 		);
1172 1172
 	}
1173 1173
 
1174
-	public function setTokenGenerator( TokenGenerator $tokenGenerator ) {
1174
+	public function setTokenGenerator(TokenGenerator $tokenGenerator) {
1175 1175
 		$this->pimple['token_generator'] = $tokenGenerator;
1176 1176
 	}
1177 1177
 
@@ -1194,23 +1194,23 @@  discard block
 block discarded – undo
1194 1194
 	private function newDonationPolicyValidator(): AddDonationPolicyValidator {
1195 1195
 		return new AddDonationPolicyValidator(
1196 1196
 			$this->newDonationAmountPolicyValidator(),
1197
-			$this->newTextPolicyValidator( 'fields' ),
1197
+			$this->newTextPolicyValidator('fields'),
1198 1198
 			$this->config['email-address-blacklist']
1199 1199
 		);
1200 1200
 	}
1201 1201
 
1202 1202
 	private function newDonationAmountPolicyValidator(): AmountPolicyValidator {
1203 1203
 		// in the future, this might come from the configuration
1204
-		return new AmountPolicyValidator( 1000, 1000 );
1204
+		return new AmountPolicyValidator(1000, 1000);
1205 1205
 	}
1206 1206
 
1207 1207
 	public function getDonationTimeframeLimit() {
1208 1208
 		return $this->config['donation-timeframe-limit'];
1209 1209
 	}
1210 1210
 
1211
-	public function newSystemMessageResponse( string $message ) {
1212
-		$test = $this->getIncludeTemplate( 'System_Message.html.twig' );
1213
-		return $test->render( [ 'message' => $message ] );
1211
+	public function newSystemMessageResponse(string $message) {
1212
+		$test = $this->getIncludeTemplate('System_Message.html.twig');
1213
+		return $test->render(['message' => $message]);
1214 1214
 	}
1215 1215
 
1216 1216
 	public function getMembershipApplicationTimeframeLimit() {
@@ -1231,37 +1231,37 @@  discard block
 block discarded – undo
1231 1231
 
1232 1232
 	public function enablePageCache() {
1233 1233
 		$this->pimple['page_cache'] = function() {
1234
-			return new FilesystemCache( $this->getCachePath() . '/pages/raw' );
1234
+			return new FilesystemCache($this->getCachePath() . '/pages/raw');
1235 1235
 		};
1236 1236
 
1237 1237
 		$this->pimple['rendered_page_cache'] = function() {
1238
-			return new FilesystemCache( $this->getCachePath() . '/pages/rendered' );
1238
+			return new FilesystemCache($this->getCachePath() . '/pages/rendered');
1239 1239
 		};
1240 1240
 	}
1241 1241
 
1242
-	private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) {
1243
-		if ( $this->profiler === null ) {
1242
+	private function addProfilingDecorator($objectToDecorate, string $profilingLabel) {
1243
+		if ($this->profiler === null) {
1244 1244
 			return $objectToDecorate;
1245 1245
 		}
1246 1246
 
1247
-		$builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() );
1247
+		$builder = new ProfilingDecoratorBuilder($this->profiler, $this->getProfilerDataCollector());
1248 1248
 
1249
-		return $builder->decorate( $objectToDecorate, $profilingLabel );
1249
+		return $builder->decorate($objectToDecorate, $profilingLabel);
1250 1250
 	}
1251 1251
 
1252
-	public function setProfiler( Stopwatch $profiler ) {
1252
+	public function setProfiler(Stopwatch $profiler) {
1253 1253
 		$this->profiler = $profiler;
1254 1254
 	}
1255 1255
 
1256
-	public function setEmailValidator( EmailValidator $validator ) {
1256
+	public function setEmailValidator(EmailValidator $validator) {
1257 1257
 		$this->pimple['mail_validator'] = $validator;
1258 1258
 	}
1259 1259
 
1260
-	public function setLogger( LoggerInterface $logger ) {
1260
+	public function setLogger(LoggerInterface $logger) {
1261 1261
 		$this->pimple['logger'] = $logger;
1262 1262
 	}
1263 1263
 
1264
-	public function setPaypalLogger( LoggerInterface $logger ) {
1264
+	public function setPaypalLogger(LoggerInterface $logger) {
1265 1265
 		$this->pimple['paypal_logger'] = $logger;
1266 1266
 	}
1267 1267
 
@@ -1270,35 +1270,35 @@  discard block
 block discarded – undo
1270 1270
 	}
1271 1271
 
1272 1272
 	private function newIbanValidator(): IbanValidator {
1273
-		return new IbanValidator( $this->newBankDataConverter(), $this->config['banned-ibans'] );
1273
+		return new IbanValidator($this->newBankDataConverter(), $this->config['banned-ibans']);
1274 1274
 	}
1275 1275
 
1276 1276
 	private function newFilePrefixer(): FilePrefixer {
1277
-		return new FilePrefixer( $this->getFilePrefix() );
1277
+		return new FilePrefixer($this->getFilePrefix());
1278 1278
 	}
1279 1279
 
1280 1280
 	private function getFilePrefix(): string {
1281 1281
 		$prefixContentFile = $this->getVarPath() . '/file_prefix.txt';
1282
-		if ( !file_exists( $prefixContentFile ) ) {
1282
+		if (!file_exists($prefixContentFile)) {
1283 1283
 			return '';
1284 1284
 		}
1285
-		return $prefix = preg_replace( '/[^0-9a-f]/', '', file_get_contents( $prefixContentFile ) );
1285
+		return $prefix = preg_replace('/[^0-9a-f]/', '', file_get_contents($prefixContentFile));
1286 1286
 	}
1287 1287
 
1288
-	public function newDonationAcceptedEventHandler( string $updateToken ): DonationAcceptedEventHandler {
1288
+	public function newDonationAcceptedEventHandler(string $updateToken): DonationAcceptedEventHandler {
1289 1289
 		return new DonationAcceptedEventHandler(
1290
-			$this->newDonationAuthorizer( $updateToken ),
1290
+			$this->newDonationAuthorizer($updateToken),
1291 1291
 			$this->getDonationRepository(),
1292 1292
 			$this->newDonationConfirmationMailer()
1293 1293
 		);
1294 1294
 	}
1295 1295
 
1296 1296
 	public function newPageNotFoundHtmlPresenter(): PageNotFoundPresenter {
1297
-		return new PageNotFoundPresenter( $this->getLayoutTemplate( 'Page_not_found.html.twig' ) );
1297
+		return new PageNotFoundPresenter($this->getLayoutTemplate('Page_not_found.html.twig'));
1298 1298
 	}
1299 1299
 
1300
-	public function setPageViewTracker( PageViewTracker $tracker ) {
1301
-		$this->pimple['page_view_tracker'] = function () use ( $tracker )  {
1300
+	public function setPageViewTracker(PageViewTracker $tracker) {
1301
+		$this->pimple['page_view_tracker'] = function() use ($tracker)  {
1302 1302
 			return $tracker;
1303 1303
 		};
1304 1304
 	}
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 		// the "https:" prefix does NOT get any slashes because baseURL is stored in a protocol-agnostic way
1312 1312
 		// (e.g. "//tracking.wikimedia.de" )
1313 1313
 		return new PiwikServerSideTracker(
1314
-			new \PiwikTracker( $this->config['piwik']['siteId'], 'https:' . $this->config['piwik']['baseUrl'] )
1314
+			new \PiwikTracker($this->config['piwik']['siteId'], 'https:' . $this->config['piwik']['baseUrl'])
1315 1315
 		);
1316 1316
 	}
1317 1317
 
Please login to merge, or discard this patch.