Test Setup Failed
Pull Request — master (#41)
by
unknown
62:50
created

Visitor   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 17
dl 0
loc 53
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getBucketIdentifier() 0 2 1
A __construct() 0 11 1
A getMinDisplayWidth() 0 2 1
A getTotalImpressionCount() 0 2 1
A getCategories() 0 2 1
A inCategory() 0 2 1
A getMaxDisplayWidth() 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 $minDisplayWidth;
16
	private ?int $maxDisplayWidth;
17
18
	/**
19
	 * @param int $totalImpressionCount How many banners the visitor has seen overall
20
	 * @param string|null $bucketIdentifier Last bucket identifier of the visitor (to put recurring visitors in the same buckets, but only per-campaign)
21
	 * @param int|null $minDisplayWidth Minimum window size to display the banner in.
22
	 * @param int|null $maxDisplayWidth Maximum window size to display the banner in.
23
	 * @param string ...$activeCategories
24
	 */
25
	public function __construct(
26
			int $totalImpressionCount,
27
			?string $bucketIdentifier,
28
			?int $minDisplayWidth,
29
			?int $maxDisplayWidth,
30
			string ...$activeCategories ) {
31
		$this->totalImpressionCount = $totalImpressionCount;
32
		$this->bucketIdentifier = $bucketIdentifier;
33
		$this->minDisplayWidth = $minDisplayWidth;
34
		$this->maxDisplayWidth = $maxDisplayWidth;
35
		$this->activeCategories = $activeCategories;
36
	}
37
38
	public function getTotalImpressionCount(): int {
39
		return $this->totalImpressionCount;
40
	}
41
42
	public function getBucketIdentifier(): ?string {
43
		return $this->bucketIdentifier;
44
	}
45
46
	public function inCategory( string $categoryName ): bool {
47
		return in_array( $categoryName, $this->activeCategories, true );
48
	}
49
50
	public function getMinDisplayWidth(): ?int {
51
		return $this->minDisplayWidth;
52
	}
53
54
	public function getMaxDisplayWidth(): ?int {
55
		return $this->maxDisplayWidth;
56
	}
57
58
	/**
59
	 * @return string[]
60
	 */
61
	public function getCategories(): array {
62
		return $this->activeCategories;
63
	}
64
}