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 | 80 | public function __construct($attributes = []) |
|
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Getters & Setters |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Get the url location. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 54 | public function getLoc() |
|
55 | |||
56 | /** |
||
57 | * Set the url location. |
||
58 | * |
||
59 | * @param string $loc |
||
60 | * |
||
61 | * @return self |
||
62 | * |
||
63 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
64 | */ |
||
65 | 80 | public function setLoc($loc) |
|
69 | |||
70 | /** |
||
71 | * Get the last modification date. |
||
72 | * |
||
73 | * @return \DateTimeInterface |
||
74 | */ |
||
75 | 38 | public function getLastMod() |
|
79 | |||
80 | /** |
||
81 | * Format the url last modification. |
||
82 | * |
||
83 | * @param string $format |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 32 | public function formatLastMod($format = DateTime::ATOM) |
|
91 | |||
92 | /** |
||
93 | * Set the last modification date. |
||
94 | * |
||
95 | * @param string|\DateTimeInterface $lastModDate |
||
96 | * @param string $format |
||
97 | * |
||
98 | * @return self |
||
99 | */ |
||
100 | 80 | public function setLastMod($lastModDate, $format = 'Y-m-d H:i:s') |
|
107 | |||
108 | /** |
||
109 | * Get the change frequency. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 8 | public function getChangeFreq() |
|
117 | |||
118 | /** |
||
119 | * Set the change frequency. |
||
120 | * |
||
121 | * @param string $changeFreq |
||
122 | * |
||
123 | * @return self |
||
124 | */ |
||
125 | 80 | public function setChangeFreq($changeFreq) |
|
129 | |||
130 | /** |
||
131 | * Get the priority. |
||
132 | * |
||
133 | * @return float |
||
134 | */ |
||
135 | 8 | public function getPriority() |
|
139 | |||
140 | /** |
||
141 | * Set the priority. |
||
142 | * |
||
143 | * @param float $priority |
||
144 | * |
||
145 | * @return self |
||
146 | * |
||
147 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
148 | */ |
||
149 | 80 | public function setPriority($priority) |
|
155 | |||
156 | /** |
||
157 | * Get the title. |
||
158 | * |
||
159 | * @return string|null |
||
160 | */ |
||
161 | 10 | public function getTitle() |
|
165 | |||
166 | /** |
||
167 | * Get the title. |
||
168 | * |
||
169 | * @param string $title |
||
170 | * |
||
171 | * @return self |
||
172 | */ |
||
173 | 80 | public function setTitle($title) |
|
177 | |||
178 | /* ----------------------------------------------------------------- |
||
179 | | Main Methods |
||
180 | | ----------------------------------------------------------------- |
||
181 | */ |
||
182 | |||
183 | /** |
||
184 | * Create a sitemap url instance. |
||
185 | * |
||
186 | * @param string $loc |
||
187 | * |
||
188 | * @return \Arcanedev\LaravelSitemap\Entities\Url |
||
189 | */ |
||
190 | 60 | public static function make($loc) |
|
194 | |||
195 | /** |
||
196 | * Make a URL instance with attributes. |
||
197 | * |
||
198 | * @param array $attributes |
||
199 | * |
||
200 | * @return \Arcanedev\LaravelSitemap\Entities\Url |
||
201 | */ |
||
202 | 6 | public static function makeFromArray(array $attributes) |
|
206 | |||
207 | /** |
||
208 | * Check if has an attribute. |
||
209 | * |
||
210 | * @param string $key |
||
211 | * |
||
212 | * @return bool |
||
213 | */ |
||
214 | 12 | public function has($key) |
|
218 | |||
219 | /** |
||
220 | * Convert the Fluent instance to an array. |
||
221 | * |
||
222 | * @return array |
||
223 | */ |
||
224 | 20 | public function toArray() |
|
230 | |||
231 | /* ----------------------------------------------------------------- |
||
232 | | Other Methods |
||
233 | | ----------------------------------------------------------------- |
||
234 | */ |
||
235 | |||
236 | /** |
||
237 | * Set an attribute. |
||
238 | * |
||
239 | * @param string $key |
||
240 | * @param mixed $value |
||
241 | * |
||
242 | * @return self |
||
243 | */ |
||
244 | 80 | protected function set($key, $value) |
|
250 | |||
251 | /** |
||
252 | * Escape the given value. |
||
253 | * |
||
254 | * @param string $value |
||
255 | * |
||
256 | * @return string |
||
257 | */ |
||
258 | 56 | protected function escape($value) |
|
267 | |||
268 | /** |
||
269 | * Check the loc value. |
||
270 | * |
||
271 | * @param string $loc |
||
272 | * |
||
273 | * @return string |
||
274 | * |
||
275 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
276 | */ |
||
277 | 80 | protected function checkLoc($loc) |
|
284 | |||
285 | /** |
||
286 | * Check the priority value. |
||
287 | * |
||
288 | * @param float $priority |
||
289 | * |
||
290 | * @return float |
||
291 | * |
||
292 | * @throws \Arcanedev\LaravelSitemap\Exceptions\SitemapException |
||
293 | */ |
||
294 | 80 | protected function checkPriority($priority) |
|
306 | } |
||
307 |