@@ -1,6 +1,6 @@ discard block |
||
| 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 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | private $profiler = null; |
| 171 | 171 | |
| 172 | - public function __construct( array $config ) { |
|
| 172 | + public function __construct(array $config) { |
|
| 173 | 173 | $this->config = $config; |
| 174 | 174 | $this->pimple = $this->newPimple(); |
| 175 | 175 | } |
@@ -177,113 +177,113 @@ discard block |
||
| 177 | 177 | private function newPimple(): \Pimple { |
| 178 | 178 | $pimple = new \Pimple(); |
| 179 | 179 | |
| 180 | - $pimple['logger'] = $pimple->share( function() { |
|
| 180 | + $pimple['logger'] = $pimple->share(function() { |
|
| 181 | 181 | return new NullLogger(); |
| 182 | 182 | } ); |
| 183 | 183 | |
| 184 | - $pimple['profiler_data_collector'] = $pimple->share( function() { |
|
| 184 | + $pimple['profiler_data_collector'] = $pimple->share(function() { |
|
| 185 | 185 | return new ProfilerDataCollector(); |
| 186 | 186 | } ); |
| 187 | 187 | |
| 188 | - $pimple['dbal_connection'] = $pimple->share( function() { |
|
| 189 | - return DriverManager::getConnection( $this->config['db'] ); |
|
| 188 | + $pimple['dbal_connection'] = $pimple->share(function() { |
|
| 189 | + return DriverManager::getConnection($this->config['db']); |
|
| 190 | 190 | } ); |
| 191 | 191 | |
| 192 | - $pimple['entity_manager'] = $pimple->share( function() { |
|
| 193 | - $entityManager = ( new StoreFactory( $this->getConnection() ) )->getEntityManager(); |
|
| 194 | - if ( $this->addDoctrineSubscribers ) { |
|
| 195 | - $entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineDonationPrePersistSubscriber() ); |
|
| 196 | - $entityManager->getEventManager()->addEventSubscriber( $this->newDoctrineMembershipApplicationPrePersistSubscriber() ); |
|
| 192 | + $pimple['entity_manager'] = $pimple->share(function() { |
|
| 193 | + $entityManager = (new StoreFactory($this->getConnection()))->getEntityManager(); |
|
| 194 | + if ($this->addDoctrineSubscribers) { |
|
| 195 | + $entityManager->getEventManager()->addEventSubscriber($this->newDoctrineDonationPrePersistSubscriber()); |
|
| 196 | + $entityManager->getEventManager()->addEventSubscriber($this->newDoctrineMembershipApplicationPrePersistSubscriber()); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $entityManager; |
| 200 | 200 | } ); |
| 201 | 201 | |
| 202 | - $pimple['subscription_repository'] = $pimple->share( function() { |
|
| 202 | + $pimple['subscription_repository'] = $pimple->share(function() { |
|
| 203 | 203 | return new LoggingSubscriptionRepository( |
| 204 | - new DoctrineSubscriptionRepository( $this->getEntityManager() ), |
|
| 204 | + new DoctrineSubscriptionRepository($this->getEntityManager()), |
|
| 205 | 205 | $this->getLogger() |
| 206 | 206 | ); |
| 207 | 207 | } ); |
| 208 | 208 | |
| 209 | - $pimple['donation_repository'] = $pimple->share( function() { |
|
| 209 | + $pimple['donation_repository'] = $pimple->share(function() { |
|
| 210 | 210 | return new LoggingDonationRepository( |
| 211 | - new DoctrineDonationRepository( $this->getEntityManager() ), |
|
| 211 | + new DoctrineDonationRepository($this->getEntityManager()), |
|
| 212 | 212 | $this->getLogger() |
| 213 | 213 | ); |
| 214 | 214 | } ); |
| 215 | 215 | |
| 216 | - $pimple['membership_application_repository'] = $pimple->share( function() { |
|
| 216 | + $pimple['membership_application_repository'] = $pimple->share(function() { |
|
| 217 | 217 | return new LoggingApplicationRepository( |
| 218 | - new DoctrineApplicationRepository( $this->getEntityManager() ), |
|
| 218 | + new DoctrineApplicationRepository($this->getEntityManager()), |
|
| 219 | 219 | $this->getLogger() |
| 220 | 220 | ); |
| 221 | 221 | } ); |
| 222 | 222 | |
| 223 | - $pimple['comment_repository'] = $pimple->share( function() { |
|
| 223 | + $pimple['comment_repository'] = $pimple->share(function() { |
|
| 224 | 224 | $finder = new LoggingCommentFinder( |
| 225 | - new DoctrineCommentFinder( $this->getEntityManager() ), |
|
| 225 | + new DoctrineCommentFinder($this->getEntityManager()), |
|
| 226 | 226 | $this->getLogger() |
| 227 | 227 | ); |
| 228 | 228 | |
| 229 | - return $this->addProfilingDecorator( $finder, 'CommentFinder' ); |
|
| 229 | + return $this->addProfilingDecorator($finder, 'CommentFinder'); |
|
| 230 | 230 | } ); |
| 231 | 231 | |
| 232 | - $pimple['mail_validator'] = $pimple->share( function() { |
|
| 233 | - return new EmailValidator( new InternetDomainNameValidator() ); |
|
| 232 | + $pimple['mail_validator'] = $pimple->share(function() { |
|
| 233 | + return new EmailValidator(new InternetDomainNameValidator()); |
|
| 234 | 234 | } ); |
| 235 | 235 | |
| 236 | - $pimple['subscription_validator'] = $pimple->share( function() { |
|
| 236 | + $pimple['subscription_validator'] = $pimple->share(function() { |
|
| 237 | 237 | return new SubscriptionValidator( |
| 238 | 238 | $this->getEmailValidator(), |
| 239 | - $this->newTextPolicyValidator( 'fields' ), |
|
| 239 | + $this->newTextPolicyValidator('fields'), |
|
| 240 | 240 | $this->newSubscriptionDuplicateValidator(), |
| 241 | 241 | $this->newHonorificValidator() |
| 242 | 242 | ); |
| 243 | 243 | } ); |
| 244 | 244 | |
| 245 | - $pimple['template_name_validator'] = $pimple->share( function() { |
|
| 246 | - return new TemplateNameValidator( $this->getTwig() ); |
|
| 245 | + $pimple['template_name_validator'] = $pimple->share(function() { |
|
| 246 | + return new TemplateNameValidator($this->getTwig()); |
|
| 247 | 247 | } ); |
| 248 | 248 | |
| 249 | - $pimple['contact_validator'] = $pimple->share( function() { |
|
| 250 | - return new GetInTouchValidator( $this->getEmailValidator() ); |
|
| 249 | + $pimple['contact_validator'] = $pimple->share(function() { |
|
| 250 | + return new GetInTouchValidator($this->getEmailValidator()); |
|
| 251 | 251 | } ); |
| 252 | 252 | |
| 253 | - $pimple['greeting_generator'] = $pimple->share( function() { |
|
| 253 | + $pimple['greeting_generator'] = $pimple->share(function() { |
|
| 254 | 254 | return new GreetingGenerator(); |
| 255 | 255 | } ); |
| 256 | 256 | |
| 257 | - $pimple['mw_api'] = $pimple->share( function() { |
|
| 257 | + $pimple['mw_api'] = $pimple->share(function() { |
|
| 258 | 258 | return new MediawikiApi( |
| 259 | 259 | $this->config['cms-wiki-api-url'], |
| 260 | 260 | $this->getGuzzleClient() |
| 261 | 261 | ); |
| 262 | 262 | } ); |
| 263 | 263 | |
| 264 | - $pimple['guzzle_client'] = $pimple->share( function() { |
|
| 264 | + $pimple['guzzle_client'] = $pimple->share(function() { |
|
| 265 | 265 | $middlewareFactory = new MiddlewareFactory(); |
| 266 | - $middlewareFactory->setLogger( $this->getLogger() ); |
|
| 266 | + $middlewareFactory->setLogger($this->getLogger()); |
|
| 267 | 267 | |
| 268 | - $handlerStack = HandlerStack::create( new CurlHandler() ); |
|
| 269 | - $handlerStack->push( $middlewareFactory->retry() ); |
|
| 268 | + $handlerStack = HandlerStack::create(new CurlHandler()); |
|
| 269 | + $handlerStack->push($middlewareFactory->retry()); |
|
| 270 | 270 | |
| 271 | - $guzzle = new Client( [ |
|
| 271 | + $guzzle = new Client([ |
|
| 272 | 272 | 'cookies' => true, |
| 273 | 273 | 'handler' => $handlerStack, |
| 274 | - 'headers' => [ 'User-Agent' => 'WMDE Fundraising Frontend' ], |
|
| 275 | - ] ); |
|
| 274 | + 'headers' => ['User-Agent' => 'WMDE Fundraising Frontend'], |
|
| 275 | + ]); |
|
| 276 | 276 | |
| 277 | - return $this->addProfilingDecorator( $guzzle, 'Guzzle Client' ); |
|
| 277 | + return $this->addProfilingDecorator($guzzle, 'Guzzle Client'); |
|
| 278 | 278 | } ); |
| 279 | 279 | |
| 280 | - $pimple['translator'] = $pimple->share( function() { |
|
| 280 | + $pimple['translator'] = $pimple->share(function() { |
|
| 281 | 281 | $translationFactory = new TranslationFactory(); |
| 282 | 282 | $loaders = [ |
| 283 | 283 | 'json' => $translationFactory->newJsonLoader() |
| 284 | 284 | ]; |
| 285 | 285 | $locale = $this->config['locale']; |
| 286 | - $translator = $translationFactory->create( $loaders, $locale ); |
|
| 286 | + $translator = $translationFactory->create($loaders, $locale); |
|
| 287 | 287 | $translator->addResource( |
| 288 | 288 | 'json', |
| 289 | 289 | __DIR__ . '/../../app/translations/messages.' . $locale . '.json', |
@@ -322,36 +322,36 @@ discard block |
||
| 322 | 322 | } ); |
| 323 | 323 | |
| 324 | 324 | // In the future, this could be locale-specific or filled from a DB table |
| 325 | - $pimple['honorifics'] = $pimple->share( function() { |
|
| 326 | - return new Honorifics( [ |
|
| 325 | + $pimple['honorifics'] = $pimple->share(function() { |
|
| 326 | + return new Honorifics([ |
|
| 327 | 327 | '' => 'Kein Titel', |
| 328 | 328 | 'Dr.' => 'Dr.', |
| 329 | 329 | 'Prof.' => 'Prof.', |
| 330 | 330 | 'Prof. Dr.' => 'Prof. Dr.' |
| 331 | - ] ); |
|
| 331 | + ]); |
|
| 332 | 332 | } ); |
| 333 | 333 | |
| 334 | - $pimple['twig_factory'] = $pimple->share( function () { |
|
| 334 | + $pimple['twig_factory'] = $pimple->share(function() { |
|
| 335 | 335 | // TODO: like this we end up with two Twig instance, one created here and on in the framework |
| 336 | - return new TwigFactory( $this->config['twig'], $this->getCachePath() . '/twig' ); |
|
| 336 | + return new TwigFactory($this->config['twig'], $this->getCachePath() . '/twig'); |
|
| 337 | 337 | } ); |
| 338 | 338 | |
| 339 | - $pimple['twig'] = $pimple->share( function() { |
|
| 339 | + $pimple['twig'] = $pimple->share(function() { |
|
| 340 | 340 | $twigFactory = $this->getTwigFactory(); |
| 341 | - $loaders = array_filter( [ |
|
| 341 | + $loaders = array_filter([ |
|
| 342 | 342 | $twigFactory->newFileSystemLoader(), |
| 343 | 343 | $twigFactory->newArrayLoader(), // This is just a fallback for testing |
| 344 | - $twigFactory->newWikiPageLoader( $this->newWikiPageRetriever() ), |
|
| 345 | - ] ); |
|
| 344 | + $twigFactory->newWikiPageLoader($this->newWikiPageRetriever()), |
|
| 345 | + ]); |
|
| 346 | 346 | $extensions = [ |
| 347 | - $twigFactory->newTranslationExtension( $this->getTranslator() ), |
|
| 347 | + $twigFactory->newTranslationExtension($this->getTranslator()), |
|
| 348 | 348 | new Twig_Extensions_Extension_Intl() |
| 349 | 349 | ]; |
| 350 | 350 | |
| 351 | - return $twigFactory->create( $loaders, $extensions ); |
|
| 351 | + return $twigFactory->create($loaders, $extensions); |
|
| 352 | 352 | } ); |
| 353 | 353 | |
| 354 | - $pimple['messenger'] = $pimple->share( function() { |
|
| 354 | + $pimple['messenger'] = $pimple->share(function() { |
|
| 355 | 355 | return new Messenger( |
| 356 | 356 | new Swift_MailTransport(), |
| 357 | 357 | $this->getOperatorAddress(), |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | ); |
| 360 | 360 | } ); |
| 361 | 361 | |
| 362 | - $pimple['confirmation-page-selector'] = $pimple->share( function() { |
|
| 363 | - return new DonationConfirmationPageSelector( $this->config['confirmation-pages'] ); |
|
| 362 | + $pimple['confirmation-page-selector'] = $pimple->share(function() { |
|
| 363 | + return new DonationConfirmationPageSelector($this->config['confirmation-pages']); |
|
| 364 | 364 | } ); |
| 365 | 365 | |
| 366 | - $pimple['paypal-payment-notification-verifier'] = $pimple->share( function() { |
|
| 366 | + $pimple['paypal-payment-notification-verifier'] = $pimple->share(function() { |
|
| 367 | 367 | return new LoggingPaymentNotificationVerifier( |
| 368 | 368 | new PayPalPaymentNotificationVerifier( |
| 369 | 369 | new Client(), |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | ); |
| 374 | 374 | } ); |
| 375 | 375 | |
| 376 | - $pimple['credit-card-api-service'] = $pimple->share( function() { |
|
| 376 | + $pimple['credit-card-api-service'] = $pimple->share(function() { |
|
| 377 | 377 | return new McpCreditCardService( |
| 378 | 378 | new TNvpServiceDispatcher( |
| 379 | 379 | 'IMcpCreditcardService_v1_5', |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | ); |
| 385 | 385 | } ); |
| 386 | 386 | |
| 387 | - $pimple['token_generator'] = $pimple->share( function() { |
|
| 387 | + $pimple['token_generator'] = $pimple->share(function() { |
|
| 388 | 388 | return new RandomTokenGenerator( |
| 389 | 389 | $this->config['token-length'], |
| 390 | - new \DateInterval( $this->config['token-validity-timestamp'] ) |
|
| 390 | + new \DateInterval($this->config['token-validity-timestamp']) |
|
| 391 | 391 | ); |
| 392 | 392 | } ); |
| 393 | 393 | |
| 394 | - $pimple['page_cache'] = $pimple->share( function() { |
|
| 394 | + $pimple['page_cache'] = $pimple->share(function() { |
|
| 395 | 395 | return new VoidCache(); |
| 396 | 396 | } ); |
| 397 | 397 | |
@@ -408,17 +408,17 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | private function newDonationEventLogger(): DonationEventLogger { |
| 410 | 410 | return new BestEffortDonationEventLogger( |
| 411 | - new DoctrineDonationEventLogger( $this->getEntityManager() ), |
|
| 411 | + new DoctrineDonationEventLogger($this->getEntityManager()), |
|
| 412 | 412 | $this->getLogger() |
| 413 | 413 | ); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | public function newInstaller(): Installer { |
| 417 | - return ( new StoreFactory( $this->getConnection() ) )->newInstaller(); |
|
| 417 | + return (new StoreFactory($this->getConnection()))->newInstaller(); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | public function newListCommentsUseCase(): ListCommentsUseCase { |
| 421 | - return new ListCommentsUseCase( $this->getCommentFinder() ); |
|
| 421 | + return new ListCommentsUseCase($this->getCommentFinder()); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | public function newCommentListJsonPresenter(): CommentListJsonPresenter { |
@@ -426,14 +426,14 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | public function newCommentListRssPresenter(): CommentListRssPresenter { |
| 429 | - return new CommentListRssPresenter( new TwigTemplate( |
|
| 429 | + return new CommentListRssPresenter(new TwigTemplate( |
|
| 430 | 430 | $this->getTwig(), |
| 431 | 431 | 'CommentList.rss.twig' |
| 432 | - ) ); |
|
| 432 | + )); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | public function newCommentListHtmlPresenter(): CommentListHtmlPresenter { |
| 436 | - return new CommentListHtmlPresenter( $this->getLayoutTemplate( 'CommentList.html.twig', [ 'piwikGoals' => [ 1 ] ] ) ); |
|
| 436 | + return new CommentListHtmlPresenter($this->getLayoutTemplate('CommentList.html.twig', ['piwikGoals' => [1]])); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | private function getCommentFinder(): CommentFinder { |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | return $this->pimple['subscription_repository']; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - public function setSubscriptionRepository( SubscriptionRepository $subscriptionRepository ) { |
|
| 447 | + public function setSubscriptionRepository(SubscriptionRepository $subscriptionRepository) { |
|
| 448 | 448 | $this->pimple['subscription_repository'] = $subscriptionRepository; |
| 449 | 449 | } |
| 450 | 450 | |
@@ -467,26 +467,26 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | public function newDisplayPagePresenter(): DisplayPagePresenter { |
| 470 | - return new DisplayPagePresenter( $this->getLayoutTemplate( 'DisplayPageLayout.twig' ) ); |
|
| 470 | + return new DisplayPagePresenter($this->getLayoutTemplate('DisplayPageLayout.twig')); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | public function newAddSubscriptionHTMLPresenter(): AddSubscriptionHtmlPresenter { |
| 474 | - return new AddSubscriptionHtmlPresenter( $this->getIncludeTemplate( 'Subscription_Form.twig' ), $this->getTranslator() ); |
|
| 474 | + return new AddSubscriptionHtmlPresenter($this->getIncludeTemplate('Subscription_Form.twig'), $this->getTranslator()); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | public function newConfirmSubscriptionHtmlPresenter(): ConfirmSubscriptionHtmlPresenter { |
| 478 | 478 | return new ConfirmSubscriptionHtmlPresenter( |
| 479 | - $this->getLayoutTemplate( 'ConfirmSubscription.html.twig' ), |
|
| 479 | + $this->getLayoutTemplate('ConfirmSubscription.html.twig'), |
|
| 480 | 480 | $this->getTranslator() |
| 481 | 481 | ); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | public function newAddSubscriptionJSONPresenter(): AddSubscriptionJsonPresenter { |
| 485 | - return new AddSubscriptionJsonPresenter( $this->getTranslator() ); |
|
| 485 | + return new AddSubscriptionJsonPresenter($this->getTranslator()); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | public function newGetInTouchHTMLPresenter(): GetInTouchHtmlPresenter { |
| 489 | - return new GetInTouchHtmlPresenter( $this->getIncludeTemplate( 'Kontaktformular.twig' ), $this->getTranslator() ); |
|
| 489 | + return new GetInTouchHtmlPresenter($this->getIncludeTemplate('Kontaktformular.twig'), $this->getTranslator()); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | public function getTwig(): Twig_Environment { |
@@ -499,11 +499,11 @@ discard block |
||
| 499 | 499 | * @param string $templateName |
| 500 | 500 | * @return TwigTemplate |
| 501 | 501 | */ |
| 502 | - private function getLayoutTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 502 | + private function getLayoutTemplate(string $templateName, array $context = []): TwigTemplate { |
|
| 503 | 503 | return new TwigTemplate( |
| 504 | 504 | $this->getTwig(), |
| 505 | 505 | $templateName, |
| 506 | - array_merge( $this->getDefaultTwigVariables(), $context ) |
|
| 506 | + array_merge($this->getDefaultTwigVariables(), $context) |
|
| 507 | 507 | ); |
| 508 | 508 | } |
| 509 | 509 | |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | * @param string $templateName Template to include |
| 514 | 514 | * @return TwigTemplate |
| 515 | 515 | */ |
| 516 | - private function getIncludeTemplate( string $templateName, array $context = [] ): TwigTemplate { |
|
| 516 | + private function getIncludeTemplate(string $templateName, array $context = []): TwigTemplate { |
|
| 517 | 517 | return new TwigTemplate( |
| 518 | 518 | $this->getTwig(), |
| 519 | 519 | 'IncludeInLayout.twig', |
| 520 | 520 | array_merge( |
| 521 | 521 | $this->getDefaultTwigVariables(), |
| 522 | - [ 'main_template' => $templateName ], |
|
| 522 | + ['main_template' => $templateName], |
|
| 523 | 523 | $context |
| 524 | 524 | ) |
| 525 | 525 | ); |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | return $this->pimple['mw_api']; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - public function setMediaWikiApi( MediawikiApi $api ) { |
|
| 550 | + public function setMediaWikiApi(MediawikiApi $api) { |
|
| 551 | 551 | $this->pimple['mw_api'] = $api; |
| 552 | 552 | } |
| 553 | 553 | |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | $this->config['cms-wiki-title-prefix'] |
| 563 | 563 | ); |
| 564 | 564 | |
| 565 | - return $this->addProfilingDecorator( $PageRetriever, 'PageRetriever' ); |
|
| 565 | + return $this->addProfilingDecorator($PageRetriever, 'PageRetriever'); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | private function newCachedPageRetriever(): PageRetriever { |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | private function newNonCachedApiPageRetriever(): PageRetriever { |
| 576 | 576 | return new ApiBasedPageRetriever( |
| 577 | 577 | $this->getMediaWikiApi(), |
| 578 | - new ApiUser( $this->config['cms-wiki-user'], $this->config['cms-wiki-password'] ), |
|
| 578 | + new ApiUser($this->config['cms-wiki-user'], $this->config['cms-wiki-password']), |
|
| 579 | 579 | $this->getLogger() |
| 580 | 580 | ); |
| 581 | 581 | } |
@@ -640,22 +640,22 @@ discard block |
||
| 640 | 640 | new TwigTemplate( |
| 641 | 641 | $this->getTwig(), |
| 642 | 642 | 'Mail_Subscription_Confirmation.twig', |
| 643 | - [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 643 | + ['greeting_generator' => $this->getGreetingGenerator()] |
|
| 644 | 644 | ), |
| 645 | 645 | 'mail_subject_membership' |
| 646 | 646 | ); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - private function newTemplateMailer( TwigTemplate $template, string $messageKey ): TemplateBasedMailer { |
|
| 649 | + private function newTemplateMailer(TwigTemplate $template, string $messageKey): TemplateBasedMailer { |
|
| 650 | 650 | $mailer = new TemplateBasedMailer( |
| 651 | 651 | $this->getMessenger(), |
| 652 | 652 | $template, |
| 653 | - $this->getTranslator()->trans( $messageKey ) |
|
| 653 | + $this->getTranslator()->trans($messageKey) |
|
| 654 | 654 | ); |
| 655 | 655 | |
| 656 | - $mailer = new LoggingMailer( $mailer, $this->getLogger() ); |
|
| 656 | + $mailer = new LoggingMailer($mailer, $this->getLogger()); |
|
| 657 | 657 | |
| 658 | - return $this->addProfilingDecorator( $mailer, 'Mailer' ); |
|
| 658 | + return $this->addProfilingDecorator($mailer, 'Mailer'); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | public function getGreetingGenerator() { |
@@ -663,11 +663,11 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | public function newCheckIbanUseCase(): CheckIbanUseCase { |
| 666 | - return new CheckIbanUseCase( $this->newBankDataConverter() ); |
|
| 666 | + return new CheckIbanUseCase($this->newBankDataConverter()); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | public function newGenerateIbanUseCase(): GenerateIbanUseCase { |
| 670 | - return new GenerateIbanUseCase( $this->newBankDataConverter() ); |
|
| 670 | + return new GenerateIbanUseCase($this->newBankDataConverter()); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | public function newIbanPresenter(): IbanPresenter { |
@@ -675,14 +675,14 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | public function newBankDataConverter() { |
| 678 | - return new BankDataConverter( $this->config['bank-data-file'] ); |
|
| 678 | + return new BankDataConverter($this->config['bank-data-file']); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - public function setSubscriptionValidator( SubscriptionValidator $subscriptionValidator ) { |
|
| 681 | + public function setSubscriptionValidator(SubscriptionValidator $subscriptionValidator) { |
|
| 682 | 682 | $this->pimple['subscription_validator'] = $subscriptionValidator; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - public function setPageTitlePrefix( string $prefix ) { |
|
| 685 | + public function setPageTitlePrefix(string $prefix) { |
|
| 686 | 686 | $this->config['cms-wiki-title-prefix'] = $prefix; |
| 687 | 687 | } |
| 688 | 688 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | private function newContactConfirmationMailer(): TemplateBasedMailer { |
| 698 | 698 | return $this->newTemplateMailer( |
| 699 | - new TwigTemplate( $this->getTwig(), 'KontaktMailExtern.twig' ), |
|
| 699 | + new TwigTemplate($this->getTwig(), 'KontaktMailExtern.twig'), |
|
| 700 | 700 | 'mail_subject_getintouch' |
| 701 | 701 | ); |
| 702 | 702 | } |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | private function newSubscriptionDuplicateCutoffDate(): \DateTime { |
| 716 | 716 | $cutoffDateTime = new \DateTime(); |
| 717 | - $cutoffDateTime->sub( new \DateInterval( $this->config['subscription-interval'] ) ); |
|
| 717 | + $cutoffDateTime->sub(new \DateInterval($this->config['subscription-interval'])); |
|
| 718 | 718 | return $cutoffDateTime; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | private function newHonorificValidator(): AllowedValuesValidator { |
| 722 | - return new AllowedValuesValidator( $this->getHonorifics()->getKeys() ); |
|
| 722 | + return new AllowedValuesValidator($this->getHonorifics()->getKeys()); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | private function getHonorifics(): Honorifics { |
@@ -728,47 +728,47 @@ discard block |
||
| 728 | 728 | |
| 729 | 729 | public function newPurgeCacheUseCase(): PurgeCacheUseCase { |
| 730 | 730 | return new PurgeCacheUseCase( |
| 731 | - new AllOfTheCachePurger( $this->getTwig(), $this->getPageCache() ), |
|
| 731 | + new AllOfTheCachePurger($this->getTwig(), $this->getPageCache()), |
|
| 732 | 732 | $this->config['purging-secret'] |
| 733 | 733 | ); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | private function newBankDataValidator(): BankDataValidator { |
| 737 | - return new BankDataValidator( new IbanValidator( $this->newBankDataConverter() ) ); |
|
| 737 | + return new BankDataValidator(new IbanValidator($this->newBankDataConverter())); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | private function getMessenger(): Messenger { |
| 741 | 741 | return $this->pimple['messenger']; |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - public function setMessenger( Messenger $messenger ) { |
|
| 744 | + public function setMessenger(Messenger $messenger) { |
|
| 745 | 745 | $this->pimple['messenger'] = $messenger; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | public function setNullMessenger() { |
| 749 | - $this->setMessenger( new Messenger( |
|
| 749 | + $this->setMessenger(new Messenger( |
|
| 750 | 750 | Swift_NullTransport::newInstance(), |
| 751 | 751 | $this->getOperatorAddress() |
| 752 | - ) ); |
|
| 752 | + )); |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | public function getOperatorAddress() { |
| 756 | - return new EmailAddress( $this->config['operator-email'] ); |
|
| 756 | + return new EmailAddress($this->config['operator-email']); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | public function newInternalErrorHTMLPresenter(): InternalErrorHtmlPresenter { |
| 760 | - return new InternalErrorHtmlPresenter( $this->getIncludeTemplate( 'ErrorPage.twig' ) ); |
|
| 760 | + return new InternalErrorHtmlPresenter($this->getIncludeTemplate('ErrorPage.twig')); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | public function newAccessDeniedHTMLPresenter(): InternalErrorHtmlPresenter { |
| 764 | - return new InternalErrorHtmlPresenter( $this->getLayoutTemplate( 'AccessDenied.twig' ) ); |
|
| 764 | + return new InternalErrorHtmlPresenter($this->getLayoutTemplate('AccessDenied.twig')); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | public function getTranslator(): TranslatorInterface { |
| 768 | 768 | return $this->pimple['translator']; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - public function setTranslator( TranslatorInterface $translator ) { |
|
| 771 | + public function setTranslator(TranslatorInterface $translator) { |
|
| 772 | 772 | $this->pimple['translator'] = $translator; |
| 773 | 773 | } |
| 774 | 774 | |
@@ -776,25 +776,25 @@ discard block |
||
| 776 | 776 | return $this->pimple['twig_factory']; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - private function newTextPolicyValidator( string $policyName ): TextPolicyValidator { |
|
| 779 | + private function newTextPolicyValidator(string $policyName): TextPolicyValidator { |
|
| 780 | 780 | $contentProvider = $this->newWikiPageRetriever(); |
| 781 | 781 | $textPolicyConfig = $this->config['text-policies'][$policyName]; |
| 782 | 782 | |
| 783 | 783 | return new TextPolicyValidator( |
| 784 | - new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['badwords'] ?? '' ), |
|
| 785 | - new PageRetrieverBasedStringList( $contentProvider, $textPolicyConfig['whitewords'] ?? '' ) |
|
| 784 | + new PageRetrieverBasedStringList($contentProvider, $textPolicyConfig['badwords'] ?? ''), |
|
| 785 | + new PageRetrieverBasedStringList($contentProvider, $textPolicyConfig['whitewords'] ?? '') |
|
| 786 | 786 | ); |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | private function newCommentPolicyValidator(): TextPolicyValidator { |
| 790 | - return $this->newTextPolicyValidator( 'comment' ); |
|
| 790 | + return $this->newTextPolicyValidator('comment'); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - public function newCancelDonationUseCase( string $updateToken ): CancelDonationUseCase { |
|
| 793 | + public function newCancelDonationUseCase(string $updateToken): CancelDonationUseCase { |
|
| 794 | 794 | return new CancelDonationUseCase( |
| 795 | 795 | $this->getDonationRepository(), |
| 796 | 796 | $this->newCancelDonationMailer(), |
| 797 | - $this->newDonationAuthorizer( $updateToken ), |
|
| 797 | + $this->newDonationAuthorizer($updateToken), |
|
| 798 | 798 | $this->newDonationEventLogger() |
| 799 | 799 | ); |
| 800 | 800 | } |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | new TwigTemplate( |
| 805 | 805 | $this->getTwig(), |
| 806 | 806 | 'Mail_Donation_Cancellation_Confirmation.twig', |
| 807 | - [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 807 | + ['greeting_generator' => $this->getGreetingGenerator()] |
|
| 808 | 808 | ), |
| 809 | 809 | 'mail_subject_confirm_cancellation' |
| 810 | 810 | ); |
@@ -862,19 +862,19 @@ discard block |
||
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | public function newPayPalUrlGenerator() { |
| 865 | - return new PayPalUrlGenerator( $this->getPayPalUrlConfig() ); |
|
| 865 | + return new PayPalUrlGenerator($this->getPayPalUrlConfig()); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | private function getPayPalUrlConfig() { |
| 869 | - return PayPalUrlConfig::newFromConfig( $this->config['paypal'] ); |
|
| 869 | + return PayPalUrlConfig::newFromConfig($this->config['paypal']); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | private function newCreditCardUrlGenerator() { |
| 873 | - return new CreditCardUrlGenerator( $this->newCreditCardUrlConfig() ); |
|
| 873 | + return new CreditCardUrlGenerator($this->newCreditCardUrlConfig()); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | private function newCreditCardUrlConfig() { |
| 877 | - return CreditCardUrlConfig::newFromConfig( $this->config['creditcard'] ); |
|
| 877 | + return CreditCardUrlConfig::newFromConfig($this->config['creditcard']); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | public function getDonationRepository(): DonationRepository { |
@@ -882,27 +882,27 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | public function newAmountValidator(): AmountValidator { |
| 885 | - return new AmountValidator( 1 ); |
|
| 885 | + return new AmountValidator(1); |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | private function newAmountFormatter(): AmountFormatter { |
| 889 | - return new AmountFormatter( $this->config['locale'] ); |
|
| 889 | + return new AmountFormatter($this->config['locale']); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | public function newDecimalNumberFormatter(): NumberFormatter { |
| 893 | - return new NumberFormatter( $this->config['locale'], NumberFormatter::DECIMAL ); |
|
| 893 | + return new NumberFormatter($this->config['locale'], NumberFormatter::DECIMAL); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - public function newAddCommentUseCase( string $updateToken ): AddCommentUseCase { |
|
| 896 | + public function newAddCommentUseCase(string $updateToken): AddCommentUseCase { |
|
| 897 | 897 | return new AddCommentUseCase( |
| 898 | 898 | $this->getDonationRepository(), |
| 899 | - $this->newDonationAuthorizer( $updateToken ), |
|
| 899 | + $this->newDonationAuthorizer($updateToken), |
|
| 900 | 900 | $this->newCommentPolicyValidator(), |
| 901 | 901 | $this->newAddCommentValidator() |
| 902 | 902 | ); |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - private function newDonationAuthorizer( string $updateToken = null, string $accessToken = null ): DonationAuthorizer { |
|
| 905 | + private function newDonationAuthorizer(string $updateToken = null, string $accessToken = null): DonationAuthorizer { |
|
| 906 | 906 | return new DoctrineDonationAuthorizer( |
| 907 | 907 | $this->getEntityManager(), |
| 908 | 908 | $updateToken, |
@@ -916,13 +916,13 @@ discard block |
||
| 916 | 916 | |
| 917 | 917 | public function newDonationConfirmationPresenter() { |
| 918 | 918 | return new DonationConfirmationHtmlPresenter( |
| 919 | - $this->getIncludeTemplate( 'DonationConfirmation.twig', [ 'piwikGoals' => [ 3 ] ] ) |
|
| 919 | + $this->getIncludeTemplate('DonationConfirmation.twig', ['piwikGoals' => [3]]) |
|
| 920 | 920 | ); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | public function newCreditCardPaymentHtmlPresenter() { |
| 924 | 924 | return new CreditCardPaymentHtmlPresenter( |
| 925 | - $this->getIncludeTemplate( 'CreditCardPaymentIframe.twig' ), |
|
| 925 | + $this->getIncludeTemplate('CreditCardPaymentIframe.twig'), |
|
| 926 | 926 | $this->getTranslator(), |
| 927 | 927 | $this->newCreditCardUrlGenerator() |
| 928 | 928 | ); |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | |
| 931 | 931 | public function newCancelDonationHtmlPresenter() { |
| 932 | 932 | return new CancelDonationHtmlPresenter( |
| 933 | - $this->getIncludeTemplate( 'Donation_Cancellation_Confirmation.twig' ) |
|
| 933 | + $this->getIncludeTemplate('Donation_Cancellation_Confirmation.twig') |
|
| 934 | 934 | ); |
| 935 | 935 | } |
| 936 | 936 | |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | new TwigTemplate( |
| 951 | 951 | $this->getTwig(), |
| 952 | 952 | 'Mail_Membership_Application_Confirmation.twig', |
| 953 | - [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 953 | + ['greeting_generator' => $this->getGreetingGenerator()] |
|
| 954 | 954 | ), |
| 955 | 955 | 'mail_subject_confirm_membership_application' |
| 956 | 956 | ); |
@@ -965,16 +965,16 @@ discard block |
||
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | private function newMembershipApplicationTracker(): ApplicationTracker { |
| 968 | - return new DoctrineApplicationTracker( $this->getEntityManager() ); |
|
| 968 | + return new DoctrineApplicationTracker($this->getEntityManager()); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | private function newMembershipApplicationPiwikTracker(): ApplicationPiwikTracker { |
| 972 | - return new DoctrineApplicationPiwikTracker( $this->getEntityManager() ); |
|
| 972 | + return new DoctrineApplicationPiwikTracker($this->getEntityManager()); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - public function newCancelMembershipApplicationUseCase( string $updateToken ): CancelMembershipApplicationUseCase { |
|
| 975 | + public function newCancelMembershipApplicationUseCase(string $updateToken): CancelMembershipApplicationUseCase { |
|
| 976 | 976 | return new CancelMembershipApplicationUseCase( |
| 977 | - $this->newMembershipApplicationAuthorizer( $updateToken ), |
|
| 977 | + $this->newMembershipApplicationAuthorizer($updateToken), |
|
| 978 | 978 | $this->getMembershipApplicationRepository(), |
| 979 | 979 | $this->newCancelMembershipApplicationMailer() |
| 980 | 980 | ); |
@@ -999,27 +999,27 @@ discard block |
||
| 999 | 999 | new TwigTemplate( |
| 1000 | 1000 | $this->getTwig(), |
| 1001 | 1001 | 'Mail_Membership_Application_Cancellation_Confirmation.twig', |
| 1002 | - [ 'greeting_generator' => $this->getGreetingGenerator() ] |
|
| 1002 | + ['greeting_generator' => $this->getGreetingGenerator()] |
|
| 1003 | 1003 | ), |
| 1004 | 1004 | 'mail_subject_confirm_membership_application_cancellation' |
| 1005 | 1005 | ); |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - public function newMembershipApplicationConfirmationUseCase( string $accessToken ) { |
|
| 1008 | + public function newMembershipApplicationConfirmationUseCase(string $accessToken) { |
|
| 1009 | 1009 | return new ShowMembershipApplicationConfirmationUseCase( |
| 1010 | - $this->newMembershipApplicationAuthorizer( null, $accessToken ), $this->getMembershipApplicationRepository(), |
|
| 1010 | + $this->newMembershipApplicationAuthorizer(null, $accessToken), $this->getMembershipApplicationRepository(), |
|
| 1011 | 1011 | $this->newMembershipApplicationTokenFetcher() |
| 1012 | 1012 | ); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - public function newShowDonationConfirmationUseCase( string $accessToken ): ShowDonationConfirmationUseCase { |
|
| 1015 | + public function newShowDonationConfirmationUseCase(string $accessToken): ShowDonationConfirmationUseCase { |
|
| 1016 | 1016 | return new ShowDonationConfirmationUseCase( |
| 1017 | - $this->newDonationAuthorizer( null, $accessToken ), |
|
| 1017 | + $this->newDonationAuthorizer(null, $accessToken), |
|
| 1018 | 1018 | $this->getDonationRepository() |
| 1019 | 1019 | ); |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - public function setDonationConfirmationPageSelector( DonationConfirmationPageSelector $selector ) { |
|
| 1022 | + public function setDonationConfirmationPageSelector(DonationConfirmationPageSelector $selector) { |
|
| 1023 | 1023 | $this->pimple['confirmation-page-selector'] = $selector; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
@@ -1028,25 +1028,25 @@ discard block |
||
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | public function newDonationFormViolationPresenter() { |
| 1031 | - $template = $this->getLayoutTemplate( 'DisplayPageLayout.twig' ); |
|
| 1031 | + $template = $this->getLayoutTemplate('DisplayPageLayout.twig'); |
|
| 1032 | 1032 | // TODO make this dependent on the 'form' value from the HTTP POST request |
| 1033 | 1033 | // (we need different form pages for A/B testing) |
| 1034 | 1034 | $template->context['main_template'] = 'DonationForm.twig'; |
| 1035 | - return new DonationFormViolationPresenter( $template, $this->newAmountFormatter() ); |
|
| 1035 | + return new DonationFormViolationPresenter($template, $this->newAmountFormatter()); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | public function newDonationFormPresenter() { |
| 1039 | - $template = $this->getLayoutTemplate( 'DisplayPageLayout.twig' ); |
|
| 1039 | + $template = $this->getLayoutTemplate('DisplayPageLayout.twig'); |
|
| 1040 | 1040 | // TODO make this dependent on the 'form' value from the HTTP POST request |
| 1041 | 1041 | // (we need different form pages for A/B testing) |
| 1042 | 1042 | $template->context['main_template'] = 'DonationForm.twig'; |
| 1043 | - return new DonationFormPresenter( $template, $this->newAmountFormatter() ); |
|
| 1043 | + return new DonationFormPresenter($template, $this->newAmountFormatter()); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - public function newHandlePayPalPaymentNotificationUseCase( string $updateToken ) { |
|
| 1046 | + public function newHandlePayPalPaymentNotificationUseCase(string $updateToken) { |
|
| 1047 | 1047 | return new HandlePayPalPaymentNotificationUseCase( |
| 1048 | 1048 | $this->getDonationRepository(), |
| 1049 | - $this->newDonationAuthorizer( $updateToken ), |
|
| 1049 | + $this->newDonationAuthorizer($updateToken), |
|
| 1050 | 1050 | $this->newDonationConfirmationMailer(), |
| 1051 | 1051 | $this->getLogger(), |
| 1052 | 1052 | $this->newDonationEventLogger() |
@@ -1057,14 +1057,14 @@ discard block |
||
| 1057 | 1057 | return $this->pimple['paypal-payment-notification-verifier']; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - public function setPayPalPaymentNotificationVerifier( PaymentNotificationVerifier $verifier ) { |
|
| 1060 | + public function setPayPalPaymentNotificationVerifier(PaymentNotificationVerifier $verifier) { |
|
| 1061 | 1061 | $this->pimple['paypal-payment-notification-verifier'] = $verifier; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | - public function newCreditCardNotificationUseCase( string $updateToken ) { |
|
| 1064 | + public function newCreditCardNotificationUseCase(string $updateToken) { |
|
| 1065 | 1065 | return new CreditCardNotificationUseCase( |
| 1066 | 1066 | $this->getDonationRepository(), |
| 1067 | - $this->newDonationAuthorizer( $updateToken ), |
|
| 1067 | + $this->newDonationAuthorizer($updateToken), |
|
| 1068 | 1068 | $this->getCreditCardService(), |
| 1069 | 1069 | $this->newDonationConfirmationMailer(), |
| 1070 | 1070 | $this->getLogger(), |
@@ -1074,23 +1074,23 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | public function newCancelMembershipApplicationHtmlPresenter() { |
| 1076 | 1076 | return new CancelMembershipApplicationHtmlPresenter( |
| 1077 | - $this->getIncludeTemplate( 'Membership_Application_Cancellation_Confirmation.twig' ) |
|
| 1077 | + $this->getIncludeTemplate('Membership_Application_Cancellation_Confirmation.twig') |
|
| 1078 | 1078 | ); |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | public function newMembershipApplicationConfirmationHtmlPresenter() { |
| 1082 | 1082 | return new MembershipApplicationConfirmationHtmlPresenter( |
| 1083 | - $this->getIncludeTemplate( 'MembershipApplicationConfirmation.twig' ) |
|
| 1083 | + $this->getIncludeTemplate('MembershipApplicationConfirmation.twig') |
|
| 1084 | 1084 | ); |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | public function newMembershipFormViolationPresenter() { |
| 1088 | 1088 | return new MembershipFormViolationPresenter( |
| 1089 | - $this->getIncludeTemplate( 'MembershipApplication.twig' ) |
|
| 1089 | + $this->getIncludeTemplate('MembershipApplication.twig') |
|
| 1090 | 1090 | ); |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - public function setCreditCardService( CreditCardService $ccService ) { |
|
| 1093 | + public function setCreditCardService(CreditCardService $ccService) { |
|
| 1094 | 1094 | $this->pimple['credit-card-api-service'] = $ccService; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | new TwigTemplate( |
| 1104 | 1104 | $this->getTwig(), |
| 1105 | 1105 | 'CreditCardPaymentNotification.twig', |
| 1106 | - [ 'returnUrl' => $this->config['creditcard']['return-url'] ] |
|
| 1106 | + ['returnUrl' => $this->config['creditcard']['return-url']] |
|
| 1107 | 1107 | ) |
| 1108 | 1108 | ); |
| 1109 | 1109 | } |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | ); |
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | - public function setTokenGenerator( TokenGenerator $tokenGenerator ) { |
|
| 1127 | + public function setTokenGenerator(TokenGenerator $tokenGenerator) { |
|
| 1128 | 1128 | $this->pimple['token_generator'] = $tokenGenerator; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
@@ -1147,22 +1147,22 @@ discard block |
||
| 1147 | 1147 | private function newDonationPolicyValidator(): AddDonationPolicyValidator { |
| 1148 | 1148 | return new AddDonationPolicyValidator( |
| 1149 | 1149 | $this->newDonationAmountPolicyValidator(), |
| 1150 | - $this->newTextPolicyValidator( 'fields' ) |
|
| 1150 | + $this->newTextPolicyValidator('fields') |
|
| 1151 | 1151 | ); |
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | private function newDonationAmountPolicyValidator(): AmountPolicyValidator { |
| 1155 | 1155 | // in the future, this might come from the configuration |
| 1156 | - return new AmountPolicyValidator( 1000, 200, 300 ); |
|
| 1156 | + return new AmountPolicyValidator(1000, 200, 300); |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | 1159 | public function getDonationTimeframeLimit() { |
| 1160 | 1160 | return $this->config['donation-timeframe-limit']; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - public function newSystemMessageResponse( string $message ) { |
|
| 1164 | - $test = $this->getIncludeTemplate( 'System_Message.twig' ); |
|
| 1165 | - return $test->render( [ 'message' => $message ] ); |
|
| 1163 | + public function newSystemMessageResponse(string $message) { |
|
| 1164 | + $test = $this->getIncludeTemplate('System_Message.twig'); |
|
| 1165 | + return $test->render(['message' => $message]); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | public function getMembershipApplicationTimeframeLimit() { |
@@ -1178,26 +1178,26 @@ discard block |
||
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | public function enablePageCache() { |
| 1181 | - $this->pimple['page_cache'] = $this->pimple->share( function() { |
|
| 1182 | - return new FilesystemCache( $this->getCachePath() . '/pages' ); |
|
| 1181 | + $this->pimple['page_cache'] = $this->pimple->share(function() { |
|
| 1182 | + return new FilesystemCache($this->getCachePath() . '/pages'); |
|
| 1183 | 1183 | } ); |
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | - private function addProfilingDecorator( $objectToDecorate, string $profilingLabel ) { |
|
| 1187 | - if ( $this->profiler === null ) { |
|
| 1186 | + private function addProfilingDecorator($objectToDecorate, string $profilingLabel) { |
|
| 1187 | + if ($this->profiler === null) { |
|
| 1188 | 1188 | return $objectToDecorate; |
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | - $builder = new ProfilingDecoratorBuilder( $this->profiler, $this->getProfilerDataCollector() ); |
|
| 1191 | + $builder = new ProfilingDecoratorBuilder($this->profiler, $this->getProfilerDataCollector()); |
|
| 1192 | 1192 | |
| 1193 | - return $builder->decorate( $objectToDecorate, $profilingLabel ); |
|
| 1193 | + return $builder->decorate($objectToDecorate, $profilingLabel); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - public function setProfiler( Stopwatch $profiler ) { |
|
| 1196 | + public function setProfiler(Stopwatch $profiler) { |
|
| 1197 | 1197 | $this->profiler = $profiler; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - public function setLogger( LoggerInterface $logger ) { |
|
| 1200 | + public function setLogger(LoggerInterface $logger) { |
|
| 1201 | 1201 | $this->pimple['logger'] = $logger; |
| 1202 | 1202 | } |
| 1203 | 1203 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\Infrastructure; |
| 6 | 6 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | private $logger; |
| 24 | 24 | private $logLevel; |
| 25 | 25 | |
| 26 | - public function __construct( ApplicationRepository $repository, LoggerInterface $logger ) { |
|
| 26 | + public function __construct(ApplicationRepository $repository, LoggerInterface $logger) { |
|
| 27 | 27 | $this->repository = $repository; |
| 28 | 28 | $this->logger = $logger; |
| 29 | 29 | $this->logLevel = LogLevel::CRITICAL; |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @throws StoreMembershipApplicationException |
| 38 | 38 | */ |
| 39 | - public function storeApplication( Application $application ) { |
|
| 39 | + public function storeApplication(Application $application) { |
|
| 40 | 40 | try { |
| 41 | - $this->repository->storeApplication( $application ); |
|
| 41 | + $this->repository->storeApplication($application); |
|
| 42 | 42 | } |
| 43 | - catch ( StoreMembershipApplicationException $ex ) { |
|
| 44 | - $this->logger->log( $this->logLevel, $ex->getMessage(), [ self::CONTEXT_EXCEPTION_KEY => $ex ] ); |
|
| 43 | + catch (StoreMembershipApplicationException $ex) { |
|
| 44 | + $this->logger->log($this->logLevel, $ex->getMessage(), [self::CONTEXT_EXCEPTION_KEY => $ex]); |
|
| 45 | 45 | throw $ex; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | * @return Application|null |
| 55 | 55 | * @throws GetMembershipApplicationException |
| 56 | 56 | */ |
| 57 | - public function getApplicationById( int $id ) { |
|
| 57 | + public function getApplicationById(int $id) { |
|
| 58 | 58 | try { |
| 59 | - return $this->repository->getApplicationById( $id ); |
|
| 59 | + return $this->repository->getApplicationById($id); |
|
| 60 | 60 | } |
| 61 | - catch ( GetMembershipApplicationException $ex ) { |
|
| 62 | - $this->logger->log( $this->logLevel, $ex->getMessage(), [ self::CONTEXT_EXCEPTION_KEY => $ex ] ); |
|
| 61 | + catch (GetMembershipApplicationException $ex) { |
|
| 62 | + $this->logger->log($this->logLevel, $ex->getMessage(), [self::CONTEXT_EXCEPTION_KEY => $ex]); |
|
| 63 | 63 | throw $ex; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\Domain\Model; |
| 6 | 6 | |
@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @throws \InvalidArgumentException |
| 23 | 23 | */ |
| 24 | - public function __construct( int $intervalInMonths, Euro $amount, BankData $bankData ) { |
|
| 25 | - $this->assertIsValidInterval( $intervalInMonths ); |
|
| 24 | + public function __construct(int $intervalInMonths, Euro $amount, BankData $bankData) { |
|
| 25 | + $this->assertIsValidInterval($intervalInMonths); |
|
| 26 | 26 | |
| 27 | 27 | $this->interval = $intervalInMonths; |
| 28 | 28 | $this->amount = $amount; |
| 29 | 29 | $this->bankData = $bankData; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function assertIsValidInterval( int $intervalInMonths ) { |
|
| 33 | - if ( !in_array( $intervalInMonths, [ 1, 3, 6, 12 ] ) ) { |
|
| 34 | - throw new \InvalidArgumentException( 'Interval needs to be 1, 3, 6 or 12' ); |
|
| 32 | + private function assertIsValidInterval(int $intervalInMonths) { |
|
| 33 | + if (!in_array($intervalInMonths, [1, 3, 6, 12])) { |
|
| 34 | + throw new \InvalidArgumentException('Interval needs to be 1, 3, 6 or 12'); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function getYearlyAmount(): Euro { |
| 51 | - return Euro::newFromCents( $this->amount->getEuroCents() * $this->getPaymentsPerYear() ); |
|
| 51 | + return Euro::newFromCents($this->amount->getEuroCents() * $this->getPaymentsPerYear()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function getPaymentsPerYear(): int { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Model; |
| 6 | 6 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | private $needsModeration; |
| 31 | 31 | private $isCancelled; |
| 32 | 32 | |
| 33 | - public static function newApplication( string $type, Applicant $applicant, Payment $payment ): self { |
|
| 33 | + public static function newApplication(string $type, Applicant $applicant, Payment $payment): self { |
|
| 34 | 34 | return new self( |
| 35 | 35 | null, |
| 36 | 36 | $type, |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function __construct( int $id = null, string $type, Applicant $applicant, Payment $payment, |
|
| 45 | - bool $needsModeration, bool $isCancelled ) { |
|
| 44 | + public function __construct(int $id = null, string $type, Applicant $applicant, Payment $payment, |
|
| 45 | + bool $needsModeration, bool $isCancelled) { |
|
| 46 | 46 | |
| 47 | 47 | $this->id = $id; |
| 48 | 48 | $this->type = $type; |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @param int $id |
| 80 | 80 | * @throws \RuntimeException |
| 81 | 81 | */ |
| 82 | - public function assignId( int $id ) { |
|
| 83 | - if ( $this->id !== null && $this->id !== $id ) { |
|
| 84 | - throw new \RuntimeException( 'Id cannot be changed after initial assignment' ); |
|
| 82 | + public function assignId(int $id) { |
|
| 83 | + if ($this->id !== null && $this->id !== $id) { |
|
| 84 | + throw new \RuntimeException('Id cannot be changed after initial assignment'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $this->id = $id; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Repositories; |
| 6 | 6 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @throws StoreMembershipApplicationException |
| 23 | 23 | */ |
| 24 | - public function storeApplication( Application $application ); |
|
| 24 | + public function storeApplication(Application $application); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @param int $id |
@@ -29,6 +29,6 @@ discard block |
||
| 29 | 29 | * @return Application|null |
| 30 | 30 | * @throws GetMembershipApplicationException |
| 31 | 31 | */ |
| 32 | - public function getApplicationById( int $id ); |
|
| 32 | + public function getApplicationById(int $id); |
|
| 33 | 33 | |
| 34 | 34 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\DataAccess; |
| 6 | 6 | |
@@ -29,102 +29,102 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | private $entityManager; |
| 31 | 31 | |
| 32 | - public function __construct( EntityManager $entityManager ) { |
|
| 32 | + public function __construct(EntityManager $entityManager) { |
|
| 33 | 33 | $this->entityManager = $entityManager; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function storeApplication( Application $application ) { |
|
| 37 | - if ( $application->hasId() ) { |
|
| 38 | - $this->updateApplication( $application ); |
|
| 36 | + public function storeApplication(Application $application) { |
|
| 37 | + if ($application->hasId()) { |
|
| 38 | + $this->updateApplication($application); |
|
| 39 | 39 | } |
| 40 | 40 | else { |
| 41 | - $this->insertApplication( $application ); |
|
| 41 | + $this->insertApplication($application); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - private function insertApplication( Application $application ) { |
|
| 45 | + private function insertApplication(Application $application) { |
|
| 46 | 46 | $doctrineApplication = new DoctrineApplication(); |
| 47 | - $this->updateDoctrineApplication( $doctrineApplication, $application ); |
|
| 47 | + $this->updateDoctrineApplication($doctrineApplication, $application); |
|
| 48 | 48 | |
| 49 | 49 | try { |
| 50 | - $this->entityManager->persist( $doctrineApplication ); |
|
| 50 | + $this->entityManager->persist($doctrineApplication); |
|
| 51 | 51 | $this->entityManager->flush(); |
| 52 | 52 | } |
| 53 | - catch ( ORMException $ex ) { |
|
| 54 | - throw new StoreMembershipApplicationException( $ex ); |
|
| 53 | + catch (ORMException $ex) { |
|
| 54 | + throw new StoreMembershipApplicationException($ex); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $application->assignId( $doctrineApplication->getId() ); |
|
| 57 | + $application->assignId($doctrineApplication->getId()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - private function updateApplication( Application $application ) { |
|
| 61 | - $doctrineApplication = $this->getDoctrineApplicationById( $application->getId() ); |
|
| 60 | + private function updateApplication(Application $application) { |
|
| 61 | + $doctrineApplication = $this->getDoctrineApplicationById($application->getId()); |
|
| 62 | 62 | |
| 63 | - if ( $doctrineApplication === null ) { |
|
| 63 | + if ($doctrineApplication === null) { |
|
| 64 | 64 | throw new StoreMembershipApplicationException(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $this->updateDoctrineApplication( $doctrineApplication, $application ); |
|
| 67 | + $this->updateDoctrineApplication($doctrineApplication, $application); |
|
| 68 | 68 | |
| 69 | 69 | try { |
| 70 | - $this->entityManager->persist( $doctrineApplication ); |
|
| 70 | + $this->entityManager->persist($doctrineApplication); |
|
| 71 | 71 | $this->entityManager->flush(); |
| 72 | 72 | } |
| 73 | - catch ( ORMException $ex ) { |
|
| 74 | - throw new StoreMembershipApplicationException( $ex ); |
|
| 73 | + catch (ORMException $ex) { |
|
| 74 | + throw new StoreMembershipApplicationException($ex); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - private function updateDoctrineApplication( DoctrineApplication $doctrineApplication, Application $application ) { |
|
| 79 | - $doctrineApplication->setId( $application->getId() ); |
|
| 80 | - $doctrineApplication->setMembershipType( $application->getType() ); |
|
| 78 | + private function updateDoctrineApplication(DoctrineApplication $doctrineApplication, Application $application) { |
|
| 79 | + $doctrineApplication->setId($application->getId()); |
|
| 80 | + $doctrineApplication->setMembershipType($application->getType()); |
|
| 81 | 81 | |
| 82 | - $this->setApplicantFields( $doctrineApplication, $application->getApplicant() ); |
|
| 83 | - $this->setPaymentFields( $doctrineApplication, $application->getPayment() ); |
|
| 82 | + $this->setApplicantFields($doctrineApplication, $application->getApplicant()); |
|
| 83 | + $this->setPaymentFields($doctrineApplication, $application->getPayment()); |
|
| 84 | 84 | |
| 85 | - $doctrineApplication->setStatus( $this->getDoctrineStatus( $application ) ); |
|
| 85 | + $doctrineApplication->setStatus($this->getDoctrineStatus($application)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - private function setApplicantFields( DoctrineApplication $application, Applicant $applicant ) { |
|
| 89 | - $application->setApplicantFirstName( $applicant->getName()->getFirstName() ); |
|
| 90 | - $application->setApplicantLastName( $applicant->getName()->getLastName() ); |
|
| 91 | - $application->setApplicantSalutation( $applicant->getName()->getSalutation() ); |
|
| 92 | - $application->setApplicantTitle( $applicant->getName()->getTitle() ); |
|
| 88 | + private function setApplicantFields(DoctrineApplication $application, Applicant $applicant) { |
|
| 89 | + $application->setApplicantFirstName($applicant->getName()->getFirstName()); |
|
| 90 | + $application->setApplicantLastName($applicant->getName()->getLastName()); |
|
| 91 | + $application->setApplicantSalutation($applicant->getName()->getSalutation()); |
|
| 92 | + $application->setApplicantTitle($applicant->getName()->getTitle()); |
|
| 93 | 93 | |
| 94 | - $application->setApplicantDateOfBirth( $applicant->getDateOfBirth() ); |
|
| 94 | + $application->setApplicantDateOfBirth($applicant->getDateOfBirth()); |
|
| 95 | 95 | |
| 96 | - $application->setApplicantEmailAddress( $applicant->getEmailAddress()->getFullAddress() ); |
|
| 97 | - $application->setApplicantPhoneNumber( $applicant->getPhoneNumber()->__toString() ); |
|
| 96 | + $application->setApplicantEmailAddress($applicant->getEmailAddress()->getFullAddress()); |
|
| 97 | + $application->setApplicantPhoneNumber($applicant->getPhoneNumber()->__toString()); |
|
| 98 | 98 | |
| 99 | 99 | $address = $applicant->getPhysicalAddress(); |
| 100 | 100 | |
| 101 | - $application->setCity( $address->getCity() ); |
|
| 102 | - $application->setCountry( $address->getCountryCode() ); |
|
| 103 | - $application->setPostcode( $address->getPostalCode() ); |
|
| 104 | - $application->setAddress( $address->getStreetAddress() ); |
|
| 101 | + $application->setCity($address->getCity()); |
|
| 102 | + $application->setCountry($address->getCountryCode()); |
|
| 103 | + $application->setPostcode($address->getPostalCode()); |
|
| 104 | + $application->setAddress($address->getStreetAddress()); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - private function setPaymentFields( DoctrineApplication $application, Payment $payment ) { |
|
| 108 | - $application->setPaymentIntervalInMonths( $payment->getIntervalInMonths() ); |
|
| 109 | - $application->setPaymentAmount( (int)$payment->getAmount()->getEuroFloat() ); |
|
| 107 | + private function setPaymentFields(DoctrineApplication $application, Payment $payment) { |
|
| 108 | + $application->setPaymentIntervalInMonths($payment->getIntervalInMonths()); |
|
| 109 | + $application->setPaymentAmount((int)$payment->getAmount()->getEuroFloat()); |
|
| 110 | 110 | |
| 111 | 111 | $bankData = $payment->getBankData(); |
| 112 | 112 | |
| 113 | - $application->setPaymentBankAccount( $bankData->getAccount() ); |
|
| 114 | - $application->setPaymentBankCode( $bankData->getBankCode() ); |
|
| 115 | - $application->setPaymentBankName( $bankData->getBankName() ); |
|
| 116 | - $application->setPaymentBic( $bankData->getBic() ); |
|
| 117 | - $application->setPaymentIban( $bankData->getIban()->toString() ); |
|
| 113 | + $application->setPaymentBankAccount($bankData->getAccount()); |
|
| 114 | + $application->setPaymentBankCode($bankData->getBankCode()); |
|
| 115 | + $application->setPaymentBankName($bankData->getBankName()); |
|
| 116 | + $application->setPaymentBic($bankData->getBic()); |
|
| 117 | + $application->setPaymentIban($bankData->getIban()->toString()); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - private function getDoctrineStatus( Application $application ): int { |
|
| 120 | + private function getDoctrineStatus(Application $application): int { |
|
| 121 | 121 | $status = DoctrineApplication::STATUS_NEUTRAL; |
| 122 | 122 | |
| 123 | - if ( $application->needsModeration() ) { |
|
| 123 | + if ($application->needsModeration()) { |
|
| 124 | 124 | $status += DoctrineApplication::STATUS_MODERATION; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( $application->isCancelled() ) { |
|
| 127 | + if ($application->isCancelled()) { |
|
| 128 | 128 | $status += DoctrineApplication::STATUS_CANCELED; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -137,19 +137,19 @@ discard block |
||
| 137 | 137 | * @return \WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Model\Application|null |
| 138 | 138 | * @throws \WMDE\Fundraising\Frontend\MembershipApplicationContext\Domain\Repositories\GetMembershipApplicationException |
| 139 | 139 | */ |
| 140 | - public function getApplicationById( int $id ) { |
|
| 140 | + public function getApplicationById(int $id) { |
|
| 141 | 141 | try { |
| 142 | - $application = $this->getDoctrineApplicationById( $id ); |
|
| 142 | + $application = $this->getDoctrineApplicationById($id); |
|
| 143 | 143 | } |
| 144 | - catch ( ORMException $ex ) { |
|
| 145 | - throw new GetMembershipApplicationException( $ex ); |
|
| 144 | + catch (ORMException $ex) { |
|
| 145 | + throw new GetMembershipApplicationException($ex); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ( $application === null ) { |
|
| 148 | + if ($application === null) { |
|
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - return $this->newApplicationDomainEntity( $application ); |
|
| 152 | + return $this->newApplicationDomainEntity($application); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -157,61 +157,61 @@ discard block |
||
| 157 | 157 | * @return DoctrineApplication|null |
| 158 | 158 | * @throws ORMException |
| 159 | 159 | */ |
| 160 | - public function getDoctrineApplicationById( int $id ) { |
|
| 161 | - return $this->entityManager->find( DoctrineApplication::class, $id ); |
|
| 160 | + public function getDoctrineApplicationById(int $id) { |
|
| 161 | + return $this->entityManager->find(DoctrineApplication::class, $id); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - private function newApplicationDomainEntity( DoctrineApplication $application ): Application { |
|
| 164 | + private function newApplicationDomainEntity(DoctrineApplication $application): Application { |
|
| 165 | 165 | return new Application( |
| 166 | 166 | $application->getId(), |
| 167 | 167 | $application->getMembershipType(), |
| 168 | 168 | new Applicant( |
| 169 | - $this->newPersonName( $application ), |
|
| 170 | - $this->newAddress( $application ), |
|
| 171 | - new EmailAddress( $application->getApplicantEmailAddress() ), |
|
| 172 | - new PhoneNumber( $application->getApplicantPhoneNumber() ), |
|
| 169 | + $this->newPersonName($application), |
|
| 170 | + $this->newAddress($application), |
|
| 171 | + new EmailAddress($application->getApplicantEmailAddress()), |
|
| 172 | + new PhoneNumber($application->getApplicantPhoneNumber()), |
|
| 173 | 173 | $application->getApplicantDateOfBirth() |
| 174 | 174 | ), |
| 175 | 175 | new Payment( |
| 176 | 176 | $application->getPaymentIntervalInMonths(), |
| 177 | - Euro::newFromFloat( $application->getPaymentAmount() ), |
|
| 178 | - $this->newBankData( $application ) |
|
| 177 | + Euro::newFromFloat($application->getPaymentAmount()), |
|
| 178 | + $this->newBankData($application) |
|
| 179 | 179 | ), |
| 180 | 180 | $application->needsModeration(), |
| 181 | 181 | $application->isCancelled() |
| 182 | 182 | ); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - private function newPersonName( DoctrineApplication $application ): ApplicantName { |
|
| 185 | + private function newPersonName(DoctrineApplication $application): ApplicantName { |
|
| 186 | 186 | $personName = ApplicantName::newPrivatePersonName(); |
| 187 | 187 | |
| 188 | - $personName->setFirstName( $application->getApplicantFirstName() ); |
|
| 189 | - $personName->setLastName( $application->getApplicantLastName() ); |
|
| 190 | - $personName->setSalutation( $application->getApplicantSalutation() ); |
|
| 191 | - $personName->setTitle( $application->getApplicantTitle() ); |
|
| 188 | + $personName->setFirstName($application->getApplicantFirstName()); |
|
| 189 | + $personName->setLastName($application->getApplicantLastName()); |
|
| 190 | + $personName->setSalutation($application->getApplicantSalutation()); |
|
| 191 | + $personName->setTitle($application->getApplicantTitle()); |
|
| 192 | 192 | |
| 193 | 193 | return $personName->freeze()->assertNoNullFields(); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - private function newAddress( DoctrineApplication $application ): PhysicalAddress { |
|
| 196 | + private function newAddress(DoctrineApplication $application): PhysicalAddress { |
|
| 197 | 197 | $address = new PhysicalAddress(); |
| 198 | 198 | |
| 199 | - $address->setCity( $application->getCity() ); |
|
| 200 | - $address->setCountryCode( $application->getCountry() ); |
|
| 201 | - $address->setPostalCode( $application->getPostcode() ); |
|
| 202 | - $address->setStreetAddress( $application->getAddress() ); |
|
| 199 | + $address->setCity($application->getCity()); |
|
| 200 | + $address->setCountryCode($application->getCountry()); |
|
| 201 | + $address->setPostalCode($application->getPostcode()); |
|
| 202 | + $address->setStreetAddress($application->getAddress()); |
|
| 203 | 203 | |
| 204 | 204 | return $address->freeze()->assertNoNullFields(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - private function newBankData( DoctrineApplication $application ): BankData { |
|
| 207 | + private function newBankData(DoctrineApplication $application): BankData { |
|
| 208 | 208 | $bankData = new BankData(); |
| 209 | 209 | |
| 210 | - $bankData->setAccount( $application->getPaymentBankAccount() ); |
|
| 211 | - $bankData->setBankCode( $application->getPaymentBankCode() ); |
|
| 212 | - $bankData->setBankName( $application->getPaymentBankName() ); |
|
| 213 | - $bankData->setBic( $application->getPaymentBic() ); |
|
| 214 | - $bankData->setIban( new Iban( $application->getPaymentIban() ) ); |
|
| 210 | + $bankData->setAccount($application->getPaymentBankAccount()); |
|
| 211 | + $bankData->setBankCode($application->getPaymentBankCode()); |
|
| 212 | + $bankData->setBankName($application->getPaymentBankName()); |
|
| 213 | + $bankData->setBic($application->getPaymentBic()); |
|
| 214 | + $bankData->setIban(new Iban($application->getPaymentIban())); |
|
| 215 | 215 | |
| 216 | 216 | return $bankData->freeze()->assertNoNullFields(); |
| 217 | 217 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\DataAccess; |
| 6 | 6 | |
@@ -18,41 +18,41 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | private $entityManager; |
| 20 | 20 | |
| 21 | - public function __construct( EntityManager $entityManager ) { |
|
| 21 | + public function __construct(EntityManager $entityManager) { |
|
| 22 | 22 | $this->entityManager = $entityManager; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function trackApplication( int $applicationId, string $trackingString ) { |
|
| 26 | - $application = $this->getApplicationById( $applicationId ); |
|
| 25 | + public function trackApplication(int $applicationId, string $trackingString) { |
|
| 26 | + $application = $this->getApplicationById($applicationId); |
|
| 27 | 27 | |
| 28 | - $application->setTracking( $trackingString ); |
|
| 28 | + $application->setTracking($trackingString); |
|
| 29 | 29 | |
| 30 | - $this->persistApplication( $application ); |
|
| 30 | + $this->persistApplication($application); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - private function getApplicationById( int $applicationId ): MembershipApplication { |
|
| 33 | + private function getApplicationById(int $applicationId): MembershipApplication { |
|
| 34 | 34 | try { |
| 35 | - $application = $this->entityManager->find( MembershipApplication::class, $applicationId ); |
|
| 35 | + $application = $this->entityManager->find(MembershipApplication::class, $applicationId); |
|
| 36 | 36 | } |
| 37 | - catch ( ORMException $ex ) { |
|
| 37 | + catch (ORMException $ex) { |
|
| 38 | 38 | // TODO: might want to log failure here |
| 39 | - throw new ApplicationPiwikTrackingException( 'Membership application could not be accessed' ); |
|
| 39 | + throw new ApplicationPiwikTrackingException('Membership application could not be accessed'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if ( $application === null ) { |
|
| 43 | - throw new ApplicationPiwikTrackingException( 'Membership application does not exist' ); |
|
| 42 | + if ($application === null) { |
|
| 43 | + throw new ApplicationPiwikTrackingException('Membership application does not exist'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $application; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - private function persistApplication( MembershipApplication $application ) { |
|
| 49 | + private function persistApplication(MembershipApplication $application) { |
|
| 50 | 50 | try { |
| 51 | - $this->entityManager->persist( $application ); |
|
| 51 | + $this->entityManager->persist($application); |
|
| 52 | 52 | $this->entityManager->flush(); |
| 53 | 53 | } |
| 54 | - catch ( ORMException $ex ) { |
|
| 55 | - throw new ApplicationPiwikTrackingException( 'Failed to persist membership application' ); |
|
| 54 | + catch (ORMException $ex) { |
|
| 55 | + throw new ApplicationPiwikTrackingException('Failed to persist membership application'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\DataAccess; |
| 6 | 6 | |
@@ -19,44 +19,44 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private $entityManager; |
| 21 | 21 | |
| 22 | - public function __construct( EntityManager $entityManager ) { |
|
| 22 | + public function __construct(EntityManager $entityManager) { |
|
| 23 | 23 | $this->entityManager = $entityManager; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function trackApplication( int $applicationId, MembershipApplicationTrackingInfo $trackingInfo ) { |
|
| 27 | - $application = $this->getApplicationById( $applicationId ); |
|
| 26 | + public function trackApplication(int $applicationId, MembershipApplicationTrackingInfo $trackingInfo) { |
|
| 27 | + $application = $this->getApplicationById($applicationId); |
|
| 28 | 28 | |
| 29 | 29 | $data = $application->getDecodedData(); |
| 30 | 30 | $data['confirmationPageCampaign'] = $trackingInfo->getCampaignCode(); |
| 31 | 31 | $data['confirmationPage'] = $trackingInfo->getKeyword(); |
| 32 | - $application->encodeAndSetData( $data ); |
|
| 32 | + $application->encodeAndSetData($data); |
|
| 33 | 33 | |
| 34 | - $this->persistApplication( $application ); |
|
| 34 | + $this->persistApplication($application); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - private function getApplicationById( int $applicationId ): MembershipApplication { |
|
| 37 | + private function getApplicationById(int $applicationId): MembershipApplication { |
|
| 38 | 38 | try { |
| 39 | - $application = $this->entityManager->find( MembershipApplication::class, $applicationId ); |
|
| 39 | + $application = $this->entityManager->find(MembershipApplication::class, $applicationId); |
|
| 40 | 40 | } |
| 41 | - catch ( ORMException $ex ) { |
|
| 41 | + catch (ORMException $ex) { |
|
| 42 | 42 | // TODO: might want to log failure here |
| 43 | - throw new ApplicationTrackingException( 'Membership application could not be accessed' ); |
|
| 43 | + throw new ApplicationTrackingException('Membership application could not be accessed'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ( $application === null ) { |
|
| 47 | - throw new ApplicationTrackingException( 'Membership application does not exist' ); |
|
| 46 | + if ($application === null) { |
|
| 47 | + throw new ApplicationTrackingException('Membership application does not exist'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $application; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - private function persistApplication( MembershipApplication $application ) { |
|
| 53 | + private function persistApplication(MembershipApplication $application) { |
|
| 54 | 54 | try { |
| 55 | - $this->entityManager->persist( $application ); |
|
| 55 | + $this->entityManager->persist($application); |
|
| 56 | 56 | $this->entityManager->flush(); |
| 57 | 57 | } |
| 58 | - catch ( ORMException $ex ) { |
|
| 59 | - throw new ApplicationTrackingException( 'Failed to persist membership application' ); |
|
| 58 | + catch (ORMException $ex) { |
|
| 59 | + throw new ApplicationTrackingException('Failed to persist membership application'); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipApplicationContext\UseCases\ApplyForMembership; |
| 6 | 6 | |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | private $validator; |
| 26 | 26 | private $piwikTracker; |
| 27 | 27 | |
| 28 | - public function __construct( ApplicationRepository $repository, |
|
| 28 | + public function __construct(ApplicationRepository $repository, |
|
| 29 | 29 | ApplicationTokenFetcher $tokenFetcher, TemplateBasedMailer $mailer, |
| 30 | 30 | MembershipApplicationValidator $validator, ApplicationTracker $tracker, |
| 31 | - ApplicationPiwikTracker $piwikTracker ) { |
|
| 31 | + ApplicationPiwikTracker $piwikTracker) { |
|
| 32 | 32 | |
| 33 | 33 | $this->repository = $repository; |
| 34 | 34 | $this->tokenFetcher = $tokenFetcher; |
@@ -38,33 +38,33 @@ discard block |
||
| 38 | 38 | $this->piwikTracker = $piwikTracker; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function applyForMembership( ApplyForMembershipRequest $request ): ApplyForMembershipResponse { |
|
| 42 | - $validationResult = $this->validator->validate( $request ); |
|
| 43 | - if ( !$validationResult->isSuccessful() ) { |
|
| 41 | + public function applyForMembership(ApplyForMembershipRequest $request): ApplyForMembershipResponse { |
|
| 42 | + $validationResult = $this->validator->validate($request); |
|
| 43 | + if (!$validationResult->isSuccessful()) { |
|
| 44 | 44 | // TODO: return failures (note that we have infrastructure failures that are not ConstraintViolations) |
| 45 | - return ApplyForMembershipResponse::newFailureResponse( $validationResult ); |
|
| 45 | + return ApplyForMembershipResponse::newFailureResponse($validationResult); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $application = $this->newApplicationFromRequest( $request ); |
|
| 48 | + $application = $this->newApplicationFromRequest($request); |
|
| 49 | 49 | |
| 50 | - if ( $this->applicationNeedsModeration( $application ) ) { |
|
| 50 | + if ($this->applicationNeedsModeration($application)) { |
|
| 51 | 51 | $application->markForModeration(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // TODO: handle exceptions |
| 55 | - $this->repository->storeApplication( $application ); |
|
| 55 | + $this->repository->storeApplication($application); |
|
| 56 | 56 | |
| 57 | 57 | // TODO: handle exceptions |
| 58 | - $this->membershipApplicationTracker->trackApplication( $application->getId(), $request->getTrackingInfo() ); |
|
| 58 | + $this->membershipApplicationTracker->trackApplication($application->getId(), $request->getTrackingInfo()); |
|
| 59 | 59 | |
| 60 | 60 | // TODO: handle exceptions |
| 61 | - $this->piwikTracker->trackApplication( $application->getId(), $request->getPiwikTrackingString() ); |
|
| 61 | + $this->piwikTracker->trackApplication($application->getId(), $request->getPiwikTrackingString()); |
|
| 62 | 62 | |
| 63 | 63 | // TODO: handle exceptions |
| 64 | - $this->sendConfirmationEmail( $application ); |
|
| 64 | + $this->sendConfirmationEmail($application); |
|
| 65 | 65 | |
| 66 | 66 | // TODO: handle exceptions |
| 67 | - $tokens = $this->tokenFetcher->getTokens( $application->getId() ); |
|
| 67 | + $tokens = $this->tokenFetcher->getTokens($application->getId()); |
|
| 68 | 68 | |
| 69 | 69 | return ApplyForMembershipResponse::newSuccessResponse( |
| 70 | 70 | $tokens->getAccessToken(), |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - private function newApplicationFromRequest( ApplyForMembershipRequest $request ): Application { |
|
| 77 | - return ( new MembershipApplicationBuilder() )->newApplicationFromRequest( $request ); |
|
| 76 | + private function newApplicationFromRequest(ApplyForMembershipRequest $request): Application { |
|
| 77 | + return (new MembershipApplicationBuilder())->newApplicationFromRequest($request); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - private function sendConfirmationEmail( Application $application ) { |
|
| 80 | + private function sendConfirmationEmail(Application $application) { |
|
| 81 | 81 | $this->mailer->sendMail( |
| 82 | 82 | $application->getApplicant()->getEmailAddress(), |
| 83 | 83 | [ |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | ); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - private function applicationNeedsModeration( Application $application ): bool { |
|
| 94 | + private function applicationNeedsModeration(Application $application): bool { |
|
| 95 | 95 | return |
| 96 | 96 | $application->getPayment()->getYearlyAmount()->getEuroFloat() |
| 97 | 97 | > self::YEARLY_PAYMENT_MODERATION_THRESHOLD_IN_EURO; |