Test Setup Failed
Pull Request — master (#41)
by
unknown
63:55
created

Visitor::getDisplayWidth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\BannerServer\Entity;
6
7
/**
8
 * @license GNU GPL v2+
9
 */
10
class Visitor {
11
12
	private int $totalImpressionCount = 0;
13
	private ?string $bucketIdentifier;
14
	private array $activeCategories;
15
	private int $displayWidth;
16
17
	/**
18
	 * @param int $totalImpressionCount How many banners the visitor has seen overall
19
	 * @param string|null $bucketIdentifier Last bucket identifier of the visitor (to put recurring visitors in the same buckets, but only per-campaign)
20
	 * @param int|null $minDisplayWidth Minimum window size to display the banner in.
21
	 * @param int|null $maxDisplayWidth Maximum window size to display the banner in.
22
	 * @param string ...$activeCategories
23
	 */
24
	public function __construct(
25
			int $totalImpressionCount,
26
			?string $bucketIdentifier,
27
			int $displayWidth,
28
			string ...$activeCategories ) {
29
		$this->totalImpressionCount = $totalImpressionCount;
30
		$this->bucketIdentifier = $bucketIdentifier;
31
		$this->displayWidth = $displayWidth;
32
		$this->activeCategories = $activeCategories;
33
	}
34
35
	public function getTotalImpressionCount(): int {
36
		return $this->totalImpressionCount;
37
	}
38
39
	public function getBucketIdentifier(): ?string {
40
		return $this->bucketIdentifier;
41
	}
42
43
	public function inCategory( string $categoryName ): bool {
44
		return in_array( $categoryName, $this->activeCategories, true );
45
	}
46
47
	public function getDisplayWidth(): ?int {
48
		return $this->displayWidth;
49
	}
50
51
	/**
52
	 * @return string[]
53
	 */
54
	public function getCategories(): array {
55
		return $this->activeCategories;
56
	}
57
}