Completed
Pull Request — master (#19)
by Tim
03:07
created

BannerSelection::createEmptySelection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\BannerServer\UseCase\BannerSelection;
6
7
/**
8
 * @license GNU GPL v2+
9
 */
10
class BannerSelection {
11
12
	private $bannerIdentifier;
13
	private $visitorData;
14
	private $campaignEnd;
15
16 2
	public static function createBannerSelection( string $bannerIdentifier, Visitor $visitorData, \DateTime $campaignEnd ): self {
17 2
		return new self( $bannerIdentifier, $visitorData, $campaignEnd );
18
	}
19
20 1
	public static function createEmptySelection( Visitor $visitor ): self {
21 1
		return new self( null, $visitor, new \DateTime() );
22
	}
23
24 3
	private function __construct( ?string $bannerIdentifier, Visitor $visitorData, \DateTime $campaignEnd ) {
25 3
		$this->bannerIdentifier = $bannerIdentifier;
26 3
		$this->visitorData = $visitorData;
27 3
		$this->campaignEnd = $campaignEnd;
28 3
	}
29
30 3
	public function displayBanner(): bool {
31 3
		return $this->bannerIdentifier !== null;
32
	}
33
34 2
	public function getBannerIdentifier(): string {
35 2
		assert( is_string( $this->bannerIdentifier ) );
36 2
		return $this->bannerIdentifier;
37
	}
38
39 2
	public function getVisitorData(): Visitor {
40 2
		return $this->visitorData;
41
	}
42
43 2
	public function getCampaignEnd(): \DateTime {
44 2
		return $this->campaignEnd;
45
	}
46
}