1 | <?php namespace Arcanedev\LaravelSitemap\Entities; |
||
14 | class Url implements ArrayAccess, UrlContract |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** @var string */ |
||
22 | protected $loc; |
||
23 | |||
24 | /** @var string|null */ |
||
25 | protected $title; |
||
26 | |||
27 | /** @var \DateTimeInterface */ |
||
28 | protected $lastModDate; |
||
29 | |||
30 | /** @var string */ |
||
31 | protected $changeFrequency; |
||
32 | |||
33 | /** @var float */ |
||
34 | protected $priority; |
||
35 | |||
36 | /* ----------------------------------------------------------------- |
||
37 | | Constructor |
||
38 | | ----------------------------------------------------------------- |
||
39 | */ |
||
40 | |||
41 | /** |
||
42 | * Url constructor. |
||
43 | * |
||
44 | * @param string $loc |
||
45 | */ |
||
46 | 62 | public function __construct($loc) |
|
53 | |||
54 | /* ----------------------------------------------------------------- |
||
55 | | Getters & Setters |
||
56 | | ----------------------------------------------------------------- |
||
57 | */ |
||
58 | |||
59 | /** |
||
60 | * Get the url location. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 52 | public function getLoc() |
|
68 | |||
69 | /** |
||
70 | * Get the url location (alias). |
||
71 | * |
||
72 | * @see getLoc() |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 14 | public function loc() |
|
80 | |||
81 | /** |
||
82 | * Set the url location. |
||
83 | * |
||
84 | * @param string $loc |
||
85 | * |
||
86 | * @return self |
||
87 | */ |
||
88 | 62 | public function setLoc($loc) |
|
94 | |||
95 | /** |
||
96 | * Get the last modification date. |
||
97 | * |
||
98 | * @return \DateTimeInterface |
||
99 | */ |
||
100 | 28 | public function getLastMod() |
|
104 | |||
105 | /** |
||
106 | * Get the last modification date (alias). |
||
107 | * |
||
108 | * @see getLastMod() |
||
109 | * |
||
110 | * @return \DateTimeInterface |
||
111 | */ |
||
112 | 10 | public function lastMod() |
|
116 | |||
117 | /** |
||
118 | * Format the url last modification. |
||
119 | * |
||
120 | * @param string $format |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | 22 | public function formatLastMod($format = DateTime::ATOM) |
|
128 | |||
129 | /** |
||
130 | * Set the last modification date. |
||
131 | * |
||
132 | * @param string|\DateTimeInterface $lastModDate |
||
133 | * @param string $format |
||
134 | * |
||
135 | * @return self |
||
136 | */ |
||
137 | 62 | public function setLastMod($lastModDate, $format = 'Y-m-d H:i:s') |
|
145 | |||
146 | /** |
||
147 | * Get the change frequency. |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 26 | public function getChangeFreq() |
|
155 | |||
156 | /** |
||
157 | * Get the change frequency (alias). |
||
158 | * |
||
159 | * @see getChangeFreq() |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | 10 | public function changeFreq() |
|
167 | |||
168 | /** |
||
169 | * Set the change frequency. |
||
170 | * |
||
171 | * @param string $changeFreq |
||
172 | * |
||
173 | * @return self |
||
174 | */ |
||
175 | 62 | public function setChangeFreq($changeFreq) |
|
181 | |||
182 | /** |
||
183 | * Get the priority. |
||
184 | * |
||
185 | * @return float |
||
186 | */ |
||
187 | 26 | public function getPriority() |
|
191 | |||
192 | /** |
||
193 | * Get the priority (alias). |
||
194 | * |
||
195 | * @see getPriority() |
||
196 | * |
||
197 | * @return float |
||
198 | */ |
||
199 | 10 | public function priority() |
|
203 | |||
204 | /** |
||
205 | * Set the priority. |
||
206 | * |
||
207 | * @param float $priority |
||
208 | * |
||
209 | * @return self |
||
210 | */ |
||
211 | 62 | public function setPriority($priority) |
|
217 | |||
218 | /** |
||
219 | * Get the title. |
||
220 | * |
||
221 | * @return string|null |
||
222 | */ |
||
223 | 10 | public function getTitle() |
|
227 | |||
228 | /** |
||
229 | * Get the title. |
||
230 | * |
||
231 | * @param string $title |
||
232 | * |
||
233 | * @return self |
||
234 | */ |
||
235 | 42 | public function setTitle($title) |
|
241 | |||
242 | /* ----------------------------------------------------------------- |
||
243 | | Main Methods |
||
244 | | ----------------------------------------------------------------- |
||
245 | */ |
||
246 | |||
247 | /** |
||
248 | * Create a sitemap url instance. |
||
249 | * |
||
250 | * @param string $loc |
||
251 | * |
||
252 | * @return \Arcanedev\LaravelSitemap\Entities\Url |
||
253 | */ |
||
254 | 46 | public static function make($loc) |
|
258 | |||
259 | /** |
||
260 | * Get the collection of items as a plain array. |
||
261 | * |
||
262 | * @return array |
||
263 | */ |
||
264 | 12 | public function toArray() |
|
273 | |||
274 | /** |
||
275 | * Get the sitemap url as JSON. |
||
276 | * |
||
277 | * @param int $options |
||
278 | * |
||
279 | * @return string |
||
280 | */ |
||
281 | 2 | public function toJson($options = 0) |
|
285 | |||
286 | /** |
||
287 | * Convert the object into something JSON serializable. |
||
288 | * |
||
289 | * @return array |
||
290 | */ |
||
291 | 2 | public function jsonSerialize() |
|
295 | |||
296 | /* ----------------------------------------------------------------- |
||
297 | | Other Methods |
||
298 | | ----------------------------------------------------------------- |
||
299 | */ |
||
300 | |||
301 | /** |
||
302 | * Escape the given value. |
||
303 | * |
||
304 | * @param string $value |
||
305 | * |
||
306 | * @return string |
||
307 | */ |
||
308 | 54 | protected function escape($value) |
|
317 | |||
318 | /** |
||
319 | * Determine if the given attribute exists. |
||
320 | * |
||
321 | * @param mixed $offset |
||
322 | * |
||
323 | * @return bool |
||
324 | */ |
||
325 | 2 | public function offsetExists($offset) |
|
329 | |||
330 | /** |
||
331 | * Get the value for a given offset. |
||
332 | * |
||
333 | * @param mixed $offset |
||
334 | * |
||
335 | * @return mixed |
||
336 | */ |
||
337 | 2 | public function offsetGet($offset) |
|
341 | |||
342 | /** |
||
343 | * Set the value for a given offset. |
||
344 | * |
||
345 | * @param mixed $offset |
||
346 | * @param mixed $value |
||
347 | * |
||
348 | * @return void |
||
349 | */ |
||
350 | public function offsetSet($offset, $value) {} // Do nothing... |
||
351 | |||
352 | /** |
||
353 | * Unset the value for a given offset. |
||
354 | * |
||
355 | * @param mixed $offset |
||
356 | * |
||
357 | * @return void |
||
358 | */ |
||
359 | public function offsetUnset($offset) {} // Do nothing... |
||
360 | } |
||
361 |