Completed
Pull Request — master (#36)
by Gabriel
64:04
created

Visitor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 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 $totalImpressionCount = 0;
13
	private $bucketIdentifier;
14
	private $activeCategories;
15
16
	/**
17
	 * @param int $totalImpressionCount How many banners the visitor has seen overall
18
	 * @param string|null $bucketIdentifier Last bucket identifier of the visitor (to put recurring visitors in the same buckets, but only per-campaign)
19
	 * @param string ...$activeCategories Categories the user has interacted with (close button, donation, etc)
20
	 */
21
	public function __construct( int $totalImpressionCount, ?string $bucketIdentifier, string ...$activeCategories ) {
22
		$this->totalImpressionCount = $totalImpressionCount;
23
		$this->bucketIdentifier = $bucketIdentifier;
24
		$this->activeCategories = $activeCategories;
25
	}
26
27
	public function getTotalImpressionCount(): int {
28
		return $this->totalImpressionCount;
29
	}
30
31
	public function getBucketIdentifier(): ?string {
32
		return $this->bucketIdentifier;
33
	}
34
35
	public function inCategory( string $categoryName ): bool {
36
		return in_array( $categoryName, $this->activeCategories, true );
37
	}
38
39
	/**
40
	 * @return string[]
41
	 */
42
	public function getCategories(): array {
43
		return $this->activeCategories;
44
	}
45
}