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

Visitor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 46
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getBucketIdentifier() 0 2 1
A __construct() 0 9 1
A getTotalImpressionCount() 0 2 1
A getCategories() 0 2 1
A inCategory() 0 2 1
A getDisplayWidth() 0 2 1
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
}