Completed
Push — master ( 4b187e...d8fefd )
by Jeroen De
04:05
created

accessIsPermitted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Frontend\UseCases\ShowMembershipApplicationConfirmation;
6
7
use WMDE\Fundraising\Frontend\Domain\Model\MembershipApplication;
8
9
/**
10
 * @license GNU GPL v2+
11
 * @author Kai Nissen < [email protected] >
12
 */
13
class ShowMembershipAppConfirmationResponse {
14
15
	private $membershipApplication;
16
	private $updateToken;
17
18
	public static function newNotAllowedResponse(): self {
19
		return new self();
20
	}
21
22
	public static function newValidResponse( MembershipApplication $membershipApplication, string $updateToken ): self {
23
		return new self( $membershipApplication, $updateToken );
24
	}
25
26
	private function __construct( MembershipApplication $membershipApplication = null, string $updateToken = null ) {
27
		$this->membershipApplication = $membershipApplication;
28
		$this->updateToken = $updateToken;
29
	}
30
31
	/**
32
	 * Returns the MembershipApplication when @see accessIsPermitted returns true, or null otherwise.
33
	 *
34
	 * @return MembershipApplication|null
35
	 */
36
	public function getApplication() {
37
		return $this->membershipApplication;
38
	}
39
40
	public function getUpdateToken() {
41
		return $this->updateToken;
42
	}
43
44
	public function accessIsPermitted(): bool {
45
		return $this->membershipApplication !== null;
46
	}
47
48
}