Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 17 |
PageHit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
110 | |
0.00% |
0 / 17 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
getDateTime | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
isNewVisitor | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getRequestUri | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getCountry | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getBrowserBrand | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getBrowserVersion | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getPlatform | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
getDeviceType | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
__set_state | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
1 | <?php |
2 | |
3 | namespace Miniframe\Statistics\Model; |
4 | |
5 | class PageHit |
6 | { |
7 | /** |
8 | * Date/time of the hit |
9 | * |
10 | * @var \DateTime |
11 | */ |
12 | protected $dateTime; |
13 | /** |
14 | * True when this is the 1st page hit for this user |
15 | * |
16 | * @var bool |
17 | */ |
18 | protected $newVisitor; |
19 | /** |
20 | * Requested URL |
21 | * |
22 | * @var string |
23 | */ |
24 | protected $requestUri; |
25 | /** |
26 | * Country code |
27 | * |
28 | * @var string|null |
29 | */ |
30 | protected $country; |
31 | /** |
32 | * Browser brand |
33 | * |
34 | * @var string|null |
35 | */ |
36 | protected $browserBrand; |
37 | /** |
38 | * Browser version |
39 | * |
40 | * @var string|null |
41 | */ |
42 | protected $browserVersion; |
43 | /** |
44 | * Platform |
45 | * |
46 | * @var string|null |
47 | */ |
48 | protected $platform; |
49 | /** |
50 | * Device type |
51 | * |
52 | * @var string|null |
53 | */ |
54 | protected $deviceType; |
55 | |
56 | /** |
57 | * Creates a new PageHit data model |
58 | * |
59 | * @param \DateTime $dateTime Date/time of the hit. |
60 | * @param boolean $newVisitor True when this is the 1st page hit for this user. |
61 | * @param string $requestUri Requested URL. |
62 | * @param string|null $country Country code. |
63 | * @param string|null $browserBrand Browser brand. |
64 | * @param string|null $browserVersion Browser version. |
65 | * @param string|null $platform Platform. |
66 | * @param string|null $deviceType Device type. |
67 | */ |
68 | public function __construct( |
69 | \DateTime $dateTime, |
70 | bool $newVisitor, |
71 | string $requestUri, |
72 | ?string $country, |
73 | ?string $browserBrand, |
74 | ?string $browserVersion, |
75 | ?string $platform, |
76 | ?string $deviceType |
77 | ) { |
78 | $this->dateTime = $dateTime; |
79 | $this->newVisitor = $newVisitor; |
80 | $this->requestUri = $requestUri; |
81 | $this->country = $country; |
82 | $this->browserBrand = $browserBrand; |
83 | $this->browserVersion = $browserVersion; |
84 | $this->platform = $platform; |
85 | $this->deviceType = $deviceType; |
86 | } |
87 | |
88 | /** |
89 | * Returns the Date/time of the hit |
90 | * |
91 | * @return \DateTime |
92 | */ |
93 | public function getDateTime(): \DateTime |
94 | { |
95 | return $this->dateTime; |
96 | } |
97 | |
98 | /** |
99 | * Returns true when this is the 1st page hit for this user |
100 | * |
101 | * @return boolean |
102 | */ |
103 | public function isNewVisitor(): bool |
104 | { |
105 | return $this->newVisitor; |
106 | } |
107 | |
108 | /** |
109 | * Returns the Requested URL |
110 | * |
111 | * @return string |
112 | */ |
113 | public function getRequestUri(): string |
114 | { |
115 | return $this->requestUri; |
116 | } |
117 | |
118 | /** |
119 | * Returns the Country code |
120 | * |
121 | * @return string|null |
122 | */ |
123 | public function getCountry(): ?string |
124 | { |
125 | return $this->country; |
126 | } |
127 | |
128 | /** |
129 | * Returns the Browser brand |
130 | * |
131 | * @return string|null |
132 | */ |
133 | public function getBrowserBrand(): ?string |
134 | { |
135 | return $this->browserBrand; |
136 | } |
137 | |
138 | /** |
139 | * Returns the Browser version |
140 | * |
141 | * @return string|null |
142 | */ |
143 | public function getBrowserVersion(): ?string |
144 | { |
145 | return $this->browserVersion; |
146 | } |
147 | |
148 | /** |
149 | * Returns the Platform |
150 | * |
151 | * @return string|null |
152 | */ |
153 | public function getPlatform(): ?string |
154 | { |
155 | return $this->platform; |
156 | } |
157 | |
158 | /** |
159 | * Returns the Device type |
160 | * |
161 | * @return string|null |
162 | */ |
163 | public function getDeviceType(): ?string |
164 | { |
165 | return $this->deviceType; |
166 | } |
167 | |
168 | /** |
169 | * Returns a pagehit object with a specific state (makes this object serializable with var_export) |
170 | * |
171 | * @param array $properties The list of properties. |
172 | * |
173 | * @return PageHit |
174 | */ |
175 | public static function __set_state(array $properties): self |
176 | { |
177 | return new self( |
178 | $properties['dateTime'], |
179 | $properties['newVisitor'], |
180 | $properties['requestUri'], |
181 | $properties['country'], |
182 | $properties['browserBrand'], |
183 | $properties['browserVersion'], |
184 | $properties['platform'], |
185 | $properties['deviceType'] |
186 | ); |
187 | } |
188 | } |