1 | <?php namespace Arcanedev\LaravelSitemap\Entities; |
||
15 | class Url extends Fluent implements UrlContract |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Constructor |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Url constructor. |
||
24 | * |
||
25 | * @param array|string $attributes |
||
26 | */ |
||
27 | 76 | public function __construct($attributes = []) |
|
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Getters & Setters |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Get the url location. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 48 | public function getLoc() |
|
55 | |||
56 | /** |
||
57 | * Get the url location (alias). |
||
58 | * |
||
59 | * @see getLoc() |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | 14 | public function loc() |
|
67 | |||
68 | /** |
||
69 | * Set the url location. |
||
70 | * |
||
71 | * @param string $loc |
||
72 | * |
||
73 | * @return self |
||
74 | * |
||
75 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
76 | */ |
||
77 | 76 | public function setLoc($loc) |
|
81 | |||
82 | /** |
||
83 | * Get the last modification date. |
||
84 | * |
||
85 | * @return \DateTimeInterface |
||
86 | */ |
||
87 | 34 | public function getLastMod() |
|
91 | |||
92 | /** |
||
93 | * Get the last modification date (alias). |
||
94 | * |
||
95 | * @see getLastMod() |
||
96 | * |
||
97 | * @return \DateTimeInterface |
||
98 | */ |
||
99 | public function lastMod() |
||
103 | |||
104 | /** |
||
105 | * Format the url last modification. |
||
106 | * |
||
107 | * @param string $format |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 28 | public function formatLastMod($format = DateTime::ATOM) |
|
115 | |||
116 | /** |
||
117 | * Set the last modification date. |
||
118 | * |
||
119 | * @param string|\DateTimeInterface $lastModDate |
||
120 | * @param string $format |
||
121 | * |
||
122 | * @return self |
||
123 | */ |
||
124 | 76 | public function setLastMod($lastModDate, $format = 'Y-m-d H:i:s') |
|
131 | |||
132 | /** |
||
133 | * Get the change frequency. |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 14 | public function getChangeFreq() |
|
141 | |||
142 | /** |
||
143 | * Get the change frequency (alias). |
||
144 | * |
||
145 | * @see getChangeFreq() |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | 10 | public function changeFreq() |
|
153 | |||
154 | /** |
||
155 | * Set the change frequency. |
||
156 | * |
||
157 | * @param string $changeFreq |
||
158 | * |
||
159 | * @return self |
||
160 | */ |
||
161 | 76 | public function setChangeFreq($changeFreq) |
|
165 | |||
166 | /** |
||
167 | * Get the priority. |
||
168 | * |
||
169 | * @return float |
||
170 | */ |
||
171 | 14 | public function getPriority() |
|
175 | |||
176 | /** |
||
177 | * Get the priority (alias). |
||
178 | * |
||
179 | * @see getPriority() |
||
180 | * |
||
181 | * @return float |
||
182 | */ |
||
183 | 10 | public function priority() |
|
187 | |||
188 | /** |
||
189 | * Set the priority. |
||
190 | * |
||
191 | * @param float $priority |
||
192 | * |
||
193 | * @return self |
||
194 | * |
||
195 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
196 | */ |
||
197 | 76 | public function setPriority($priority) |
|
203 | |||
204 | /** |
||
205 | * Get the title. |
||
206 | * |
||
207 | * @return string|null |
||
208 | */ |
||
209 | 8 | public function getTitle() |
|
213 | |||
214 | /** |
||
215 | * Get the title. |
||
216 | * |
||
217 | * @param string $title |
||
218 | * |
||
219 | * @return self |
||
220 | */ |
||
221 | 76 | public function setTitle($title) |
|
225 | |||
226 | /* ----------------------------------------------------------------- |
||
227 | | Main Methods |
||
228 | | ----------------------------------------------------------------- |
||
229 | */ |
||
230 | |||
231 | /** |
||
232 | * Create a sitemap url instance. |
||
233 | * |
||
234 | * @param string $loc |
||
235 | * |
||
236 | * @return \Arcanedev\LaravelSitemap\Entities\Url |
||
237 | */ |
||
238 | 54 | public static function make($loc) |
|
242 | |||
243 | /** |
||
244 | * Make a URL instance with attributes. |
||
245 | * |
||
246 | * @param array $attributes |
||
247 | * |
||
248 | * @return \Arcanedev\LaravelSitemap\Entities\Url |
||
249 | */ |
||
250 | 4 | public static function makeFromArray(array $attributes) |
|
254 | |||
255 | /** |
||
256 | * Convert the Fluent instance to an array. |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | 18 | public function toArray() |
|
266 | |||
267 | /* ----------------------------------------------------------------- |
||
268 | | Other Methods |
||
269 | | ----------------------------------------------------------------- |
||
270 | */ |
||
271 | |||
272 | /** |
||
273 | * Set an attribute. |
||
274 | * |
||
275 | * @param string $key |
||
276 | * @param mixed $value |
||
277 | * |
||
278 | * @return self |
||
279 | */ |
||
280 | 76 | protected function set($key, $value) |
|
286 | |||
287 | /** |
||
288 | * Check if has an attribute. |
||
289 | * |
||
290 | * @param string $key |
||
291 | * |
||
292 | * @return bool |
||
293 | */ |
||
294 | protected function has($key) |
||
298 | |||
299 | /** |
||
300 | * Escape the given value. |
||
301 | * |
||
302 | * @param string $value |
||
303 | * |
||
304 | * @return string |
||
305 | */ |
||
306 | 50 | protected function escape($value) |
|
315 | |||
316 | /** |
||
317 | * Check the loc value. |
||
318 | * |
||
319 | * @param string $loc |
||
320 | * |
||
321 | * @return string |
||
322 | * |
||
323 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
324 | */ |
||
325 | 76 | protected function checkLoc($loc) |
|
332 | |||
333 | /** |
||
334 | * Check the priority value. |
||
335 | * |
||
336 | * @param float $priority |
||
337 | * |
||
338 | * @return float |
||
339 | * |
||
340 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
341 | */ |
||
342 | 76 | protected function checkPriority($priority) |
|
354 | } |
||
355 |