@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $tag = Url::create($tag); |
47 | 47 | } |
48 | 48 | |
49 | - if (! in_array($tag, $this->tags)) { |
|
49 | + if (!in_array($tag, $this->tags)) { |
|
50 | 50 | $this->tags[] = $tag; |
51 | 51 | } |
52 | 52 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function getUrl(string $url): ?Url |
62 | 62 | { |
63 | - return collect($this->tags)->first(function (Tag $tag) use ($url) { |
|
63 | + return collect($this->tags)->first(function(Tag $tag) use ($url) { |
|
64 | 64 | return $tag->getType() === 'url' && $tag->url === $url; |
65 | 65 | }); |
66 | 66 | } |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | |
73 | 73 | public function hasImages() : bool |
74 | 74 | { |
75 | - return (bool) collect($this->tags)->first(function (Tag $tag) { |
|
76 | - return $tag->getType() === 'url' && ! empty($tag->images); |
|
75 | + return (bool) collect($this->tags)->first(function(Tag $tag) { |
|
76 | + return $tag->getType() === 'url' && !empty($tag->images); |
|
77 | 77 | }); |
78 | 78 | } |
79 | 79 | |
80 | 80 | public function hasNews() : bool |
81 | 81 | { |
82 | - return (bool) collect($this->tags)->first(function (Tag $tag) { |
|
83 | - return $tag->getType() === 'url' && ! empty($tag->news); |
|
82 | + return (bool) collect($this->tags)->first(function(Tag $tag) { |
|
83 | + return $tag->getType() === 'url' && !empty($tag->news); |
|
84 | 84 | }); |
85 | 85 | } |
86 | 86 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $hasImages = $this->hasImages(); |
99 | 99 | $hasNews = $this->hasNews(); |
100 | 100 | |
101 | - if (! $nativeRenderer) { |
|
101 | + if (!$nativeRenderer) { |
|
102 | 102 | return view('sitemap::sitemap') |
103 | 103 | ->with(compact('tags', 'hasImages', 'hasNews')) |
104 | 104 | ->render(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function getSitemap(string $url): ?Sitemap |
42 | 42 | { |
43 | - return collect($this->tags)->first(function (Tag $tag) use ($url) { |
|
43 | + return collect($this->tags)->first(function(Tag $tag) use ($url) { |
|
44 | 44 | return $tag->getType() === 'sitemap' && $tag->url === $url; |
45 | 45 | }); |
46 | 46 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $tags = $this->tags; |
64 | 64 | |
65 | - if (! $nativeRenderer) { |
|
65 | + if (!$nativeRenderer) { |
|
66 | 66 | return view('sitemap::sitemapIndex/index') |
67 | 67 | ->with(compact('tags')) |
68 | 68 | ->render(); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function render(string $type) : string |
37 | 37 | { |
38 | 38 | try { |
39 | - switch($type) { |
|
39 | + switch ($type) { |
|
40 | 40 | case 'sitemap': |
41 | 41 | $xml = $this->sitemapTemplate(); |
42 | 42 | |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | default: |
49 | 49 | throw new \Exception('Invalid Render Type', 999); |
50 | 50 | } |
51 | - } catch(\Exception $e) { |
|
51 | + } catch (\Exception $e) { |
|
52 | 52 | if ($e->getCode() === 999) { |
53 | 53 | throw new \Exception('The render type must be "sitemap" or "sitemapIndex"'); |
54 | 54 | } |
55 | 55 | |
56 | - throw new \Exception('Error while rendering the xml: ' . $e->getMessage()); |
|
56 | + throw new \Exception('Error while rendering the xml: '.$e->getMessage()); |
|
57 | 57 | } |
58 | 58 | |
59 | - if (! class_exists('\DOMDocument')) { |
|
59 | + if (!class_exists('\DOMDocument')) { |
|
60 | 60 | return $xml; |
61 | 61 | } |
62 | 62 | |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | |
76 | 76 | private function sitemapIndexTemplate() : string |
77 | 77 | { |
78 | - $template = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
78 | + $template = '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
79 | 79 | $template .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; |
80 | 80 | |
81 | 81 | foreach ($this->params['tags'] as $tag) { |
82 | 82 | /** @var Sitemap $tag */ |
83 | 83 | |
84 | 84 | $template .= '<sitemap>'; |
85 | - if (! empty($tag->url)) { |
|
86 | - $template .= '<loc>' . url($tag->url) . '</loc>'; |
|
85 | + if (!empty($tag->url)) { |
|
86 | + $template .= '<loc>'.url($tag->url).'</loc>'; |
|
87 | 87 | } |
88 | 88 | |
89 | - if (! empty($tag->lastModificationDate)) { |
|
90 | - $template .= '<lastmod>' . $tag->lastModificationDate->format(DateTime::ATOM) . '</lastmod>'; |
|
89 | + if (!empty($tag->lastModificationDate)) { |
|
90 | + $template .= '<lastmod>'.$tag->lastModificationDate->format(DateTime::ATOM).'</lastmod>'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $template .= '</sitemap>'; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | private function sitemapTemplate() : string |
102 | 102 | { |
103 | - $template = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
|
103 | + $template = '<?xml version="1.0" encoding="UTF-8"?>'."\n"; |
|
104 | 104 | $template .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"'; |
105 | 105 | if ($this->params['hasImages']) { |
106 | 106 | $template .= ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'; |
@@ -122,39 +122,39 @@ discard block |
||
122 | 122 | private function urlTemplate(Url $tag) : string |
123 | 123 | { |
124 | 124 | $template = '<url>'; |
125 | - if (! empty($tag->url)) { |
|
126 | - $template .= '<loc>' . url($tag->url) . '</loc>'; |
|
125 | + if (!empty($tag->url)) { |
|
126 | + $template .= '<loc>'.url($tag->url).'</loc>'; |
|
127 | 127 | } |
128 | 128 | if (count($tag->alternates)) { |
129 | 129 | foreach ($tag->alternates as $alternate) { |
130 | - $template .= '<xhtml:link rel="alternate" hreflang="' . $alternate->locale . '" href="' . url($alternate->url) . '" />'; |
|
130 | + $template .= '<xhtml:link rel="alternate" hreflang="'.$alternate->locale.'" href="'.url($alternate->url).'" />'; |
|
131 | 131 | } |
132 | 132 | } |
133 | - if (! empty($tag->lastModificationDate)) { |
|
134 | - $template .= '<lastmod>' . $tag->lastModificationDate->format(DateTime::ATOM) . '</lastmod>'; |
|
133 | + if (!empty($tag->lastModificationDate)) { |
|
134 | + $template .= '<lastmod>'.$tag->lastModificationDate->format(DateTime::ATOM).'</lastmod>'; |
|
135 | 135 | } |
136 | - if (! empty($tag->changeFrequency)) { |
|
137 | - $template .= '<changefreq>' . $tag->changeFrequency . '</changefreq>'; |
|
136 | + if (!empty($tag->changeFrequency)) { |
|
137 | + $template .= '<changefreq>'.$tag->changeFrequency.'</changefreq>'; |
|
138 | 138 | } |
139 | - if (! empty($tag->priority)) { |
|
140 | - $template .= '<priority>' . number_format($tag->priority, 1) . '</priority>'; |
|
139 | + if (!empty($tag->priority)) { |
|
140 | + $template .= '<priority>'.number_format($tag->priority, 1).'</priority>'; |
|
141 | 141 | } |
142 | 142 | if (count($tag->images)) { |
143 | 143 | foreach ($tag->images as $image) { |
144 | - if (! empty($image->url)) { |
|
144 | + if (!empty($image->url)) { |
|
145 | 145 | $template .= '<image:image>'; |
146 | - $template .= '<image:loc>' . url($image->url) . '</image:loc>'; |
|
147 | - if (! empty($image->caption)) { |
|
148 | - $template .= '<image:caption>' . $image->caption . '</image:caption>'; |
|
146 | + $template .= '<image:loc>'.url($image->url).'</image:loc>'; |
|
147 | + if (!empty($image->caption)) { |
|
148 | + $template .= '<image:caption>'.$image->caption.'</image:caption>'; |
|
149 | 149 | } |
150 | - if (! empty($image->geo_location)) { |
|
151 | - $template .= '<image:geo_location>' . $image->geo_location . '</image:geo_location>'; |
|
150 | + if (!empty($image->geo_location)) { |
|
151 | + $template .= '<image:geo_location>'.$image->geo_location.'</image:geo_location>'; |
|
152 | 152 | } |
153 | - if (! empty($image->title)) { |
|
154 | - $template .= '<image:title>' . $image->title . '</image:title>'; |
|
153 | + if (!empty($image->title)) { |
|
154 | + $template .= '<image:title>'.$image->title.'</image:title>'; |
|
155 | 155 | } |
156 | - if (! empty($image->license)) { |
|
157 | - $template .= '<image:license>' . $image->license . '</image:license>'; |
|
156 | + if (!empty($image->license)) { |
|
157 | + $template .= '<image:license>'.$image->license.'</image:license>'; |
|
158 | 158 | } |
159 | 159 | $template .= '</image:image>'; |
160 | 160 | } |
@@ -163,20 +163,20 @@ discard block |
||
163 | 163 | if (count($tag->news)) { |
164 | 164 | foreach ($tag->news as $new) { |
165 | 165 | $template .= '<news:news>'; |
166 | - if (! empty($new->publication_date)) { |
|
167 | - $template .= '<news:publication_date>' . $new->publication_date->format('Y-m-d') . '</news:publication_date>'; |
|
166 | + if (!empty($new->publication_date)) { |
|
167 | + $template .= '<news:publication_date>'.$new->publication_date->format('Y-m-d').'</news:publication_date>'; |
|
168 | 168 | } |
169 | - if (! empty($new->title)) { |
|
170 | - $template .= '<news:title>' . $new->title . '</news:title>'; |
|
169 | + if (!empty($new->title)) { |
|
170 | + $template .= '<news:title>'.$new->title.'</news:title>'; |
|
171 | 171 | } |
172 | - if (! empty($new->name) || ! empty($new->language)) { |
|
172 | + if (!empty($new->name) || !empty($new->language)) { |
|
173 | 173 | $template .= '<news:publication>'; |
174 | - if (! empty($new->name)) { |
|
175 | - $template .= '<news:name>' . $new->name . '</news:name>'; |
|
174 | + if (!empty($new->name)) { |
|
175 | + $template .= '<news:name>'.$new->name.'</news:name>'; |
|
176 | 176 | } |
177 | 177 | |
178 | - if (! empty($new->language)) { |
|
179 | - $template .= '<news:language>' . $new->language . '</news:language>'; |
|
178 | + if (!empty($new->language)) { |
|
179 | + $template .= '<news:language>'.$new->language.'</news:language>'; |
|
180 | 180 | } |
181 | 181 | $template .= '</news:publication>'; |
182 | 182 | } |