1 | <?php namespace Cornford\Googlitics; |
||
8 | abstract class AnalyticsBase implements AnalyticalBaseInterface |
||
9 | { |
||
10 | |||
11 | const TYPE_PAGEVIEW = 'pageview'; |
||
12 | const TYPE_APPVIEW = 'appview'; |
||
13 | const TYPE_SCREENVIEW = 'screenview'; |
||
14 | const TYPE_EVENT = 'event'; |
||
15 | const TYPE_TRANSACTION = 'transaction'; |
||
16 | const TYPE_ITEM = 'item'; |
||
17 | const TYPE_SOCIAL = 'social'; |
||
18 | const TYPE_EXCEPTION = 'exception'; |
||
19 | const TYPE_TIMING = 'timing'; |
||
20 | |||
21 | const ECOMMERCE_TRANSACTION = 'addTransaction'; |
||
22 | const ECOMMERCE_ITEM = 'addItem'; |
||
23 | |||
24 | /** |
||
25 | * App |
||
26 | * |
||
27 | * @var Application |
||
28 | */ |
||
29 | protected $application; |
||
30 | |||
31 | /** |
||
32 | * View |
||
33 | * |
||
34 | * @var View |
||
35 | */ |
||
36 | protected $view; |
||
37 | |||
38 | /** |
||
39 | * Tracking enabled |
||
40 | * |
||
41 | * @var boolean |
||
42 | */ |
||
43 | protected $enabled; |
||
44 | |||
45 | /** |
||
46 | * Google Analytics tracking id |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $id; |
||
51 | |||
52 | /** |
||
53 | * Domain |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $domain; |
||
58 | |||
59 | /** |
||
60 | * Anonymised tracking |
||
61 | * |
||
62 | * @var boolean |
||
63 | */ |
||
64 | protected $anonymised; |
||
65 | |||
66 | /** |
||
67 | * Automatically track |
||
68 | * |
||
69 | * @var boolean |
||
70 | */ |
||
71 | protected $automatic; |
||
72 | |||
73 | /** |
||
74 | * Tracking items |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | public $items = []; |
||
79 | |||
80 | /** |
||
81 | * Construct Googlitics |
||
82 | * |
||
83 | * @param Application $application |
||
84 | * @param View $view |
||
85 | * @param array $options |
||
86 | * |
||
87 | * @throws AnalyticsArgumentException |
||
88 | * |
||
89 | * @return self |
||
|
|||
90 | */ |
||
91 | public function __construct(Application $application, View $view, array $options = []) |
||
106 | |||
107 | /** |
||
108 | * Set enabled status |
||
109 | * |
||
110 | * @param boolean $value |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | protected function setEnabled($value) |
||
118 | |||
119 | /** |
||
120 | * Get the enabled status |
||
121 | * |
||
122 | * @return boolean |
||
123 | */ |
||
124 | protected function getEnabled() |
||
128 | |||
129 | /** |
||
130 | * Set the Google Analytics id |
||
131 | * |
||
132 | * @param string $value |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | protected function setId($value) |
||
140 | |||
141 | /** |
||
142 | * Get the Google Analytics id |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | protected function getId() |
||
150 | |||
151 | /** |
||
152 | * Set the tracking domain |
||
153 | * |
||
154 | * @param string $value |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | protected function setDomain($value) |
||
162 | |||
163 | /** |
||
164 | * Get the tracking domain |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | protected function getDomain() |
||
172 | |||
173 | /** |
||
174 | * Set anonymised tracking |
||
175 | * |
||
176 | * @param boolean $value |
||
177 | * |
||
178 | * @return void |
||
179 | */ |
||
180 | protected function setAnonymised($value) |
||
184 | |||
185 | /** |
||
186 | * Get anonymised tracking |
||
187 | * |
||
188 | * @return boolean |
||
189 | */ |
||
190 | protected function getAnonymised() |
||
194 | |||
195 | /** |
||
196 | * Set automatic tracking |
||
197 | * |
||
198 | * @param boolean $value |
||
199 | * |
||
200 | * @return void |
||
201 | */ |
||
202 | protected function setAutomatic($value) |
||
206 | |||
207 | /** |
||
208 | * Get automatic tracking |
||
209 | * |
||
210 | * @return boolean |
||
211 | */ |
||
212 | protected function getAutomatic() |
||
216 | |||
217 | /** |
||
218 | * Add tracking item |
||
219 | * |
||
220 | * @param string $value |
||
221 | * |
||
222 | * @return void |
||
223 | */ |
||
224 | protected function addItem($value) |
||
228 | |||
229 | /** |
||
230 | * Set tracking items |
||
231 | * |
||
232 | * @param array $array |
||
233 | * |
||
234 | * @return void |
||
235 | */ |
||
236 | protected function setItems(array $array) |
||
240 | |||
241 | /** |
||
242 | * Get the tracking items |
||
243 | * |
||
244 | * @return array |
||
245 | */ |
||
246 | public function getItems() |
||
250 | |||
251 | /** |
||
252 | * Is tracking enabled? |
||
253 | * |
||
254 | * @return boolean |
||
255 | */ |
||
256 | public function isEnabled() |
||
260 | |||
261 | /** |
||
262 | * Enable tracking. |
||
263 | * |
||
264 | * @return void |
||
265 | */ |
||
266 | public function enableTracking() |
||
270 | |||
271 | /** |
||
272 | * Disable tracking. |
||
273 | * |
||
274 | * @return void |
||
275 | */ |
||
276 | public function disableTracking() |
||
280 | |||
281 | /** |
||
282 | * Is anonymised tracking enabled? |
||
283 | * |
||
284 | * @return boolean |
||
285 | */ |
||
286 | public function isAnonymised() { |
||
289 | |||
290 | /** |
||
291 | * Enable anonymised tracking. |
||
292 | * |
||
293 | * @return void |
||
294 | */ |
||
295 | public function enableAnonymisedTracking() |
||
299 | |||
300 | /** |
||
301 | * Disable anonymised tracking. |
||
302 | * |
||
303 | * @return void |
||
304 | */ |
||
305 | public function disableAnonymisedTracking() |
||
309 | |||
310 | /** |
||
311 | * Is automatic tracking enabled? |
||
312 | * |
||
313 | * @return boolean |
||
314 | */ |
||
315 | public function isAutomatic() |
||
319 | |||
320 | /** |
||
321 | * Enable automatic tracking. |
||
322 | * |
||
323 | * @return void |
||
324 | */ |
||
325 | public function enableAutomaticTracking() |
||
329 | |||
330 | /** |
||
331 | * Disable automatic tracking. |
||
332 | * |
||
333 | * @return void |
||
334 | */ |
||
335 | public function disableAutomaticTracking() |
||
339 | |||
340 | /** |
||
341 | * Track an ecommerce item. |
||
342 | * |
||
343 | * @param string $type |
||
344 | * @param array $options |
||
345 | * |
||
346 | * @return void |
||
347 | */ |
||
348 | protected function trackEcommerce($type = self::ECOMMERCE_TRANSACTION, array $options = []) |
||
354 | |||
355 | } |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.