Passed
Pull Request — develop-v4 (#13)
by
unknown
20:44
created
src/helpers/Field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -190,8 +190,8 @@
 block discarded – undo
190 190
                 // Prefix the keys with the global set name
191 191
                 $prefix = $global->handle;
192 192
                 $fields = array_combine(
193
-                    array_map(static function ($key) use ($prefix) {
194
-                        return $prefix . '.' . $key;
193
+                    array_map(static function($key) use ($prefix) {
194
+                        return $prefix.'.'.$key;
195 195
                     }, array_keys($fields)),
196 196
                     $fields
197 197
                 );
Please login to merge, or discard this patch.
src/ga4/ComponentFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
         ];
82 82
 
83 83
         if (!array_key_exists($componentName, $componentMap)) {
84
-            throw new \InvalidArgumentException(Craft::t('instant-analytics-ga4', 'Unknown event type - ' . $componentName));
84
+            throw new \InvalidArgumentException(Craft::t('instant-analytics-ga4', 'Unknown event type - '.$componentName));
85 85
         }
86 86
         
87 87
         return new $componentMap[$componentName];
Please login to merge, or discard this patch.
src/controllers/TrackController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
      *         The actions must be in 'kebab-case'
32 32
      * @access protected
33 33
      */
34
-    protected array|bool|int $allowAnonymous = [
34
+    protected array | bool | int $allowAnonymous = [
35 35
         'track-page-view-url',
36 36
         'track-event-url'
37 37
     ];
Please login to merge, or discard this patch.
src/services/ServicesTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
         // so we can't extract it from the passed in $config
40 40
         $majorVersion = '4';
41 41
         // Dev server container name & port are based on the major version of this plugin
42
-        $devPort = 3000 + (int)$majorVersion;
43
-        $versionName = 'v' . $majorVersion;
42
+        $devPort = 3000 + (int) $majorVersion;
43
+        $versionName = 'v'.$majorVersion;
44 44
         return [
45 45
             'components' => [
46 46
                 'ga4' => Ga4::class,
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
                     'assetClass' => InstantAnalyticsAsset::class,
51 51
                     'checkDevServer' => true,
52 52
                     'class' => VitePluginService::class,
53
-                    'devServerInternal' => 'http://craft-instantanalytics-ga4-' . $versionName . '-buildchain-dev:' . $devPort,
54
-                    'devServerPublic' => 'http://localhost:' . $devPort,
53
+                    'devServerInternal' => 'http://craft-instantanalytics-ga4-'.$versionName.'-buildchain-dev:'.$devPort,
54
+                    'devServerPublic' => 'http://localhost:'.$devPort,
55 55
                     'errorEntry' => 'src/js/app.ts',
56 56
                     'useDevServer' => true,
57 57
                 ],
Please login to merge, or discard this patch.
src/ga4/Analytics.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @param string $listName
180 180
      * @throws \yii\base\InvalidConfigException
181 181
      */
182
-    public function addCommerceProductImpression(Product|Variant $productVariant, int $index = 0, string $listName = 'default') {
182
+    public function addCommerceProductImpression(Product | Variant $productVariant, int $index = 0, string $listName = 'default') {
183 183
         InstantAnalytics::$plugin->commerce->addCommerceProductImpression($productVariant);
184 184
     }
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      * @throws \yii\base\InvalidConfigException
193 193
      *@deprecated `Analytics::addCommerceProductDetailView()` is deprecated. Use `Analytics::addCommerceProductImpression()` instead.
194 194
      */
195
-    public function addCommerceProductDetailView(Product|Variant $productVariant, int $index = 0, string $listName = 'default') {
195
+    public function addCommerceProductDetailView(Product | Variant $productVariant, int $index = 0, string $listName = 'default') {
196 196
         Craft::$app->getDeprecator()->log('Analytics::addCommerceProductDetailView()', '`Analytics::addCommerceProductDetailView()` is deprecated. Use `Analytics::addCommerceProductImpression()` instead.');
197 197
         $this->addCommerceProductImpression($productVariant);
198 198
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             // Load them up for GA4
339 339
             foreach ($campaignParams as $key => $method) {
340 340
                 $value = $request->getParam($key) ?? $session->get($key) ?? null;
341
-                $method = 'set' . $method;
341
+                $method = 'set'.$method;
342 342
 
343 343
                 $this->$method($value);
344 344
 
Please login to merge, or discard this patch.
src/InstantAnalytics.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         Event::on(
247 247
             CraftVariable::class,
248 248
             CraftVariable::EVENT_INIT,
249
-            function (Event $event): void {
249
+            function(Event $event): void {
250 250
                 /** @var CraftVariable $variable */
251 251
                 $variable = $event->sender;
252 252
                 $variable->set('instantAnalytics', [
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
         Event::on(
267 267
             Plugins::class,
268 268
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
269
-            function (PluginEvent $event): void {
269
+            function(PluginEvent $event): void {
270 270
                 if ($event->plugin === $this) {
271 271
                     $request = Craft::$app->getRequest();
272 272
                     if ($request->isCpRequest) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         Event::on(
281 281
             Plugins::class,
282 282
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
283
-            function () {
283
+            function() {
284 284
                 // Determine if Craft Commerce is installed & enabled
285 285
                 self::$commercePlugin = Craft::$app->getPlugins()->getPlugin(self::COMMERCE_PLUGIN_HANDLE);
286 286
                 // Determine if SEOmatic is installed & enabled
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         Event::on(
311 311
             UrlManager::class,
312 312
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
313
-            function (RegisterUrlRulesEvent $event): void {
313
+            function(RegisterUrlRulesEvent $event): void {
314 314
                 Craft::debug(
315 315
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
316 316
                     __METHOD__
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         Event::on(
327 327
             View::class,
328 328
             View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE,
329
-            static function (TemplateEvent $event): void {
329
+            static function(TemplateEvent $event): void {
330 330
                 self::$currentTemplate = $event->template;
331 331
             }
332 332
         );
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         Event::on(
335 335
             View::class,
336 336
             View::EVENT_AFTER_RENDER_PAGE_TEMPLATE,
337
-            function (TemplateEvent $event): void {
337
+            function(TemplateEvent $event): void {
338 338
                 if (self::$settings->autoSendPageView) {
339 339
                     $request = Craft::$app->getRequest();
340 340
                     if (!$request->getIsAjax()) {
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         Event::on(
349 349
             Response::class,
350 350
             Response::EVENT_BEFORE_SEND,
351
-            function (Event $event): void {
351
+            function(Event $event): void {
352 352
                 // Initialize this sooner rather than later, since it's possible this will want to tinker with cookies
353 353
                 $this->ga4->getAnalytics();
354 354
             }
@@ -358,21 +358,21 @@  discard block
 block discarded – undo
358 358
         Event::on(
359 359
             Response::class,
360 360
             Response::EVENT_AFTER_SEND,
361
-            function (Event $event): void {
361
+            function(Event $event): void {
362 362
                 $this->ga4->getAnalytics()->sendCollectedEvents();
363 363
             }
364 364
         );
365 365
 
366 366
         // Commerce-specific hooks
367 367
         if (self::$commercePlugin !== null) {
368
-            Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function (Event $e): void {
368
+            Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e): void {
369 369
                 $order = $e->sender;
370 370
                 if (self::$settings->autoSendPurchaseComplete) {
371 371
                     $this->commerce->triggerOrderCompleteEvent($order);
372 372
                 }
373 373
             });
374 374
 
375
-            Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function (LineItemEvent $e): void {
375
+            Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function(LineItemEvent $e): void {
376 376
                 $lineItem = $e->lineItem;
377 377
                 if (self::$settings->autoSendAddToCart) {
378 378
                     $this->commerce->triggerAddToCartEvent($lineItem);
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
             });
381 381
 
382 382
             // Check to make sure Order::EVENT_AFTER_REMOVE_LINE_ITEM is defined
383
-            if (defined(Order::class . '::EVENT_AFTER_REMOVE_LINE_ITEM')) {
384
-                Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function (LineItemEvent $e): void {
383
+            if (defined(Order::class.'::EVENT_AFTER_REMOVE_LINE_ITEM')) {
384
+                Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function(LineItemEvent $e): void {
385 385
                     $lineItem = $e->lineItem;
386 386
                     if (self::$settings->autoSendRemoveFromCart) {
387 387
                         $this->commerce->triggerRemoveFromCartEvent($lineItem);
Please login to merge, or discard this patch.
src/services/Commerce.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @param Product|Variant $productVariant the Product or Variant
240 240
      * @throws \yii\base\InvalidConfigException
241 241
      */
242
-    public function addCommerceProductImpression(Variant|Product $productVariant): void
242
+    public function addCommerceProductImpression(Variant | Product $productVariant): void
243 243
     {
244 244
         if ($productVariant) {
245 245
             $event = InstantAnalytics::$plugin->ga4->getAnalytics()->create()->ViewItemEvent();
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
                 $name = $cat->title;
420 420
 
421 421
                 while ($cat = $cat->parent) {
422
-                    $name = $cat->title . '/' . $name;
422
+                    $name = $cat->title.'/'.$name;
423 423
                 }
424 424
 
425 425
                 $cats[] = $name;
Please login to merge, or discard this patch.
src/helpers/Analytics.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             $urlParts = parse_url($url);
73 73
             $url = $urlParts['path'] ?? '/';
74 74
             if (isset($urlParts['query'])) {
75
-                $url .= '?' . $urlParts['query'];
75
+                $url .= '?'.$urlParts['query'];
76 76
             }
77 77
         }
78 78
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $path = parse_url($url, PHP_URL_PATH);
114 114
         $pathFragments = explode('/', rtrim($path, '/'));
115 115
         $fileName = end($pathFragments);
116
-        $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/' . $fileName, $urlParams);
116
+        $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/'.$fileName, $urlParams);
117 117
 
118 118
         InstantAnalytics::$plugin->logAnalyticsEvent(
119 119
             'Created pageViewTrackingUrl for: {trackingUrl}',
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $urlParams = compact('url', 'eventName', 'params');
145 145
 
146 146
         $fileName = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME);
147
-        $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/' . $fileName, $urlParams);
147
+        $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/'.$fileName, $urlParams);
148 148
 
149 149
         InstantAnalytics::$plugin->logAnalyticsEvent(
150 150
             'Created eventTrackingUrl for: {trackingUrl}',
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $result = true;
169 169
         $request = Craft::$app->getRequest();
170 170
 
171
-        $logExclusion = static function (string $setting)
171
+        $logExclusion = static function(string $setting)
172 172
         {
173 173
             if (InstantAnalytics::$settings->logExcludedAnalytics) {
174 174
                 $request = Craft::$app->getRequest();
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
             $cid = $_COOKIE['_ia'];
278 278
         } else {
279 279
             // Generate our own client id, otherwise.
280
-            $cid = static::gaGenUUID() . '.1';
280
+            $cid = static::gaGenUUID().'.1';
281 281
         }
282 282
 
283 283
         if (InstantAnalytics::$settings->createGclidCookie && !empty($cid)) {
284
-            setcookie('_ia', $cid, strtotime('+' . InstantAnalytics::$settings->sessionDuration . ' minutes'), '/'); // Two years
284
+            setcookie('_ia', $cid, strtotime('+'.InstantAnalytics::$settings->sessionDuration.' minutes'), '/'); // Two years
285 285
         }
286 286
 
287 287
         return $cid;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     public static function getSessionCookie(): ?array
297 297
     {
298 298
         $measurementId = App::parseEnv(InstantAnalytics::$settings->googleAnalyticsMeasurementId);
299
-        $cookieName = '_ga_' . StringHelper::removeLeft($measurementId, 'G-');
299
+        $cookieName = '_ga_'.StringHelper::removeLeft($measurementId, 'G-');
300 300
         if (isset($_COOKIE[$cookieName])) {
301 301
             $sessionCookie = null;
302 302
 
Please login to merge, or discard this patch.