Passed
Push — v3 ( 4d5a5e...2ec2ef )
by Andrew
21:28 queued 08:26
created
src/helpers/Sitemap.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         // Output some info if this is a console app
112 112
         if ($job && Craft::$app instanceof ConsoleApplication) {
113
-            echo $job->description . PHP_EOL;
113
+            echo $job->description.PHP_EOL;
114 114
         }
115 115
 
116 116
         $lines = [];
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         if ($multiSite) {
138 138
             $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"';
139 139
         }
140
-        if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
140
+        if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
141 141
             $urlsetLine .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"';
142 142
         }
143 143
         $urlsetLine .= '>';
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
         while ($currentElement < $totalElements) {
173 173
             $elements = $paginator->getPageResults();
174 174
             if (Craft::$app instanceof ConsoleApplication) {
175
-                echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages()
176
-                    . ' - elements: ' . $paginator->getTotalResults()
175
+                echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages()
176
+                    . ' - elements: '.$paginator->getTotalResults()
177 177
                     . PHP_EOL;
178 178
             }
179 179
             /** @var Element $element */
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                 }
186 186
                 // Output some info if this is a console app
187 187
                 if (Craft::$app instanceof ConsoleApplication) {
188
-                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}" . PHP_EOL;
188
+                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}".PHP_EOL;
189 189
                 }
190 190
 
191 191
                 $metaBundle->metaSitemapVars->setAttributes($stashedSitemapAttrs, false);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                         }
234 234
                         $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl);
235 235
                         if ($url !== $canonicalUrl) {
236
-                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri);
236
+                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri);
237 237
                             continue;
238 238
                         }
239 239
                     }
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
                                             if ($primarySiteId === $altSourceSiteId && Seomatic::$settings->addXDefaultHrefLang) {
295 295
                                                 $lines[] = '<xhtml:link rel="alternate"'
296 296
                                                     . ' hreflang="x-default"'
297
-                                                    . ' href="' . Html::encode($altUrl) . '"'
297
+                                                    . ' href="'.Html::encode($altUrl).'"'
298 298
                                                     . ' />';
299 299
                                             }
300 300
                                             $lines[] = '<xhtml:link rel="alternate"'
301
-                                                . ' hreflang="' . $altSiteSettings['language'] . '"'
302
-                                                . ' href="' . Html::encode($altUrl) . '"'
301
+                                                . ' hreflang="'.$altSiteSettings['language'].'"'
302
+                                                . ' href="'.Html::encode($altUrl).'"'
303 303
                                                 . ' />';
304 304
                                         }
305 305
                                     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
                         }
309 309
                     }
310 310
                     // Handle news sitemaps https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap
311
-                    if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
311
+                    if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
312 312
                         $now = new DateTime();
313 313
                         $interval = $now->diff($dateUpdated);
314 314
                         if ($interval->days <= 2) {
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
                             }
319 319
                             $lines[] = '<news:news>';
320 320
                             $lines[] = '<news:publication>';
321
-                            $lines[] = '<news:name>' . $metaBundle->metaSitemapVars->newsPublicationName . '</news:name>';
322
-                            $lines[] = '<news:language>' . $language . '</news:language>';
321
+                            $lines[] = '<news:name>'.$metaBundle->metaSitemapVars->newsPublicationName.'</news:name>';
322
+                            $lines[] = '<news:language>'.$language.'</news:language>';
323 323
                             $lines[] = '</news:publication>';
324
-                            $lines[] = '<news:publication_date>' . $dateUpdated->format(DateTime::W3C) . '</news:publication_date>';
325
-                            $lines[] = '<news:title>' . $element->title . '</news:title>';
324
+                            $lines[] = '<news:publication_date>'.$dateUpdated->format(DateTime::W3C).'</news:publication_date>';
325
+                            $lines[] = '<news:title>'.$element->title.'</news:title>';
326 326
                             $lines[] = '</news:news>';
327 327
                         }
328 328
                     }
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
         $lines[] = '</urlset>';
421 421
 
422 422
         $cache = Craft::$app->getCache();
423
-        $cacheKey = SitemapTemplate::CACHE_KEY . $groupId . $type . $handle . $siteId;
423
+        $cacheKey = SitemapTemplate::CACHE_KEY.$groupId.$type.$handle.$siteId;
424 424
         $dependency = new TagDependency([
425 425
             'tags' => [
426 426
                 SitemapTemplate::GLOBAL_SITEMAP_CACHE_TAG,
427
-                SitemapTemplate::SITEMAP_CACHE_TAG . $handle . $siteId,
427
+                SitemapTemplate::SITEMAP_CACHE_TAG.$handle.$siteId,
428 428
             ],
429 429
         ]);
430 430
         $lines = implode('', $lines);
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
         $result = $cache->set($cacheKey, $lines, $cacheDuration, $dependency);
438 438
         // Remove the queue job id from the cache too
439 439
         $cache->delete($queueJobCacheKey);
440
-        Craft::debug('Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey, __METHOD__);
440
+        Craft::debug('Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey, __METHOD__);
441 441
         // Output some info if this is a console app
442 442
         if (Craft::$app instanceof ConsoleApplication) {
443
-            echo 'Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey . PHP_EOL;
443
+            echo 'Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey.PHP_EOL;
444 444
         }
445 445
         // If the FastCGI Cache Bust plugin is installed, clear its caches too
446 446
         /** @var FastcgiCacheBust $plugin */
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      */
557 557
     protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines)
558 558
     {
559
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
559
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
560 560
             switch ($asset->kind) {
561 561
                 case 'image':
562 562
                     $transform = Craft::$app->getAssetTransforms()->getTransformByHandle($metaBundle->metaSitemapVars->sitemapAssetTransform ?? '');
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
                         $fieldName = $row['field'] ?? '';
570 570
                         $propName = $row['property'] ?? '';
571 571
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
572
-                            $lines[] = '<image:' . $propName . '>';
572
+                            $lines[] = '<image:'.$propName.'>';
573 573
                             $lines[] = Html::encode($asset[$fieldName]);
574
-                            $lines[] = '</image:' . $propName . '>';
574
+                            $lines[] = '</image:'.$propName.'>';
575 575
                         }
576 576
                     }
577 577
                     $lines[] = '</image:image>';
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
                         $fieldName = $row['field'] ?? '';
588 588
                         $propName = $row['property'] ?? '';
589 589
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
590
-                            $lines[] = '<video:' . $propName . '>';
590
+                            $lines[] = '<video:'.$propName.'>';
591 591
                             $lines[] = Html::encode($asset[$fieldName]);
592
-                            $lines[] = '</video:' . $propName . '>';
592
+                            $lines[] = '</video:'.$propName.'>';
593 593
                         }
594 594
                     }
595 595
                     $lines[] = '</video:video>';
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
      */
606 606
     protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines)
607 607
     {
608
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
608
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
609 609
             if (in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) {
610 610
                 $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new DateTime();
611 611
                 $lines[] = '<url>';
Please login to merge, or discard this patch.