Passed
Push — master ( 46c6e0...3e0e18 )
by Gabriel
01:52 queued 11s
created

ShowUpdateAddressController::showForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 11
ccs 9
cts 9
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\App\Controllers;
6
7
use Symfony\Component\HttpFoundation\Response;
8
use WMDE\Fundraising\Frontend\App\AccessDeniedException;
9
use WMDE\Fundraising\Frontend\Factories\FunFunFactory;
10
11
/**
12
 * @license GNU GPL v2+
13
 */
14
class ShowUpdateAddressController {
15
16
	public const ADDRESS_CHANGE_SESSION_KEY = 'address_changed';
17
18 2
	public function showForm( string $addressToken, FunFunFactory $ffFactory ): Response {
19 2
		$addressChangeRepository = $ffFactory->getAddressChangeRepository();
20 2
		$addressChange = $addressChangeRepository->getAddressChangeByUuid( $addressToken );
21 2
		if ( $addressChange === null ) {
22 1
			throw new AccessDeniedException();
23
		}
24 1
		return new Response(
25 1
			$ffFactory->getLayoutTemplate( 'Update_Address.html.twig' )->render(
26
				[
27 1
					'addressToken' => $addressToken,
28 1
					'isCompany' => $addressChange->isCompanyAddress()
29
				]
30
			)
31
		);
32
	}
33
}