Passed
Push — develop ( 75a5f6...3a86a8 )
by Andrew
03:26 queued 11s
created
src/twigextensions/InstantAnalyticsTwigExtension.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function getGlobals()
47 47
     {
48
-        $globals = [];
48
+        $globals = [ ];
49 49
         $view = Craft::$app->getView();
50 50
         if ($view->getIsRenderingPageTemplate()) {
51 51
             $request = Craft::$app->getRequest();
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
     public function getFilters()
67 67
     {
68 68
         return [
69
-            new \Twig_SimpleFilter('pageViewAnalytics', [$this, 'pageViewAnalytics']),
70
-            new \Twig_SimpleFilter('eventAnalytics', [$this, 'eventAnalytics']),
71
-            new \Twig_SimpleFilter('pageViewTrackingUrl', [$this, 'pageViewTrackingUrl']),
72
-            new \Twig_SimpleFilter('eventTrackingUrl', [$this, 'eventTrackingUrl']),
69
+            new \Twig_SimpleFilter('pageViewAnalytics', [ $this, 'pageViewAnalytics' ]),
70
+            new \Twig_SimpleFilter('eventAnalytics', [ $this, 'eventAnalytics' ]),
71
+            new \Twig_SimpleFilter('pageViewTrackingUrl', [ $this, 'pageViewTrackingUrl' ]),
72
+            new \Twig_SimpleFilter('eventTrackingUrl', [ $this, 'eventTrackingUrl' ]),
73 73
         ];
74 74
     }
75 75
 
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
     public function getFunctions()
80 80
     {
81 81
         return [
82
-            new \Twig_SimpleFunction('pageViewAnalytics', [$this, 'pageViewAnalytics']),
83
-            new \Twig_SimpleFunction('eventAnalytics', [$this, 'eventAnalytics']),
84
-            new \Twig_SimpleFunction('pageViewTrackingUrl', [$this, 'pageViewTrackingUrl']),
85
-            new \Twig_SimpleFunction('eventTrackingUrl', [$this, 'eventTrackingUrl']),
82
+            new \Twig_SimpleFunction('pageViewAnalytics', [ $this, 'pageViewAnalytics' ]),
83
+            new \Twig_SimpleFunction('eventAnalytics', [ $this, 'eventAnalytics' ]),
84
+            new \Twig_SimpleFunction('pageViewTrackingUrl', [ $this, 'pageViewTrackingUrl' ]),
85
+            new \Twig_SimpleFunction('eventTrackingUrl', [ $this, 'eventTrackingUrl' ]),
86 86
         ];
87 87
     }
88 88
 
Please login to merge, or discard this patch.
src/helpers/IAnalytics.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @inheritdoc
29 29
      */
30
-    public function __construct($isSsl = false, $isDisabled = false, array $options = [])
30
+    public function __construct($isSsl = false, $isDisabled = false, array $options = [ ])
31 31
     {
32 32
         /** @var Settings $settings */
33 33
         $settings = InstantAnalytics::$plugin->getSettings();
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
     {
141 141
         /** @var Settings $settings */
142 142
         $settings = InstantAnalytics::$plugin->getSettings();
143
-        $requestIp = $_SERVER['REMOTE_ADDR'];
143
+        $requestIp = $_SERVER[ 'REMOTE_ADDR' ];
144 144
         if ($this->shouldSendAnalytics) {
145 145
             try {
146 146
                 Craft::info(
147
-                    "Send hit for IAnalytics object: ".print_r($this, true),
147
+                    "Send hit for IAnalytics object: " . print_r($this, true),
148 148
                     __METHOD__
149 149
                 );
150 150
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             } catch (\Exception $e) {
153 153
                 if ($settings->logExcludedAnalytics) {
154 154
                     Craft::info(
155
-                        "*** sendHit(): error sending analytics: ".$e->getMessage(),
155
+                        "*** sendHit(): error sending analytics: " . $e->getMessage(),
156 156
                         __METHOD__
157 157
                     );
158 158
                 }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         } else {
161 161
             if ($settings->logExcludedAnalytics) {
162 162
                 Craft::info(
163
-                    "*** sendHit(): analytics not sent for ".$requestIp,
163
+                    "*** sendHit(): analytics not sent for " . $requestIp,
164 164
                     __METHOD__
165 165
                 );
166 166
             }
Please login to merge, or discard this patch.
src/services/IA.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                 ->setDocumentTitle($title);
82 82
             $result = $analytics;
83 83
             Craft::info(
84
-                "Created sendPageView for `".$url."` - `".$title."`",
84
+                "Created sendPageView for `" . $url . "` - `" . $title . "`",
85 85
                 __METHOD__
86 86
             );
87 87
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 ->setEventValue(intval($eventValue));
113 113
             $result = $analytics;
114 114
             Craft::info(
115
-                "Created sendEvent for `".$eventCategory."` - `".$eventAction."` - `".$eventLabel."` - `".$eventValue."`",
115
+                "Created sendEvent for `" . $eventCategory . "` - `" . $eventAction . "` - `" . $eventLabel . "` - `" . $eventValue . "`",
116 116
                 __METHOD__
117 117
             );
118 118
         }
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
         $path = parse_url($url, PHP_URL_PATH);
155 155
         $pathFragments = explode('/', rtrim($path, '/'));
156 156
         $fileName = end($pathFragments);
157
-        $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/'.$fileName, $urlParams);
157
+        $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/' . $fileName, $urlParams);
158 158
         Craft::info(
159
-            "Created pageViewTrackingUrl for ".$trackingUrl,
159
+            "Created pageViewTrackingUrl for " . $trackingUrl,
160 160
             __METHOD__
161 161
         );
162 162
 
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
             'eventValue'    => $eventValue,
186 186
         ];
187 187
         $fileName = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME);
188
-        $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/'.$fileName, $urlParams);
188
+        $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/' . $fileName, $urlParams);
189 189
         Craft::info(
190
-            "Created eventTrackingUrl for ".$trackingUrl,
190
+            "Created eventTrackingUrl for " . $trackingUrl,
191 191
             __METHOD__
192 192
         );
193 193
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         if (!$settings->sendAnalyticsData) {
213 213
             if ($settings->logExcludedAnalytics) {
214 214
                 Craft::info(
215
-                    "Analytics excluded for: ".$requestIp." due to: `sendAnalyticsData`",
215
+                    "Analytics excluded for: " . $requestIp . " due to: `sendAnalyticsData`",
216 216
                     __METHOD__
217 217
                 );
218 218
             }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         if (!$settings->sendAnalyticsInDevMode && Craft::$app->getConfig()->getGeneral()->devMode) {
224 224
             if ($settings->logExcludedAnalytics) {
225 225
                 Craft::info(
226
-                    "Analytics excluded for: ".$requestIp." due to: `sendAnalyticsInDevMode`",
226
+                    "Analytics excluded for: " . $requestIp . " due to: `sendAnalyticsInDevMode`",
227 227
                     __METHOD__
228 228
                 );
229 229
             }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         if ($request->getIsConsoleRequest()) {
235 235
             if ($settings->logExcludedAnalytics) {
236 236
                 Craft::info(
237
-                    "Analytics excluded for: ".$requestIp." due to: `craft()->isConsole()`",
237
+                    "Analytics excluded for: " . $requestIp . " due to: `craft()->isConsole()`",
238 238
                     __METHOD__
239 239
                 );
240 240
             }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         if ($request->getIsCpRequest()) {
246 246
             if ($settings->logExcludedAnalytics) {
247 247
                 Craft::info(
248
-                    "Analytics excluded for: ".$requestIp." due to: `craft()->request->isCpRequest()`",
248
+                    "Analytics excluded for: " . $requestIp . " due to: `craft()->request->isCpRequest()`",
249 249
                     __METHOD__
250 250
                 );
251 251
             }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if ($request->getIsLivePreview()) {
257 257
             if ($settings->logExcludedAnalytics) {
258 258
                 Craft::info(
259
-                    "Analytics excluded for: ".$requestIp." due to: `craft()->request->isLivePreview()`",
259
+                    "Analytics excluded for: " . $requestIp . " due to: `craft()->request->isLivePreview()`",
260 260
                     __METHOD__
261 261
                 );
262 262
             }
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
         // Check the $_SERVER[] super-global exclusions
268 268
         if (isset($settings->serverExcludes) && is_array($settings->serverExcludes)) {
269 269
             foreach ($settings->serverExcludes as $match => $matchArray) {
270
-                if (isset($_SERVER[$match])) {
270
+                if (isset($_SERVER[ $match ])) {
271 271
                     foreach ($matchArray as $matchItem) {
272
-                        if (preg_match($matchItem, $_SERVER[$match])) {
272
+                        if (preg_match($matchItem, $_SERVER[ $match ])) {
273 273
                             if ($settings->logExcludedAnalytics) {
274 274
                                 Craft::info(
275
-                                    "Analytics excluded for: ".$requestIp." due to: `serverExcludes`",
275
+                                    "Analytics excluded for: " . $requestIp . " due to: `serverExcludes`",
276 276
                                     __METHOD__
277 277
                                 );
278 278
                             }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             if ($crawlerDetect->isCrawler()) {
292 292
                 if ($settings->logExcludedAnalytics) {
293 293
                     Craft::info(
294
-                        "Analytics excluded for: ".$requestIp." due to: `filterBotUserAgents`",
294
+                        "Analytics excluded for: " . $requestIp . " due to: `filterBotUserAgents`",
295 295
                         __METHOD__
296 296
                     );
297 297
                 }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             if ($settings->adminExclude && $user->admin) {
309 309
                 if ($settings->logExcludedAnalytics) {
310 310
                     Craft::info(
311
-                        "Analytics excluded for: ".$requestIp." due to: `adminExclude`",
311
+                        "Analytics excluded for: " . $requestIp . " due to: `adminExclude`",
312 312
                         __METHOD__
313 313
                     );
314 314
                 }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                     if ($user->isInGroup($matchItem)) {
322 322
                         if ($settings->logExcludedAnalytics) {
323 323
                             Craft::info(
324
-                                "Analytics excluded for: ".$requestIp." due to: `groupExcludes`",
324
+                                "Analytics excluded for: " . $requestIp . " due to: `groupExcludes`",
325 325
                                 __METHOD__
326 326
                             );
327 327
                         }
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
         // We want to send just a path to GA for page views
352 352
         if (UrlHelper::isAbsoluteUrl($url)) {
353 353
             $urlParts = parse_url($url);
354
-            if (isset($urlParts['path'])) {
355
-                $url = $urlParts['path'];
354
+            if (isset($urlParts[ 'path' ])) {
355
+                $url = $urlParts[ 'path' ];
356 356
             } else {
357 357
                 $url = "/";
358 358
             }
359
-            if (isset($urlParts['query'])) {
360
-                $url = $url."?".$urlParts['query'];
359
+            if (isset($urlParts[ 'query' ])) {
360
+                $url = $url . "?" . $urlParts[ 'query' ];
361 361
             }
362 362
         }
363 363
 
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
     private function getGclid()
472 472
     {
473 473
         $gclid = "";
474
-        if (isset($_GET['gclid'])) {
475
-            $gclid = $_GET['gclid'];
474
+        if (isset($_GET[ 'gclid' ])) {
475
+            $gclid = $_GET[ 'gclid' ];
476 476
             if (!empty($gclid)) {
477 477
                 setcookie("gclid", $gclid, time() + (10 * 365 * 24 * 60 * 60), "/");
478 478
             }
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
     private function gaParseCookie()
491 491
     {
492 492
         $cid = '';
493
-        if (isset($_COOKIE['_ga'])) {
494
-            $parts = preg_split('[\.]', $_COOKIE["_ga"], 4);
493
+        if (isset($_COOKIE[ '_ga' ])) {
494
+            $parts = preg_split('[\.]', $_COOKIE[ "_ga" ], 4);
495 495
             if ($parts !== false) {
496 496
                 $cid = implode('.', array_slice($parts, 2));
497 497
             }
498 498
         } else {
499
-            if (isset($_COOKIE['_ia']) && $_COOKIE['_ia'] != '') {
500
-                $cid = $_COOKIE['_ia'];
499
+            if (isset($_COOKIE[ '_ia' ]) && $_COOKIE[ '_ia' ] != '') {
500
+                $cid = $_COOKIE[ '_ia' ];
501 501
             } else {
502 502
                 $cid = $this->gaGenUUID();
503 503
             }
Please login to merge, or discard this patch.
src/InstantAnalytics.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         // Add in our Twig extensions
84 84
         $view->registerTwigExtension(new InstantAnalyticsTwigExtension());
85 85
         // Install our template hook
86
-        $view->hook('iaSendPageView', [$this, 'iaSendPageView']);
86
+        $view->hook('iaSendPageView', [ $this, 'iaSendPageView' ]);
87 87
         // Determine if Craft Commerce is installed & enabled
88 88
         self::$commercePlugin = Craft::$app->getPlugins()->getPlugin('commerce');
89 89
         // Determine if SEOmatic is installed & enabled
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         Event::on(
93 93
             CraftVariable::class,
94 94
             CraftVariable::EVENT_INIT,
95
-            function (Event $event) {
95
+            function(Event $event) {
96 96
                 /** @var CraftVariable $variable */
97 97
                 $variable = $event->sender;
98 98
                 $variable->set('instantAnalytics', InstantAnalyticsVariable::class);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         Event::on(
104 104
             Plugins::class,
105 105
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
106
-            function (PluginEvent $event) {
106
+            function(PluginEvent $event) {
107 107
                 if ($event->plugin === $this) {
108 108
                     $request = Craft::$app->getRequest();
109 109
                     if (($request->isCpRequest) && (!$request->isConsoleRequest)) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             Event::on(
120 120
                 View::class,
121 121
                 View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE,
122
-                function (TemplateEvent $event) {
122
+                function(TemplateEvent $event) {
123 123
                     self::$currentTemplate = $event->template;
124 124
                 }
125 125
             );
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             Event::on(
128 128
                 View::class,
129 129
                 View::EVENT_AFTER_RENDER_PAGE_TEMPLATE,
130
-                function (TemplateEvent $event) {
130
+                function(TemplateEvent $event) {
131 131
                     $settings = InstantAnalytics::$plugin->getSettings();
132 132
                     if ($settings->autoSendPageView) {
133 133
                         $this->sendPageView();
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
             Event::on(
139 139
                 UrlManager::class,
140 140
                 UrlManager::EVENT_REGISTER_SITE_URL_RULES,
141
-                function (RegisterUrlRulesEvent $event) {
142
-                    $event->rules['instantanalytics/pageViewTrack/<filename:[-\w\.*]+>?'] =
141
+                function(RegisterUrlRulesEvent $event) {
142
+                    $event->rules[ 'instantanalytics/pageViewTrack/<filename:[-\w\.*]+>?' ] =
143 143
                         'instant-analytics/track/track-page-view-url';
144
-                    $event->rules['instantanalytics/eventTrack/<filename:[-\w\.*]+>?'] =
144
+                    $event->rules[ 'instantanalytics/eventTrack/<filename:[-\w\.*]+>?' ] =
145 145
                         'instant-analytics/track/track-event-url';
146 146
                 }
147 147
             );
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             Craft::t(
156 156
                 'instant-analytics',
157 157
                 '{name} plugin loaded',
158
-                ['name' => $this->name]
158
+                [ 'name' => $this->name ]
159 159
             ),
160 160
             __METHOD__
161 161
         );
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function settingsHtml()
168 168
     {
169
-        $commerceFields = [];
169
+        $commerceFields = [ ];
170 170
 
171 171
         if (self::$commercePlugin) {
172 172
             /**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     private function getPullFieldsFromLayoutId(int $layoutId)
214 214
     {
215
-        $result = ['' => "none"];
215
+        $result = [ '' => "none" ];
216 216
         $fieldLayout = Craft::$app->getFields()->getLayoutById($layoutId);
217 217
         $fieldLayoutFields = $fieldLayout->getFields();
218 218
         foreach ($fieldLayoutFields as $fieldLayoutField) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                 case "RichText":
223 223
                 case "RedactorI":
224 224
                 case "Categories":
225
-                    $result[$field->handle] = $field->name;
225
+                    $result[ $field->handle ] = $field->name;
226 226
                     break;
227 227
 
228 228
                 case "Tags":
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             if ($analytics) {
247 247
                 $response = $analytics->sendPageView();
248 248
                 Craft::info(
249
-                    "pageView sent, response: ".print_r($response, true),
249
+                    "pageView sent, response: " . print_r($response, true),
250 250
                     __METHOD__
251 251
                 );
252 252
             } else {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $request = Craft::$app->getRequest();
271 271
         if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()) {
272 272
             // If SEOmatic is installed, set the page title from it
273
-            if (self::$seomaticPlugin && isset($context['seomaticMeta'])) {
273
+            if (self::$seomaticPlugin && isset($context[ 'seomaticMeta' ])) {
274 274
                 /**
275 275
                  * TODO: fix for SEOmatic
276 276
                  * $seomaticMeta = $context['seomaticMeta'];
Please login to merge, or discard this patch.