Completed
Pull Request — master (#17)
by Gabriel
691:17 queued 688:20
created

BannerSelection   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 35
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getCampaignEnd() 0 2 1
A __construct() 0 4 1
A getVisitorData() 0 2 1
A displayBanner() 0 2 1
A createEmptySelection() 0 2 1
A createBannerSelection() 0 2 1
A getBannerIdentifier() 0 3 1
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
	public static function createBannerSelection( string $bannerIdentifier, Visitor $visitorData, \DateTime $campaignEnd ): self {
17
		return new self( $bannerIdentifier, $visitorData, $campaignEnd );
18
	}
19
20
	public static function createEmptySelection( Visitor $visitor ): self {
21
		return new self( null, $visitor, new \DateTime() );
22
	}
23
24
	private function __construct( ?string $bannerIdentifier, Visitor $visitorData, \DateTime $campaignEnd ) {
25
		$this->bannerIdentifier = $bannerIdentifier;
26
		$this->visitorData = $visitorData;
27
		$this->campaignEnd = $campaignEnd;
28
	}
29
30
	public function displayBanner(): bool {
31
		return $this->bannerIdentifier !== null;
32
	}
33
34
	public function getBannerIdentifier(): string {
35
		assert( is_string( $this->bannerIdentifier ) );
36
		return $this->bannerIdentifier;
37
	}
38
39
	public function getVisitorData(): Visitor {
40
		return $this->visitorData;
41
	}
42
43
	public function getCampaignEnd(): \DateTime {
44
		return $this->campaignEnd;
45
	}
46
}