Passed
Push — v3 ( c32422...11cdfe )
by Andrew
13:45
created
src/helpers/Sitemap.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         if ($multiSite) {
121 121
             $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"';
122 122
         }
123
-        if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
123
+        if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
124 124
             $urlsetLine .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"';
125 125
         }
126 126
         $urlsetLine .= '>';
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
                         $paginator->getTotalPages(),
189 189
                         $paginator->getTotalResults());
190 190
                 }
191
-                echo $message . PHP_EOL;
191
+                echo $message.PHP_EOL;
192 192
             }
193 193
             /** @var Element $element */
194 194
             foreach ($elements as $element) {
195 195
                 // Output some info if this is a console app
196 196
                 if (Craft::$app instanceof ConsoleApplication) {
197
-                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}" . PHP_EOL;
197
+                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}".PHP_EOL;
198 198
                 }
199 199
 
200 200
                 $metaBundle->metaSitemapVars->setAttributes($stashedSitemapAttrs, false);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                         }
243 243
                         $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl);
244 244
                         if ($url !== $canonicalUrl) {
245
-                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri);
245
+                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri);
246 246
                             continue;
247 247
                         }
248 248
                     }
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
                                             if ($primarySiteId === $altSourceSiteId && Seomatic::$settings->addXDefaultHrefLang) {
304 304
                                                 $lines[] = '<xhtml:link rel="alternate"'
305 305
                                                     . ' hreflang="x-default"'
306
-                                                    . ' href="' . Html::encode($altUrl) . '"'
306
+                                                    . ' href="'.Html::encode($altUrl).'"'
307 307
                                                     . ' />';
308 308
                                             }
309 309
                                             $lines[] = '<xhtml:link rel="alternate"'
310
-                                                . ' hreflang="' . $altSiteSettings['language'] . '"'
311
-                                                . ' href="' . Html::encode($altUrl) . '"'
310
+                                                . ' hreflang="'.$altSiteSettings['language'].'"'
311
+                                                . ' href="'.Html::encode($altUrl).'"'
312 312
                                                 . ' />';
313 313
                                         }
314 314
                                     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                         }
318 318
                     }
319 319
                     // Handle news sitemaps https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap
320
-                    if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
320
+                    if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
321 321
                         $now = new DateTime();
322 322
                         $interval = $now->diff($dateUpdated);
323 323
                         if ($interval->days <= 2) {
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
                             }
328 328
                             $lines[] = '<news:news>';
329 329
                             $lines[] = '<news:publication>';
330
-                            $lines[] = '<news:name>' . $metaBundle->metaSitemapVars->newsPublicationName . '</news:name>';
331
-                            $lines[] = '<news:language>' . $language . '</news:language>';
330
+                            $lines[] = '<news:name>'.$metaBundle->metaSitemapVars->newsPublicationName.'</news:name>';
331
+                            $lines[] = '<news:language>'.$language.'</news:language>';
332 332
                             $lines[] = '</news:publication>';
333
-                            $lines[] = '<news:publication_date>' . $dateUpdated->format(DateTime::W3C) . '</news:publication_date>';
334
-                            $lines[] = '<news:title>' . $element->title . '</news:title>';
333
+                            $lines[] = '<news:publication_date>'.$dateUpdated->format(DateTime::W3C).'</news:publication_date>';
334
+                            $lines[] = '<news:title>'.$element->title.'</news:title>';
335 335
                             $lines[] = '</news:news>';
336 336
                         }
337 337
                     }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      */
548 548
     protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines)
549 549
     {
550
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
550
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
551 551
             switch ($asset->kind) {
552 552
                 case 'image':
553 553
                     $transform = Craft::$app->getAssetTransforms()->getTransformByHandle($metaBundle->metaSitemapVars->sitemapAssetTransform ?? '');
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
                         $fieldName = $row['field'] ?? '';
561 561
                         $propName = $row['property'] ?? '';
562 562
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
563
-                            $lines[] = '<image:' . $propName . '>';
563
+                            $lines[] = '<image:'.$propName.'>';
564 564
                             $lines[] = Html::encode($asset[$fieldName]);
565
-                            $lines[] = '</image:' . $propName . '>';
565
+                            $lines[] = '</image:'.$propName.'>';
566 566
                         }
567 567
                     }
568 568
                     $lines[] = '</image:image>';
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
                         $fieldName = $row['field'] ?? '';
579 579
                         $propName = $row['property'] ?? '';
580 580
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
581
-                            $lines[] = '<video:' . $propName . '>';
581
+                            $lines[] = '<video:'.$propName.'>';
582 582
                             $lines[] = Html::encode($asset[$fieldName]);
583
-                            $lines[] = '</video:' . $propName . '>';
583
+                            $lines[] = '</video:'.$propName.'>';
584 584
                         }
585 585
                     }
586 586
                     $lines[] = '</video:video>';
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      */
597 597
     protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines)
598 598
     {
599
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
599
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
600 600
             if (in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) {
601 601
                 $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new DateTime();
602 602
                 $lines[] = '<url>';
Please login to merge, or discard this patch.
src/models/SitemapTemplate.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
         }
150 150
 
151 151
         $cache = Craft::$app->getCache();
152
-        $pageCacheSuffix = 's' . (int)$metaBundle->metaSitemapVars->sitemapPageSize . 'p' . $page;
152
+        $pageCacheSuffix = 's'.(int) $metaBundle->metaSitemapVars->sitemapPageSize.'p'.$page;
153 153
 
154
-        $uniqueKey = $groupId . $type . $handle . $siteId . $pageCacheSuffix;
155
-        $cacheKey = self::CACHE_KEY . $uniqueKey;
154
+        $uniqueKey = $groupId.$type.$handle.$siteId.$pageCacheSuffix;
155
+        $cacheKey = self::CACHE_KEY.$uniqueKey;
156 156
         $result = $cache->get($cacheKey);
157 157
 
158 158
         // If the sitemap isn't cached, start a job to create it
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 $dependency = new TagDependency([
172 172
                     'tags' => [
173 173
                         self::GLOBAL_SITEMAP_CACHE_TAG,
174
-                        self::SITEMAP_CACHE_TAG . $handle . $siteId . $pageCacheSuffix,
174
+                        self::SITEMAP_CACHE_TAG.$handle.$siteId.$pageCacheSuffix,
175 175
                     ],
176 176
                 ]);
177 177
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
                 // Output some info if this is a console app
185 185
                 if (Craft::$app instanceof ConsoleApplication) {
186
-                    echo 'Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey . PHP_EOL;
186
+                    echo 'Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey.PHP_EOL;
187 187
                 }
188 188
 
189 189
                 // If the FastCGI Cache Bust plugin is installed, clear its caches too
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
                 // Return an empty XML document
212 212
                 $lines[] = '<?xml version="1.0" encoding="UTF-8"?>';
213 213
                 $lines[] = '<?xml-stylesheet type="text/xsl" href="sitemap-empty.xsl"?>';
214
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'This sitemap has not been generated yet.') . ' -->';
215
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'If you are seeing this in local dev or an') . ' -->';
216
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'environment with `devMode` on, caches only') . ' -->';
217
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'last for 30 seconds in local dev, so it is') . ' -->';
218
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'normal for the sitemap to not be cached.') . ' -->';
214
+                $lines[] = '<!-- '.Craft::t('seomatic', 'This sitemap has not been generated yet.').' -->';
215
+                $lines[] = '<!-- '.Craft::t('seomatic', 'If you are seeing this in local dev or an').' -->';
216
+                $lines[] = '<!-- '.Craft::t('seomatic', 'environment with `devMode` on, caches only').' -->';
217
+                $lines[] = '<!-- '.Craft::t('seomatic', 'last for 30 seconds in local dev, so it is').' -->';
218
+                $lines[] = '<!-- '.Craft::t('seomatic', 'normal for the sitemap to not be cached.').' -->';
219 219
                 $lines[] = '<urlset>';
220 220
                 $lines[] = '</urlset>';
221 221
             }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             return $lines;
225 225
         } else {
226 226
             if (Craft::$app instanceof ConsoleApplication) {
227
-                echo 'Found in cache' . PHP_EOL;
227
+                echo 'Found in cache'.PHP_EOL;
228 228
             }
229 229
         }
230 230
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     public function invalidateCache(string $handle, int $siteId)
241 241
     {
242 242
         $cache = Craft::$app->getCache();
243
-        TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG . $handle . $siteId);
243
+        TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG.$handle.$siteId);
244 244
         Craft::info(
245
-            'Sitemap cache cleared: ' . $handle,
245
+            'Sitemap cache cleared: '.$handle,
246 246
             __METHOD__
247 247
         );
248 248
     }
Please login to merge, or discard this patch.
src/Seomatic.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         self::$cacheDuration = self::$devMode
277 277
             ? self::DEVMODE_CACHE_DURATION
278 278
             : self::$settings->metaCacheDuration ?? null;
279
-        self::$cacheDuration = self::$cacheDuration === null ? null : (int)self::$cacheDuration;
279
+        self::$cacheDuration = self::$cacheDuration === null ? null : (int) self::$cacheDuration;
280 280
         self::$environment = EnvironmentHelper::determineEnvironment();
281 281
         MetaValueHelper::cache();
282 282
         // Version helpers
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             $lastSegment = end($segments);
399 399
             $site = Craft::$app->getSites()->getSiteByHandle($lastSegment);
400 400
             if ($site !== null) {
401
-                $siteSuffix = '/' . $lastSegment;
401
+                $siteSuffix = '/'.$lastSegment;
402 402
             }
403 403
         }
404 404
         /** @var User $currentUser */
@@ -407,31 +407,31 @@  discard block
 block discarded – undo
407 407
         if ($currentUser->can('seomatic:dashboard')) {
408 408
             $subNavs['dashboard'] = [
409 409
                 'label' => Craft::t('seomatic', 'Dashboard'),
410
-                'url' => 'seomatic/dashboard' . $siteSuffix,
410
+                'url' => 'seomatic/dashboard'.$siteSuffix,
411 411
             ];
412 412
         }
413 413
         if ($currentUser->can('seomatic:global-meta')) {
414 414
             $subNavs['global'] = [
415 415
                 'label' => Craft::t('seomatic', 'Global SEO'),
416
-                'url' => 'seomatic/global/general' . $siteSuffix,
416
+                'url' => 'seomatic/global/general'.$siteSuffix,
417 417
             ];
418 418
         }
419 419
         if ($currentUser->can('seomatic:content-meta')) {
420 420
             $subNavs['content'] = [
421 421
                 'label' => Craft::t('seomatic', 'Content SEO'),
422
-                'url' => 'seomatic/content' . $siteSuffix,
422
+                'url' => 'seomatic/content'.$siteSuffix,
423 423
             ];
424 424
         }
425 425
         if ($currentUser->can('seomatic:site-settings')) {
426 426
             $subNavs['site'] = [
427 427
                 'label' => Craft::t('seomatic', 'Site Settings'),
428
-                'url' => 'seomatic/site/identity' . $siteSuffix,
428
+                'url' => 'seomatic/site/identity'.$siteSuffix,
429 429
             ];
430 430
         }
431 431
         if ($currentUser->can('seomatic:tracking-scripts')) {
432 432
             $subNavs['tracking'] = [
433 433
                 'label' => Craft::t('seomatic', 'Tracking Scripts'),
434
-                'url' => 'seomatic/tracking/gtag' . $siteSuffix,
434
+                'url' => 'seomatic/tracking/gtag'.$siteSuffix,
435 435
             ];
436 436
         }
437 437
         $editableSettings = true;
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
                     $element = $e->sender;
627 627
                     if ($element->uri !== null) {
628 628
                         $e->previewTargets[] = [
629
-                            'label' => '
Please login to merge, or discard this patch.