1 | <?php namespace Arcanedev\SeoHelper; |
||
18 | class SeoMeta implements SeoMetaContract |
||
19 | { |
||
20 | /* ----------------------------------------------------------------- |
||
21 | | Traits |
||
22 | | ----------------------------------------------------------------- |
||
23 | */ |
||
24 | |||
25 | use Configurable; |
||
26 | |||
27 | /* ----------------------------------------------------------------- |
||
28 | | Properties |
||
29 | | ----------------------------------------------------------------- |
||
30 | */ |
||
31 | |||
32 | /** |
||
33 | * Current URL. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $currentUrl = ''; |
||
38 | |||
39 | /** |
||
40 | * The Title instance. |
||
41 | * |
||
42 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Title |
||
43 | */ |
||
44 | protected $title; |
||
45 | |||
46 | /** |
||
47 | * The Description instance. |
||
48 | * |
||
49 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Description |
||
50 | */ |
||
51 | protected $description; |
||
52 | |||
53 | /** |
||
54 | * The Keywords instance. |
||
55 | * |
||
56 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Keywords |
||
57 | */ |
||
58 | protected $keywords; |
||
59 | |||
60 | /** |
||
61 | * The MiscTags instance. |
||
62 | * |
||
63 | * @var \Arcanedev\SeoHelper\Contracts\Entities\MiscTags |
||
64 | */ |
||
65 | protected $misc; |
||
66 | |||
67 | /** |
||
68 | * The Webmasters instance. |
||
69 | * |
||
70 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Webmasters |
||
71 | */ |
||
72 | protected $webmasters; |
||
73 | |||
74 | /** |
||
75 | * The Analytics instance. |
||
76 | * |
||
77 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Analytics |
||
78 | */ |
||
79 | protected $analytics; |
||
80 | |||
81 | /* ----------------------------------------------------------------- |
||
82 | | Constructor |
||
83 | | ----------------------------------------------------------------- |
||
84 | */ |
||
85 | |||
86 | /** |
||
87 | * Make SeoMeta instance. |
||
88 | * |
||
89 | * @param array $configs |
||
90 | */ |
||
91 | 93 | public function __construct(array $configs) |
|
96 | |||
97 | /** |
||
98 | * Start the engine. |
||
99 | */ |
||
100 | 93 | private function init() |
|
121 | |||
122 | /* ----------------------------------------------------------------- |
||
123 | | Getters & Setters |
||
124 | | ----------------------------------------------------------------- |
||
125 | */ |
||
126 | |||
127 | /** |
||
128 | * Set the Title instance. |
||
129 | * |
||
130 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Title $title |
||
131 | * |
||
132 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
133 | */ |
||
134 | 93 | public function title(TitleContract $title) |
|
140 | |||
141 | /** |
||
142 | * Get the Title instance. |
||
143 | * |
||
144 | * @return \Arcanedev\SeoHelper\Contracts\Entities\Title |
||
145 | */ |
||
146 | 3 | public function getTitleEntity() |
|
150 | |||
151 | /** |
||
152 | * Set the Description instance. |
||
153 | * |
||
154 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Description $description |
||
155 | * |
||
156 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
157 | */ |
||
158 | 93 | public function description(DescriptionContract $description) |
|
164 | |||
165 | /** |
||
166 | * Get the Description instance. |
||
167 | * |
||
168 | * @return \Arcanedev\SeoHelper\Contracts\Entities\Description |
||
169 | */ |
||
170 | 3 | public function getDescriptionEntity() |
|
174 | |||
175 | /** |
||
176 | * Set the Keywords instance. |
||
177 | * |
||
178 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Keywords $keywords |
||
179 | * |
||
180 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
181 | */ |
||
182 | 93 | public function keywords(KeywordsContract $keywords) |
|
188 | |||
189 | /** |
||
190 | * Get the Keywords instance. |
||
191 | * |
||
192 | * @return \Arcanedev\SeoHelper\Contracts\Entities\Keywords |
||
193 | */ |
||
194 | 3 | public function getKeywordsEntity() |
|
198 | |||
199 | /** |
||
200 | * Set the MiscTags instance. |
||
201 | * |
||
202 | * @param \Arcanedev\SeoHelper\Contracts\Entities\MiscTags $misc |
||
203 | * |
||
204 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
205 | */ |
||
206 | 93 | public function misc(MiscTagsContract $misc) |
|
212 | |||
213 | /** |
||
214 | * Get the MiscTags instance. |
||
215 | * |
||
216 | * @return \Arcanedev\SeoHelper\Contracts\Entities\MiscTags |
||
217 | */ |
||
218 | 3 | public function getMiscEntity() |
|
222 | |||
223 | /** |
||
224 | * Set the Webmasters instance. |
||
225 | * |
||
226 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Webmasters $webmasters |
||
227 | * |
||
228 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
229 | */ |
||
230 | 93 | public function webmasters(WebmastersContract $webmasters) |
|
236 | |||
237 | /** |
||
238 | * Get the Webmasters instance. |
||
239 | * |
||
240 | * @return \Arcanedev\SeoHelper\Contracts\Entities\Webmasters |
||
241 | */ |
||
242 | 3 | public function getWebmastersEntity() |
|
246 | |||
247 | /** |
||
248 | * Set the Analytics instance. |
||
249 | * |
||
250 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Analytics $analytics |
||
251 | * |
||
252 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
253 | */ |
||
254 | 93 | public function analytics(AnalyticsContract $analytics) |
|
260 | |||
261 | /** |
||
262 | * Get the Analytics instance. |
||
263 | * |
||
264 | * @return \Arcanedev\SeoHelper\Contracts\Entities\Analytics |
||
265 | */ |
||
266 | 3 | public function getAnalyticsEntity() |
|
270 | |||
271 | /** |
||
272 | * Set the title. |
||
273 | * |
||
274 | * @param string $title |
||
275 | * @param string $siteName |
||
276 | * @param string $separator |
||
277 | * |
||
278 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
279 | */ |
||
280 | 15 | public function setTitle($title, $siteName = null, $separator = null) |
|
286 | |||
287 | /** |
||
288 | * Set the site name. |
||
289 | * |
||
290 | * @param string $siteName |
||
291 | * |
||
292 | * @return self |
||
293 | */ |
||
294 | 15 | public function setSiteName($siteName) |
|
300 | |||
301 | /** |
||
302 | * Hide site name. |
||
303 | * |
||
304 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
305 | */ |
||
306 | 3 | public function hideSiteName() |
|
312 | |||
313 | /** |
||
314 | * Show site name. |
||
315 | * |
||
316 | * @return self |
||
317 | */ |
||
318 | 3 | public function showSiteName() |
|
324 | |||
325 | /** |
||
326 | * Set the description content. |
||
327 | * |
||
328 | * @param string $content |
||
329 | * |
||
330 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
331 | */ |
||
332 | 9 | public function setDescription($content) |
|
338 | |||
339 | /** |
||
340 | * Set the keywords content. |
||
341 | * |
||
342 | * @param array|string $content |
||
343 | * |
||
344 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
345 | */ |
||
346 | 15 | public function setKeywords($content) |
|
352 | |||
353 | /** |
||
354 | * Add a keyword. |
||
355 | * |
||
356 | * @param string $keyword |
||
357 | * |
||
358 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
359 | */ |
||
360 | 3 | public function addKeyword($keyword) |
|
366 | |||
367 | /** |
||
368 | * Add many keywords. |
||
369 | * |
||
370 | * @param array $keywords |
||
371 | * |
||
372 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
373 | */ |
||
374 | 3 | public function addKeywords(array $keywords) |
|
380 | |||
381 | /** |
||
382 | * Add a webmaster tool site verifier. |
||
383 | * |
||
384 | * @param string $webmaster |
||
385 | * @param string $content |
||
386 | * |
||
387 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
388 | */ |
||
389 | 3 | public function addWebmaster($webmaster, $content) |
|
395 | |||
396 | /** |
||
397 | * Set the current URL. |
||
398 | * |
||
399 | * @param string $url |
||
400 | * |
||
401 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
402 | */ |
||
403 | 30 | public function setUrl($url) |
|
410 | |||
411 | /** |
||
412 | * Set the Google Analytics code. |
||
413 | * |
||
414 | * @param string $code |
||
415 | * |
||
416 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
417 | */ |
||
418 | 3 | public function setGoogleAnalytics($code) |
|
424 | |||
425 | /* ----------------------------------------------------------------- |
||
426 | | Main Methods |
||
427 | | ----------------------------------------------------------------- |
||
428 | */ |
||
429 | |||
430 | /** |
||
431 | * Add a meta tag. |
||
432 | * |
||
433 | * @param string $name |
||
434 | * @param string $content |
||
435 | * |
||
436 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
437 | */ |
||
438 | 3 | public function addMeta($name, $content) |
|
444 | |||
445 | /** |
||
446 | * Add many meta tags. |
||
447 | * |
||
448 | * @param array $metas |
||
449 | * |
||
450 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
451 | */ |
||
452 | 3 | public function addMetas(array $metas) |
|
458 | |||
459 | /** |
||
460 | * Remove a meta from the meta collection by key. |
||
461 | * |
||
462 | * @param string|array $names |
||
463 | * |
||
464 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
465 | */ |
||
466 | 3 | public function removeMeta($names) |
|
472 | |||
473 | /** |
||
474 | * Reset the meta collection except the description and keywords metas. |
||
475 | * |
||
476 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
477 | */ |
||
478 | 3 | public function resetMetas() |
|
484 | |||
485 | /** |
||
486 | * Reset all webmaster tool site verifier metas. |
||
487 | * |
||
488 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
489 | */ |
||
490 | 3 | public function resetWebmasters() |
|
496 | |||
497 | /** |
||
498 | * Render all seo tags. |
||
499 | * |
||
500 | * @return string |
||
501 | */ |
||
502 | 69 | public function render() |
|
513 | |||
514 | /** |
||
515 | * Render all seo tags. |
||
516 | * |
||
517 | * @return string |
||
518 | */ |
||
519 | 24 | public function __toString() |
|
523 | } |
||
524 |