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

ShowUpdateAddressController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A showForm() 0 11 2
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
}