1 | <?php namespace Arcanedev\LaravelTracker; |
||
14 | class Tracker implements TrackerContract |
||
15 | { |
||
16 | /* ------------------------------------------------------------------------------------------------ |
||
17 | | Properties |
||
18 | | ------------------------------------------------------------------------------------------------ |
||
19 | */ |
||
20 | /** |
||
21 | * The application container. |
||
22 | * |
||
23 | * @var \Illuminate\Contracts\Foundation\Application |
||
24 | */ |
||
25 | protected $app; |
||
26 | |||
27 | /** |
||
28 | * The request instance. |
||
29 | * |
||
30 | * @var \Illuminate\Http\Request |
||
31 | */ |
||
32 | private $request; |
||
33 | |||
34 | /** |
||
35 | * The tracking manager. |
||
36 | * |
||
37 | * @var \Arcanedev\LaravelTracker\TrackingManager |
||
38 | */ |
||
39 | private $trackingManager; |
||
40 | |||
41 | /** |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $enabled = false; |
||
45 | |||
46 | /** |
||
47 | * The current session data. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $sessionData = []; |
||
52 | |||
53 | /* ------------------------------------------------------------------------------------------------ |
||
54 | | Constructor |
||
55 | | ------------------------------------------------------------------------------------------------ |
||
56 | */ |
||
57 | /** |
||
58 | * Tracker constructor. |
||
59 | * |
||
60 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
61 | */ |
||
62 | 24 | public function __construct(Application $app) |
|
68 | |||
69 | /* ------------------------------------------------------------------------------------------------ |
||
70 | | Getters & Setters |
||
71 | | ------------------------------------------------------------------------------------------------ |
||
72 | */ |
||
73 | /** |
||
74 | * Get the config repository. |
||
75 | * |
||
76 | * @return \Illuminate\Contracts\Config\Repository |
||
77 | */ |
||
78 | 24 | private function config() |
|
82 | |||
83 | /** |
||
84 | * Get the tracker config. |
||
85 | * |
||
86 | * @param string $key |
||
87 | * @param mixed|null $default |
||
88 | * |
||
89 | * @return mixed |
||
90 | */ |
||
91 | 24 | private function getConfig($key, $default = null) |
|
95 | |||
96 | /** |
||
97 | * Set the request. |
||
98 | * |
||
99 | * @param \Illuminate\Http\Request $request |
||
100 | * |
||
101 | * @return self |
||
102 | */ |
||
103 | 6 | private function setRequest(Request $request) |
|
109 | |||
110 | /** |
||
111 | * Get the user agent parser. |
||
112 | * |
||
113 | * @return \Arcanedev\LaravelTracker\Contracts\Parsers\UserAgentParser |
||
114 | */ |
||
115 | public function getUserAgentParser() |
||
119 | |||
120 | /* ------------------------------------------------------------------------------------------------ |
||
121 | | Main Functions |
||
122 | | ------------------------------------------------------------------------------------------------ |
||
123 | */ |
||
124 | /** |
||
125 | * Start the tracking. |
||
126 | * |
||
127 | * @param \Illuminate\Http\Request $request |
||
128 | */ |
||
129 | 6 | public function track(Request $request) |
|
137 | |||
138 | /** |
||
139 | * Enable the tracker. |
||
140 | */ |
||
141 | 6 | public function enable() |
|
146 | |||
147 | /** |
||
148 | * Disable the tracker. |
||
149 | */ |
||
150 | 6 | public function disable() |
|
155 | |||
156 | /* ------------------------------------------------------------------------------------------------ |
||
157 | | Check Functions |
||
158 | | ------------------------------------------------------------------------------------------------ |
||
159 | */ |
||
160 | /** |
||
161 | * Check if the tracker is enabled. |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | 24 | public function isEnabled() |
|
169 | |||
170 | /* ------------------------------------------------------------------------------------------------ |
||
171 | | Other Functions |
||
172 | | ------------------------------------------------------------------------------------------------ |
||
173 | */ |
||
174 | /** |
||
175 | * Get the session log data. |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | 6 | protected function getSessionActivityData() |
|
193 | |||
194 | /** |
||
195 | * Get the stored session id. |
||
196 | * |
||
197 | * @return int |
||
198 | */ |
||
199 | 6 | protected function getSessionId() |
|
205 | |||
206 | /** |
||
207 | * @return array |
||
208 | */ |
||
209 | 6 | protected function makeSessionData() |
|
227 | |||
228 | private function getPathId() |
||
232 | |||
233 | private function getQueryId() |
||
237 | |||
238 | /** |
||
239 | * Get the user id. |
||
240 | * |
||
241 | * @return int|null |
||
242 | */ |
||
243 | 6 | private function getUserId() |
|
249 | |||
250 | /** |
||
251 | * Get the tracked device id. |
||
252 | * |
||
253 | * @return int|null |
||
254 | */ |
||
255 | 6 | private function getDeviceId() |
|
261 | |||
262 | /** |
||
263 | * Get the tracked ip address ip. |
||
264 | * |
||
265 | * @return int|null |
||
266 | */ |
||
267 | private function getGeoIpId() |
||
273 | |||
274 | /** |
||
275 | * Get the tracked user agent id. |
||
276 | * |
||
277 | * @return int|null |
||
278 | */ |
||
279 | private function getAgentId() |
||
285 | |||
286 | /** |
||
287 | * Get the tracked referer id. |
||
288 | * |
||
289 | * @return int|null |
||
290 | */ |
||
291 | private function getRefererId() |
||
297 | |||
298 | /** |
||
299 | * Get the tracked cookie id. |
||
300 | * |
||
301 | * @return int|null |
||
302 | */ |
||
303 | private function getCookieId() |
||
309 | |||
310 | /** |
||
311 | * Get the tracked language id. |
||
312 | * |
||
313 | * @return int|null |
||
314 | */ |
||
315 | private function getLanguageId() |
||
321 | |||
322 | /** |
||
323 | * Check if the visitor is a robot. |
||
324 | * |
||
325 | * @return bool |
||
326 | */ |
||
327 | protected function isRobot() |
||
334 | } |
||
335 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.