Completed
Pull Request — master (#546)
by Jeroen De
05:00 queued 54s
created
src/Factories/FunFunFactory.php 1 patch
Spacing   +160 added lines, -160 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
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	private $pimple;
157 157
 	private $addDoctrineSubscribers = true;
158 158
 
159
-	public function __construct( array $config ) {
159
+	public function __construct(array $config) {
160 160
 		$this->config = $config;
161 161
 		$this->pimple = $this->newPimple();
162 162
 	}
@@ -164,102 +164,102 @@  discard block
 block discarded – undo
164 164
 	private function newPimple(): \Pimple {
165 165
 		$pimple = new \Pimple();
166 166
 
167
-		$pimple['dbal_connection'] = $pimple->share( function() {
168
-			return DriverManager::getConnection( $this->config['db'] );
167
+		$pimple['dbal_connection'] = $pimple->share(function() {
168
+			return DriverManager::getConnection($this->config['db']);
169 169
 		} );
170 170
 
171
-		$pimple['entity_manager'] = $pimple->share( function() {
172
-			$entityManager = ( new StoreFactory( $this->getConnection() ) )->getEntityManager();
173
-			if ( $this->addDoctrineSubscribers ) {
174
-				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() );
175
-				$entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() );
171
+		$pimple['entity_manager'] = $pimple->share(function() {
172
+			$entityManager = (new StoreFactory($this->getConnection()))->getEntityManager();
173
+			if ($this->addDoctrineSubscribers) {
174
+				$entityManager->getEventManager()->addEventSubscriber($this->newDoctrineDonationPrePersistSubscriber());
175
+				$entityManager->getEventManager()->addEventSubscriber($this->newDoctrineMembershipApplicationPrePersistSubscriber());
176 176
 			}
177 177
 
178 178
 			return $entityManager;
179 179
 		} );
180 180
 
181
-		$pimple['subscription_repository'] = $pimple->share( function() {
181
+		$pimple['subscription_repository'] = $pimple->share(function() {
182 182
 			return new LoggingSubscriptionRepository(
183
-				new DoctrineSubscriptionRepository( $this->getEntityManager() ),
183
+				new DoctrineSubscriptionRepository($this->getEntityManager()),
184 184
 				$this->getLogger()
185 185
 			);
186 186
 		} );
187 187
 
188
-		$pimple['donation_repository'] = $pimple->share( function() {
188
+		$pimple['donation_repository'] = $pimple->share(function() {
189 189
 			return new LoggingDonationRepository(
190
-				new DoctrineDonationRepository( $this->getEntityManager() ),
190
+				new DoctrineDonationRepository($this->getEntityManager()),
191 191
 				$this->getLogger()
192 192
 			);
193 193
 		} );
194 194
 
195
-		$pimple['membership_application_repository'] = $pimple->share( function() {
195
+		$pimple['membership_application_repository'] = $pimple->share(function() {
196 196
 			return new LoggingMembershipApplicationRepository(
197
-				new DoctrineMembershipApplicationRepository( $this->getEntityManager() ),
197
+				new DoctrineMembershipApplicationRepository($this->getEntityManager()),
198 198
 				$this->getLogger()
199 199
 			);
200 200
 		} );
201 201
 
202
-		$pimple['comment_repository'] = $pimple->share( function() {
202
+		$pimple['comment_repository'] = $pimple->share(function() {
203 203
 			return new LoggingCommentFinder(
204
-				new DoctrineCommentFinder( $this->getEntityManager() ),
204
+				new DoctrineCommentFinder($this->getEntityManager()),
205 205
 				$this->getLogger()
206 206
 			);
207 207
 		} );
208 208
 
209
-		$pimple['mail_validator'] = $pimple->share( function() {
210
-			return new EmailValidator( new InternetDomainNameValidator() );
209
+		$pimple['mail_validator'] = $pimple->share(function() {
210
+			return new EmailValidator(new InternetDomainNameValidator());
211 211
 		} );
212 212
 
213
-		$pimple['subscription_validator'] = $pimple->share( function() {
213
+		$pimple['subscription_validator'] = $pimple->share(function() {
214 214
 			return new SubscriptionValidator(
215 215
 				$this->getEmailValidator(),
216
-				$this->getTextPolicyValidator( 'fields' ),
216
+				$this->getTextPolicyValidator('fields'),
217 217
 				$this->newSubscriptionDuplicateValidator(),
218 218
 				$this->newHonorificValidator()
219 219
 			);
220 220
 		} );
221 221
 
222
-		$pimple['template_name_validator'] = $pimple->share( function() {
223
-			return new TemplateNameValidator( $this->getTwig() );
222
+		$pimple['template_name_validator'] = $pimple->share(function() {
223
+			return new TemplateNameValidator($this->getTwig());
224 224
 		} );
225 225
 
226
-		$pimple['contact_validator'] = $pimple->share( function() {
227
-			return new GetInTouchValidator( $this->getEmailValidator() );
226
+		$pimple['contact_validator'] = $pimple->share(function() {
227
+			return new GetInTouchValidator($this->getEmailValidator());
228 228
 		} );
229 229
 
230
-		$pimple['greeting_generator'] = $pimple->share( function() {
230
+		$pimple['greeting_generator'] = $pimple->share(function() {
231 231
 			return new GreetingGenerator();
232 232
 		} );
233 233
 
234
-		$pimple['mw_api'] = $pimple->share( function() {
234
+		$pimple['mw_api'] = $pimple->share(function() {
235 235
 			return new MediawikiApi(
236 236
 				$this->config['cms-wiki-api-url'],
237 237
 				$this->getGuzzleClient()
238 238
 			);
239 239
 		} );
240 240
 
241
-		$pimple['guzzle_client'] = $pimple->share( function() {
241
+		$pimple['guzzle_client'] = $pimple->share(function() {
242 242
 			$middlewareFactory = new MiddlewareFactory();
243
-			$middlewareFactory->setLogger( $this->getLogger() );
243
+			$middlewareFactory->setLogger($this->getLogger());
244 244
 
245
-			$handlerStack = HandlerStack::create( new CurlHandler() );
246
-			$handlerStack->push( $middlewareFactory->retry() );
245
+			$handlerStack = HandlerStack::create(new CurlHandler());
246
+			$handlerStack->push($middlewareFactory->retry());
247 247
 
248
-			return new Client( [
248
+			return new Client([
249 249
 				'cookies' => true,
250 250
 				'handler' => $handlerStack,
251
-				'headers' => [ 'User-Agent' => 'WMDE Fundraising Frontend' ],
252
-			] );
251
+				'headers' => ['User-Agent' => 'WMDE Fundraising Frontend'],
252
+			]);
253 253
 		} );
254 254
 
255
-		$pimple['translator'] = $pimple->share( function() {
255
+		$pimple['translator'] = $pimple->share(function() {
256 256
 			$translationFactory = new TranslationFactory();
257 257
 			$loaders = [
258 258
 				'json' => $translationFactory->newJsonLoader()
259 259
 			];
260 260
 			$locale = $this->config['locale'];
261
-			$translator = $translationFactory->create( $loaders, $locale );
262
-			$translator->addResource( 'json', __DIR__ . '/../../app/translations/messages.' . $locale . '.json', $locale );
261
+			$translator = $translationFactory->create($loaders, $locale);
262
+			$translator->addResource('json', __DIR__ . '/../../app/translations/messages.' . $locale . '.json', $locale);
263 263
 			$translator->addResource(
264 264
 				'json',
265 265
 				__DIR__ . '/../../app/translations/paymentTypes.' . $locale . '.json',
@@ -272,55 +272,55 @@  discard block
 block discarded – undo
272 272
 				$locale,
273 273
 				'paymentIntervals'
274 274
 			);
275
-			$translator->addResource( 'json', __DIR__ . '/../../app/translations/validations.' . $locale . '.json', $locale,
276
-				'validations' );
275
+			$translator->addResource('json', __DIR__ . '/../../app/translations/validations.' . $locale . '.json', $locale,
276
+				'validations');
277 277
 			return $translator;
278 278
 		} );
279 279
 
280 280
 		// In the future, this could be locale-specific or filled from a DB table
281
-		$pimple['honorifics'] = $pimple->share( function() {
282
-			return new Honorifics( [
281
+		$pimple['honorifics'] = $pimple->share(function() {
282
+			return new Honorifics([
283 283
 				'' => 'Kein Titel',
284 284
 				'Dr.' => 'Dr.',
285 285
 				'Prof.' => 'Prof.',
286 286
 				'Prof. Dr.' => 'Prof. Dr.'
287
-			] );
287
+			]);
288 288
 		} );
289 289
 
290
-		$pimple['twig_factory'] = $pimple->share( function () {
291
-			return new TwigFactory( $this->config['twig'] );
290
+		$pimple['twig_factory'] = $pimple->share(function() {
291
+			return new TwigFactory($this->config['twig']);
292 292
 		} );
293 293
 
294
-		$pimple['twig'] = $pimple->share( function() {
294
+		$pimple['twig'] = $pimple->share(function() {
295 295
 			$twigFactory = $this->getTwigFactory();
296
-			$loaders = array_filter( [
296
+			$loaders = array_filter([
297 297
 				$twigFactory->newFileSystemLoader(),
298 298
 				$twigFactory->newArrayLoader(), // This is just a fallback for testing
299
-				$twigFactory->newWikiPageLoader( $this->newWikiContentProvider() ),
300
-			] );
299
+				$twigFactory->newWikiPageLoader($this->newWikiContentProvider()),
300
+			]);
301 301
 			$extensions = [
302
-				$twigFactory->newTranslationExtension( $this->getTranslator() ),
302
+				$twigFactory->newTranslationExtension($this->getTranslator()),
303 303
 				new Twig_Extensions_Extension_Intl()
304 304
 			];
305
-			return $twigFactory->create( $loaders, $extensions );
305
+			return $twigFactory->create($loaders, $extensions);
306 306
 		} );
307 307
 
308
-		$pimple['logger'] = $pimple->share( function() {
309
-			$logger = new Logger( 'WMDE Fundraising Frontend logger' );
308
+		$pimple['logger'] = $pimple->share(function() {
309
+			$logger = new Logger('WMDE Fundraising Frontend logger');
310 310
 
311
-			$streamHandler = new StreamHandler( $this->newLoggerPath( ( new \DateTime() )->format( 'Y-m-d\TH:i:s\Z' ) ) );
312
-			$bufferHandler = new BufferHandler( $streamHandler, 500, Logger::DEBUG, true, true );
313
-			$streamHandler->setFormatter( new LineFormatter( "%message%\n" ) );
314
-			$logger->pushHandler( $bufferHandler );
311
+			$streamHandler = new StreamHandler($this->newLoggerPath((new \DateTime())->format('Y-m-d\TH:i:s\Z')));
312
+			$bufferHandler = new BufferHandler($streamHandler, 500, Logger::DEBUG, true, true);
313
+			$streamHandler->setFormatter(new LineFormatter("%message%\n"));
314
+			$logger->pushHandler($bufferHandler);
315 315
 
316
-			$errorHandler = new StreamHandler( $this->newLoggerPath( 'error' ), Logger::ERROR );
317
-			$errorHandler->setFormatter( new JsonFormatter() );
318
-			$logger->pushHandler( $errorHandler );
316
+			$errorHandler = new StreamHandler($this->newLoggerPath('error'), Logger::ERROR);
317
+			$errorHandler->setFormatter(new JsonFormatter());
318
+			$logger->pushHandler($errorHandler);
319 319
 
320 320
 			return $logger;
321 321
 		} );
322 322
 
323
-		$pimple['messenger'] = $pimple->share( function() {
323
+		$pimple['messenger'] = $pimple->share(function() {
324 324
 			return new Messenger(
325 325
 				new Swift_MailTransport(),
326 326
 				$this->getOperatorAddress(),
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 			);
329 329
 		} );
330 330
 
331
-		$pimple['confirmation-page-selector'] = $pimple->share( function() {
332
-			return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] );
331
+		$pimple['confirmation-page-selector'] = $pimple->share(function() {
332
+			return new DonationConfirmationPageSelector($this->config['confirmation-pages']);
333 333
 		} );
334 334
 
335
-		$pimple['paypal-payment-notification-verifier'] = $pimple->share( function() {
335
+		$pimple['paypal-payment-notification-verifier'] = $pimple->share(function() {
336 336
 			return new LoggingPaymentNotificationVerifier(
337 337
 				new PayPalPaymentNotificationVerifier(
338 338
 					new Client(),
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 			);
343 343
 		} );
344 344
 
345
-		$pimple['credit-card-api-service'] = $pimple->share( function() {
345
+		$pimple['credit-card-api-service'] = $pimple->share(function() {
346 346
 			return new McpCreditCardService(
347 347
 				new TNvpServiceDispatcher(
348 348
 					'IMcpCreditcardService_v1_5',
@@ -353,10 +353,10 @@  discard block
 block discarded – undo
353 353
 			);
354 354
 		} );
355 355
 
356
-		$pimple['token_generator'] = $pimple->share( function() {
356
+		$pimple['token_generator'] = $pimple->share(function() {
357 357
 			return new RandomTokenGenerator(
358 358
 				$this->config['token-length'],
359
-				new \DateInterval( $this->config['token-validity-timestamp'] )
359
+				new \DateInterval($this->config['token-validity-timestamp'])
360 360
 			);
361 361
 		} );
362 362
 
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
 
374 374
 	private function newDonationEventLogger(): DonationEventLogger {
375 375
 		return new BestEffortDonationEventLogger(
376
-			new DoctrineDonationEventLogger( $this->getEntityManager() ),
376
+			new DoctrineDonationEventLogger($this->getEntityManager()),
377 377
 			$this->getLogger()
378 378
 		);
379 379
 	}
380 380
 
381 381
 	public function newInstaller(): Installer {
382
-		return ( new StoreFactory( $this->getConnection() ) )->newInstaller();
382
+		return (new StoreFactory($this->getConnection()))->newInstaller();
383 383
 	}
384 384
 
385 385
 	public function newListCommentsUseCase(): ListCommentsUseCase {
386
-		return new ListCommentsUseCase( $this->getCommentFinder() );
386
+		return new ListCommentsUseCase($this->getCommentFinder());
387 387
 	}
388 388
 
389 389
 	public function newCommentListJsonPresenter(): CommentListJsonPresenter {
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	public function newCommentListRssPresenter(): CommentListRssPresenter {
394
-		return new CommentListRssPresenter( new TwigTemplate(
394
+		return new CommentListRssPresenter(new TwigTemplate(
395 395
 			$this->getTwig(),
396 396
 			'CommentList.rss.twig'
397
-		) );
397
+		));
398 398
 	}
399 399
 
400 400
 	public function newCommentListHtmlPresenter(): CommentListHtmlPresenter {
401
-		return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'CommentList.html.twig' ) );
401
+		return new CommentListHtmlPresenter($this->getLayoutTemplate('CommentList.html.twig'));
402 402
 	}
403 403
 
404 404
 	private function getCommentFinder(): CommentFinder {
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		return $this->pimple['subscription_repository'];
410 410
 	}
411 411
 
412
-	public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) {
412
+	public function setSubscriptionRepository(SubscriptionRepository $subscriptionRepository) {
413 413
 		$this->pimple['subscription_repository'] = $subscriptionRepository;
414 414
 	}
415 415
 
@@ -432,26 +432,26 @@  discard block
 block discarded – undo
432 432
 	}
433 433
 
434 434
 	public function newDisplayPagePresenter(): DisplayPagePresenter {
435
-		return new DisplayPagePresenter( $this->getLayoutTemplate( 'DisplayPageLayout.twig' ) );
435
+		return new DisplayPagePresenter($this->getLayoutTemplate('DisplayPageLayout.twig'));
436 436
 	}
437 437
 
438 438
 	public function newAddSubscriptionHTMLPresenter(): AddSubscriptionHtmlPresenter {
439
-		return new AddSubscriptionHtmlPresenter( $this->getIncludeTemplate( 'Subscription_Form.twig' ), $this->getTranslator() );
439
+		return new AddSubscriptionHtmlPresenter($this->getIncludeTemplate('Subscription_Form.twig'), $this->getTranslator());
440 440
 	}
441 441
 
442 442
 	public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter {
443 443
 		return new ConfirmSubscriptionHtmlPresenter(
444
-			$this->getLayoutTemplate( 'ConfirmSubscription.html.twig' ),
444
+			$this->getLayoutTemplate('ConfirmSubscription.html.twig'),
445 445
 			$this->getTranslator()
446 446
 		);
447 447
 	}
448 448
 
449 449
 	public function newAddSubscriptionJSONPresenter(): AddSubscriptionJsonPresenter {
450
-		return new AddSubscriptionJsonPresenter( $this->getTranslator() );
450
+		return new AddSubscriptionJsonPresenter($this->getTranslator());
451 451
 	}
452 452
 
453 453
 	public function newGetInTouchHTMLPresenter(): GetInTouchHtmlPresenter {
454
-		return new GetInTouchHtmlPresenter( $this->getIncludeTemplate( 'Kontaktformular.twig' ), $this->getTranslator() );
454
+		return new GetInTouchHtmlPresenter($this->getIncludeTemplate('Kontaktformular.twig'), $this->getTranslator());
455 455
 	}
456 456
 
457 457
 	public function getTwig(): Twig_Environment {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @param string $templateName
465 465
 	 * @return TwigTemplate
466 466
 	 */
467
-	private function getLayoutTemplate( string $templateName ): TwigTemplate {
467
+	private function getLayoutTemplate(string $templateName): TwigTemplate {
468 468
 		 return new TwigTemplate(
469 469
 			$this->getTwig(),
470 470
 			$templateName,
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	 * @param string $templateName Template to include
479 479
 	 * @return TwigTemplate
480 480
 	 */
481
-	private function getIncludeTemplate( string $templateName ): TwigTemplate {
481
+	private function getIncludeTemplate(string $templateName): TwigTemplate {
482 482
 		return new TwigTemplate(
483 483
 			$this->getTwig(),
484 484
 			'IncludeInLayout.twig',
485 485
 			array_merge(
486 486
 				$this->getDefaultTwigVariables(),
487
-				[ 'main_template' => $templateName]
487
+				['main_template' => $templateName]
488 488
 			)
489 489
 		);
490 490
 	}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 	private function newPageRetriever(): PageRetriever {
510 510
 		return new ApiBasedPageRetriever(
511 511
 			$this->getMediaWikiApi(),
512
-			new ApiUser( $this->config['cms-wiki-user'], $this->config['cms-wiki-password'] ),
512
+			new ApiUser($this->config['cms-wiki-user'], $this->config['cms-wiki-password']),
513 513
 			$this->getLogger()
514 514
 		);
515 515
 	}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		return $this->pimple['mw_api'];
519 519
 	}
520 520
 
521
-	public function setMediaWikiApi( MediawikiApi $api ) {
521
+	public function setMediaWikiApi(MediawikiApi $api) {
522 522
 		$this->pimple['mw_api'] = $api;
523 523
 	}
524 524
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		return $this->pimple['logger'];
539 539
 	}
540 540
 
541
-	private function newLoggerPath( string $fileName ): string {
541
+	private function newLoggerPath(string $fileName): string {
542 542
 		return __DIR__ . '/../../var/log/' . $fileName . '.log';
543 543
 	}
544 544
 
@@ -582,20 +582,20 @@  discard block
 block discarded – undo
582 582
 			new TwigTemplate(
583 583
 					$this->getTwig(),
584 584
 					'Mail_Subscription_Confirmation.twig',
585
-					[ 'greeting_generator' => $this->getGreetingGenerator() ]
585
+					['greeting_generator' => $this->getGreetingGenerator()]
586 586
 			),
587 587
 			'mail_subject_membership'
588 588
 		);
589 589
 	}
590 590
 
591
-	private function newTemplateMailer( TwigTemplate $template, string $messageKey ): TemplateBasedMailer {
591
+	private function newTemplateMailer(TwigTemplate $template, string $messageKey): TemplateBasedMailer {
592 592
 		$mailer = new TemplateBasedMailer(
593 593
 			$this->getMessenger(),
594 594
 			$template,
595
-			$this->getTranslator()->trans( $messageKey )
595
+			$this->getTranslator()->trans($messageKey)
596 596
 		);
597 597
 
598
-		return new LoggingMailer( $mailer, $this->getLogger() );
598
+		return new LoggingMailer($mailer, $this->getLogger());
599 599
 	}
600 600
 
601 601
 	public function getGreetingGenerator() {
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
 	}
604 604
 
605 605
 	public function newCheckIbanUseCase(): CheckIbanUseCase {
606
-		return new CheckIbanUseCase( $this->newBankDataConverter() );
606
+		return new CheckIbanUseCase($this->newBankDataConverter());
607 607
 	}
608 608
 
609 609
 	public function newGenerateIbanUseCase(): GenerateIbanUseCase {
610
-		return new GenerateIbanUseCase( $this->newBankDataConverter() );
610
+		return new GenerateIbanUseCase($this->newBankDataConverter());
611 611
 	}
612 612
 
613 613
 	public function newIbanPresenter(): IbanPresenter {
@@ -615,14 +615,14 @@  discard block
 block discarded – undo
615 615
 	}
616 616
 
617 617
 	public function newBankDataConverter() {
618
-		return new BankDataConverter( $this->config['bank-data-file'] );
618
+		return new BankDataConverter($this->config['bank-data-file']);
619 619
 	}
620 620
 
621
-	public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) {
621
+	public function setSubscriptionValidator(SubscriptionValidator $subscriptionValidator) {
622 622
 		$this->pimple['subscription_validator'] = $subscriptionValidator;
623 623
 	}
624 624
 
625
-	public function setPageTitlePrefix( string $prefix ) {
625
+	public function setPageTitlePrefix(string $prefix) {
626 626
 		$this->config['cms-wiki-title-prefix'] = $prefix;
627 627
 	}
628 628
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
 	private function newContactConfirmationMailer(): TemplateBasedMailer {
638 638
 		return $this->newTemplateMailer(
639
-			new TwigTemplate( $this->getTwig(), 'KontaktMailExtern.twig' ),
639
+			new TwigTemplate($this->getTwig(), 'KontaktMailExtern.twig'),
640 640
 			'mail_subject_getintouch'
641 641
 		);
642 642
 	}
@@ -654,12 +654,12 @@  discard block
 block discarded – undo
654 654
 
655 655
 	private function newSubscriptionDuplicateCutoffDate(): \DateTime {
656 656
 		$cutoffDateTime = new \DateTime();
657
-		$cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) );
657
+		$cutoffDateTime->sub(new \DateInterval($this->config['subscription-interval']));
658 658
 		return $cutoffDateTime;
659 659
 	}
660 660
 
661 661
 	private function newHonorificValidator(): AllowedValuesValidator {
662
-		return new AllowedValuesValidator( $this->getHonorifics()->getKeys() );
662
+		return new AllowedValuesValidator($this->getHonorifics()->getKeys());
663 663
 	}
664 664
 
665 665
 	private function getHonorifics(): Honorifics {
@@ -667,45 +667,45 @@  discard block
 block discarded – undo
667 667
 	}
668 668
 
669 669
 	private function newPaymentTypeValidator(): AllowedValuesValidator {
670
-		return new AllowedValuesValidator( PaymentType::getPaymentTypes() );
670
+		return new AllowedValuesValidator(PaymentType::getPaymentTypes());
671 671
 	}
672 672
 
673 673
 	private function newBankDataValidator(): BankDataValidator {
674
-		return new BankDataValidator( new IbanValidator( $this->newBankDataConverter() ) );
674
+		return new BankDataValidator(new IbanValidator($this->newBankDataConverter()));
675 675
 	}
676 676
 
677 677
 	private function getMessenger(): Messenger {
678 678
 		return $this->pimple['messenger'];
679 679
 	}
680 680
 
681
-	public function setMessenger( Messenger $messenger ) {
681
+	public function setMessenger(Messenger $messenger) {
682 682
 		$this->pimple['messenger'] = $messenger;
683 683
 	}
684 684
 
685 685
 	public function setNullMessenger() {
686
-		$this->setMessenger( new Messenger(
686
+		$this->setMessenger(new Messenger(
687 687
 			Swift_NullTransport::newInstance(),
688 688
 			$this->getOperatorAddress()
689
-		) );
689
+		));
690 690
 	}
691 691
 
692 692
 	public function getOperatorAddress() {
693
-		return new EmailAddress( $this->config['operator-email'] );
693
+		return new EmailAddress($this->config['operator-email']);
694 694
 	}
695 695
 
696 696
 	public function newInternalErrorHTMLPresenter(): InternalErrorHtmlPresenter {
697
-		return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'ErrorPage.twig' ) );
697
+		return new InternalErrorHtmlPresenter($this->getIncludeTemplate('ErrorPage.twig'));
698 698
 	}
699 699
 
700 700
 	public function newAccessDeniedHTMLPresenter(): InternalErrorHtmlPresenter {
701
-		return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'AccessDenied.twig' ) );
701
+		return new InternalErrorHtmlPresenter($this->getLayoutTemplate('AccessDenied.twig'));
702 702
 	}
703 703
 
704 704
 	public function getTranslator(): TranslatorInterface {
705 705
 		return $this->pimple['translator'];
706 706
 	}
707 707
 
708
-	public function setTranslator( TranslatorInterface $translator ) {
708
+	public function setTranslator(TranslatorInterface $translator) {
709 709
 		$this->pimple['translator'] = $translator;
710 710
 	}
711 711
 
@@ -713,40 +713,40 @@  discard block
 block discarded – undo
713 713
 		return $this->pimple['twig_factory'];
714 714
 	}
715 715
 
716
-	private function getTextPolicyValidator( $policyName ) {
716
+	private function getTextPolicyValidator($policyName) {
717 717
 		$policyValidator = new TextPolicyValidator();
718 718
 
719 719
 		$contentProvider = $this->newWikiContentProvider();
720 720
 		$textPolicyConfig = $this->config['text-policies'][$policyName];
721 721
 
722 722
 		// TODO: this is not the place to retrieve resources over the network
723
-		$policyValidator->addBadWordsFromArray( $this->loadWordsFromWiki(
723
+		$policyValidator->addBadWordsFromArray($this->loadWordsFromWiki(
724 724
 			$contentProvider,
725 725
 			$textPolicyConfig['badwords'] ?? ''
726
-		) );
727
-		$policyValidator->addWhiteWordsFromArray( $this->loadWordsFromWiki(
726
+		));
727
+		$policyValidator->addWhiteWordsFromArray($this->loadWordsFromWiki(
728 728
 			$contentProvider,
729 729
 			$textPolicyConfig['whitewords'] ?? ''
730
-		) );
730
+		));
731 731
 
732 732
 		return $policyValidator;
733 733
 	}
734 734
 
735
-	private function loadWordsFromWiki( WikiContentProvider $contentProvider, string $pageName ): array {
736
-		if ( $pageName === '' ) {
737
-			return [ ];
735
+	private function loadWordsFromWiki(WikiContentProvider $contentProvider, string $pageName): array {
736
+		if ($pageName === '') {
737
+			return [];
738 738
 		}
739
-		$content = $contentProvider->getContent( $pageName, 'raw' );
740
-		$words = array_map( 'trim', explode( "\n", $content ) );
739
+		$content = $contentProvider->getContent($pageName, 'raw');
740
+		$words = array_map('trim', explode("\n", $content));
741 741
 
742
-		return array_filter( $words );
742
+		return array_filter($words);
743 743
 	}
744 744
 
745
-	public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase {
745
+	public function newCancelDonationUseCase(string $updateToken): CancelDonationUseCase {
746 746
 		return new CancelDonationUseCase(
747 747
 			$this->getDonationRepository(),
748 748
 			$this->newCancelDonationMailer(),
749
-			$this->newDonationAuthorizer( $updateToken ),
749
+			$this->newDonationAuthorizer($updateToken),
750 750
 			$this->newDonationEventLogger()
751 751
 		);
752 752
 	}
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			new TwigTemplate(
757 757
 				$this->getTwig(),
758 758
 				'Mail_Donation_Cancellation_Confirmation.twig',
759
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
759
+				['greeting_generator' => $this->getGreetingGenerator()]
760 760
 			),
761 761
 			'mail_subject_confirm_cancellation'
762 762
 		);
@@ -814,19 +814,19 @@  discard block
 block discarded – undo
814 814
 	}
815 815
 
816 816
 	public function newPayPalUrlGenerator() {
817
-		return new PayPalUrlGenerator( $this->getPayPalUrlConfig() );
817
+		return new PayPalUrlGenerator($this->getPayPalUrlConfig());
818 818
 	}
819 819
 
820 820
 	private function getPayPalUrlConfig() {
821
-		return PayPalUrlConfig::newFromConfig( $this->config['paypal'] );
821
+		return PayPalUrlConfig::newFromConfig($this->config['paypal']);
822 822
 	}
823 823
 
824 824
 	private function newCreditCardUrlGenerator() {
825
-		return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() );
825
+		return new CreditCardUrlGenerator($this->newCreditCardUrlConfig());
826 826
 	}
827 827
 
828 828
 	private function newCreditCardUrlConfig() {
829
-		return CreditCardUrlConfig::newFromConfig( $this->config['creditcard'] );
829
+		return CreditCardUrlConfig::newFromConfig($this->config['creditcard']);
830 830
 	}
831 831
 
832 832
 	public function getDonationRepository(): DonationRepository {
@@ -844,22 +844,22 @@  discard block
 block discarded – undo
844 844
 	}
845 845
 
846 846
 	private function newAmountFormatter(): AmountFormatter {
847
-		return new AmountFormatter( $this->config['locale'] );
847
+		return new AmountFormatter($this->config['locale']);
848 848
 	}
849 849
 
850 850
 	public function newDecimalNumberFormatter(): NumberFormatter {
851
-		return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL );
851
+		return new NumberFormatter($this->config['locale'], NumberFormatter::DECIMAL);
852 852
 	}
853 853
 
854
-	public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase {
854
+	public function newAddCommentUseCase(string $updateToken): AddCommentUseCase {
855 855
 		return new AddCommentUseCase(
856 856
 			$this->getDonationRepository(),
857
-			$this->newDonationAuthorizer( $updateToken ),
858
-			$this->getTextPolicyValidator( 'comment' )
857
+			$this->newDonationAuthorizer($updateToken),
858
+			$this->getTextPolicyValidator('comment')
859 859
 		);
860 860
 	}
861 861
 
862
-	private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer {
862
+	private function newDonationAuthorizer(string $updateToken = null, string $accessToken = null): DonationAuthorizer {
863 863
 		return new DoctrineDonationAuthorizer(
864 864
 			$this->getEntityManager(),
865 865
 			$updateToken,
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
 
874 874
 	public function newDonationConfirmationPresenter() {
875 875
 		return new DonationConfirmationHtmlPresenter(
876
-			$this->getIncludeTemplate( 'DonationConfirmation.twig' )
876
+			$this->getIncludeTemplate('DonationConfirmation.twig')
877 877
 		);
878 878
 	}
879 879
 
880 880
 	public function newCreditCardPaymentHtmlPresenter() {
881 881
 		return new CreditCardPaymentHtmlPresenter(
882
-			$this->getIncludeTemplate( 'CreditCardPaymentIframe.twig' ),
882
+			$this->getIncludeTemplate('CreditCardPaymentIframe.twig'),
883 883
 			$this->getTranslator(),
884 884
 			$this->newCreditCardUrlGenerator()
885 885
 		);
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 
888 888
 	public function newCancelDonationHtmlPresenter() {
889 889
 		return new CancelDonationHtmlPresenter(
890
-			$this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.twig' )
890
+			$this->getIncludeTemplate('Donation_Cancellation_Confirmation.twig')
891 891
 		);
892 892
 	}
893 893
 
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 			new TwigTemplate(
907 907
 				$this->getTwig(),
908 908
 				'Mail_Membership_Application_Confirmation.twig',
909
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
909
+				['greeting_generator' => $this->getGreetingGenerator()]
910 910
 			),
911 911
 			'mail_subject_confirm_membership_application'
912 912
 		);
@@ -921,12 +921,12 @@  discard block
 block discarded – undo
921 921
 	}
922 922
 
923 923
 	private function newMembershipApplicationTracker(): MembershipApplicationTracker {
924
-		return new DoctrineMembershipApplicationTracker( $this->getEntityManager() );
924
+		return new DoctrineMembershipApplicationTracker($this->getEntityManager());
925 925
 	}
926 926
 
927
-	public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase {
927
+	public function newCancelMembershipApplicationUseCase(string $updateToken): CancelMembershipApplicationUseCase {
928 928
 		return new CancelMembershipApplicationUseCase(
929
-			$this->newMembershipApplicationAuthorizer( $updateToken ),
929
+			$this->newMembershipApplicationAuthorizer($updateToken),
930 930
 			$this->getMembershipApplicationRepository(),
931 931
 			$this->newCancelMembershipApplicationMailer()
932 932
 		);
@@ -951,27 +951,27 @@  discard block
 block discarded – undo
951 951
 			new TwigTemplate(
952 952
 				$this->getTwig(),
953 953
 				'Mail_Membership_Application_Cancellation_Confirmation.twig',
954
-				[ 'greeting_generator' => $this->getGreetingGenerator() ]
954
+				['greeting_generator' => $this->getGreetingGenerator()]
955 955
 			),
956 956
 			'mail_subject_confirm_membership_application_cancellation'
957 957
 		);
958 958
 	}
959 959
 
960
-	public function newMembershipApplicationConfirmationUseCase( string $accessToken ) {
960
+	public function newMembershipApplicationConfirmationUseCase(string $accessToken) {
961 961
 		return new ShowMembershipApplicationConfirmationUseCase(
962
-			$this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(),
962
+			$this->newMembershipApplicationAuthorizer(null, $accessToken), $this->getMembershipApplicationRepository(),
963 963
 			$this->newMembershipApplicationTokenFetcher()
964 964
 		);
965 965
 	}
966 966
 
967
-	public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase {
967
+	public function newShowDonationConfirmationUseCase(string $accessToken): ShowDonationConfirmationUseCase {
968 968
 		return new ShowDonationConfirmationUseCase(
969
-			$this->newDonationAuthorizer( null, $accessToken ),
969
+			$this->newDonationAuthorizer(null, $accessToken),
970 970
 			$this->getDonationRepository()
971 971
 		);
972 972
 	}
973 973
 
974
-	public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) {
974
+	public function setDonationConfirmationPageSelector(DonationConfirmationPageSelector $selector) {
975 975
 		$this->pimple['confirmation-page-selector'] = $selector;
976 976
 	}
977 977
 
@@ -980,17 +980,17 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	public function newDonationFormViolationPresenter() {
983
-		$template = $this->getLayoutTemplate( 'DisplayPageLayout.twig' );
983
+		$template = $this->getLayoutTemplate('DisplayPageLayout.twig');
984 984
 		// TODO make this dependent on the 'form' value from the HTTP POST request
985 985
 		// (we need different form pages for A/B testing)
986 986
 		$template->context['main_template'] = 'DonationForm.twig';
987
-		return new DonationFormViolationPresenter( $template, $this->newAmountFormatter() );
987
+		return new DonationFormViolationPresenter($template, $this->newAmountFormatter());
988 988
 	}
989 989
 
990
-	public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) {
990
+	public function newHandlePayPalPaymentNotificationUseCase(string $updateToken) {
991 991
 		return new HandlePayPalPaymentNotificationUseCase(
992 992
 			$this->getDonationRepository(),
993
-			$this->newDonationAuthorizer( $updateToken ),
993
+			$this->newDonationAuthorizer($updateToken),
994 994
 			$this->newDonationConfirmationMailer(),
995 995
 			$this->getLogger(),
996 996
 			$this->newDonationEventLogger()
@@ -1001,14 +1001,14 @@  discard block
 block discarded – undo
1001 1001
 		return $this->pimple['paypal-payment-notification-verifier'];
1002 1002
 	}
1003 1003
 
1004
-	public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) {
1004
+	public function setPayPalPaymentNotificationVerifier(PaymentNotificationVerifier $verifier) {
1005 1005
 		$this->pimple['paypal-payment-notification-verifier'] = $verifier;
1006 1006
 	}
1007 1007
 
1008
-	public function newCreditCardNotificationUseCase( string $updateToken ) {
1008
+	public function newCreditCardNotificationUseCase(string $updateToken) {
1009 1009
 		return new CreditCardNotificationUseCase(
1010 1010
 			$this->getDonationRepository(),
1011
-			$this->newDonationAuthorizer( $updateToken ),
1011
+			$this->newDonationAuthorizer($updateToken),
1012 1012
 			$this->getCreditCardService(),
1013 1013
 			$this->newDonationConfirmationMailer(),
1014 1014
 			$this->getLogger(),
@@ -1018,23 +1018,23 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
 	public function newCancelMembershipApplicationHtmlPresenter() {
1020 1020
 		return new CancelMembershipApplicationHtmlPresenter(
1021
-			$this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.twig' )
1021
+			$this->getIncludeTemplate('Membership_Application_Cancellation_Confirmation.twig')
1022 1022
 		);
1023 1023
 	}
1024 1024
 
1025 1025
 	public function newMembershipApplicationConfirmationHtmlPresenter() {
1026 1026
 		return new MembershipApplicationConfirmationHtmlPresenter(
1027
-			$this->getIncludeTemplate( 'MembershipApplicationConfirmation.twig' )
1027
+			$this->getIncludeTemplate('MembershipApplicationConfirmation.twig')
1028 1028
 		);
1029 1029
 	}
1030 1030
 
1031 1031
 	public function newMembershipFormViolationPresenter() {
1032 1032
 		return new MembershipFormViolationPresenter(
1033
-			$this->getIncludeTemplate( 'MembershipApplication.twig' )
1033
+			$this->getIncludeTemplate('MembershipApplication.twig')
1034 1034
 		);
1035 1035
 	}
1036 1036
 
1037
-	public function setCreditCardService( CreditCardService $ccService ) {
1037
+	public function setCreditCardService(CreditCardService $ccService) {
1038 1038
 		$this->pimple['credit-card-api-service'] = $ccService;
1039 1039
 	}
1040 1040
 
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 			new TwigTemplate(
1048 1048
 				$this->getTwig(),
1049 1049
 				'CreditCardPaymentNotification.twig',
1050
-				[ 'returnUrl' => $this->config['creditcard']['return-url'] ]
1050
+				['returnUrl' => $this->config['creditcard']['return-url']]
1051 1051
 			)
1052 1052
 		);
1053 1053
 	}
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 		);
1069 1069
 	}
1070 1070
 
1071
-	public function setTokenGenerator( TokenGenerator $tokenGenerator ) {
1071
+	public function setTokenGenerator(TokenGenerator $tokenGenerator) {
1072 1072
 		$this->pimple['token_generator'] = $tokenGenerator;
1073 1073
 	}
1074 1074
 
@@ -1091,22 +1091,22 @@  discard block
 block discarded – undo
1091 1091
 	private function newDonationPolicyValidator(): AddDonationPolicyValidator {
1092 1092
 		return new AddDonationPolicyValidator(
1093 1093
 			$this->newDonationAmountPolicyValidator(),
1094
-			$this->getTextPolicyValidator( 'fields' )
1094
+			$this->getTextPolicyValidator('fields')
1095 1095
 		);
1096 1096
 	}
1097 1097
 
1098 1098
 	private function newDonationAmountPolicyValidator(): AmountPolicyValidator {
1099 1099
 		// in the future, this might come from the configuration
1100
-		return new AmountPolicyValidator( 1000, 200, 300 );
1100
+		return new AmountPolicyValidator(1000, 200, 300);
1101 1101
 	}
1102 1102
 
1103 1103
 	public function getDonationTimeframeLimit() {
1104 1104
 		return $this->config['donation-timeframe-limit'];
1105 1105
 	}
1106 1106
 
1107
-	public function newSystemMessageResponse( string $message ) {
1108
-		$test = $this->getIncludeTemplate( 'System_Message.twig' );
1109
-		return $test->render( [ 'message' => $message ] );
1107
+	public function newSystemMessageResponse(string $message) {
1108
+		$test = $this->getIncludeTemplate('System_Message.twig');
1109
+		return $test->render(['message' => $message]);
1110 1110
 	}
1111 1111
 
1112 1112
 	public function getMembershipApplicationTimeframeLimit() {
Please login to merge, or discard this patch.