1 | <?php namespace Arcanedev\SeoHelper; |
||
18 | class SeoMeta implements SeoMetaContract |
||
19 | { |
||
20 | /* ----------------------------------------------------------------- |
||
21 | | Traits |
||
22 | | ----------------------------------------------------------------- |
||
23 | */ |
||
24 | use Configurable; |
||
25 | |||
26 | /* ----------------------------------------------------------------- |
||
27 | | Properties |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | /** |
||
31 | * Current URL. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $currentUrl = ''; |
||
36 | |||
37 | /** |
||
38 | * The Title instance. |
||
39 | * |
||
40 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Title |
||
41 | */ |
||
42 | protected $title; |
||
43 | |||
44 | /** |
||
45 | * The Description instance. |
||
46 | * |
||
47 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Description |
||
48 | */ |
||
49 | protected $description; |
||
50 | |||
51 | /** |
||
52 | * The Keywords instance. |
||
53 | * |
||
54 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Keywords |
||
55 | */ |
||
56 | protected $keywords; |
||
57 | |||
58 | /** |
||
59 | * The MiscTags instance. |
||
60 | * |
||
61 | * @var \Arcanedev\SeoHelper\Contracts\Entities\MiscTags |
||
62 | */ |
||
63 | protected $misc; |
||
64 | |||
65 | /** |
||
66 | * The Webmasters instance. |
||
67 | * |
||
68 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Webmasters |
||
69 | */ |
||
70 | protected $webmasters; |
||
71 | |||
72 | /** |
||
73 | * The Analytics instance. |
||
74 | * |
||
75 | * @var \Arcanedev\SeoHelper\Contracts\Entities\Analytics |
||
76 | */ |
||
77 | protected $analytics; |
||
78 | |||
79 | /* ----------------------------------------------------------------- |
||
80 | | Constructor |
||
81 | | ----------------------------------------------------------------- |
||
82 | */ |
||
83 | /** |
||
84 | * Make SeoMeta instance. |
||
85 | * |
||
86 | * @param array $configs |
||
87 | */ |
||
88 | 93 | public function __construct(array $configs) |
|
93 | |||
94 | /** |
||
95 | * Start the engine. |
||
96 | */ |
||
97 | 93 | private function init() |
|
118 | |||
119 | /* ----------------------------------------------------------------- |
||
120 | | Getters & Setters |
||
121 | | ----------------------------------------------------------------- |
||
122 | */ |
||
123 | /** |
||
124 | * Set the Title instance. |
||
125 | * |
||
126 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Title $title |
||
127 | * |
||
128 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
129 | */ |
||
130 | 93 | public function title(TitleContract $title) |
|
136 | |||
137 | /** |
||
138 | * Set the Description instance. |
||
139 | * |
||
140 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Description $description |
||
141 | * |
||
142 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
143 | */ |
||
144 | 93 | public function description(DescriptionContract $description) { |
|
149 | |||
150 | /** |
||
151 | * Set the Keywords instance. |
||
152 | * |
||
153 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Keywords $keywords |
||
154 | * |
||
155 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
156 | */ |
||
157 | 93 | public function keywords(KeywordsContract $keywords) |
|
163 | |||
164 | /** |
||
165 | * Set the MiscTags instance. |
||
166 | * |
||
167 | * @param \Arcanedev\SeoHelper\Contracts\Entities\MiscTags $misc |
||
168 | * |
||
169 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
170 | */ |
||
171 | 93 | public function misc(MiscTagsContract $misc) |
|
177 | |||
178 | /** |
||
179 | * Set the Webmasters instance. |
||
180 | * |
||
181 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Webmasters $webmasters |
||
182 | * |
||
183 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
184 | */ |
||
185 | 93 | public function webmasters(WebmastersContract $webmasters) |
|
191 | |||
192 | /** |
||
193 | * Set the Analytics instance. |
||
194 | * |
||
195 | * @param \Arcanedev\SeoHelper\Contracts\Entities\Analytics $analytics |
||
196 | * |
||
197 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
198 | */ |
||
199 | 93 | private function analytics(AnalyticsContract $analytics) |
|
205 | |||
206 | /** |
||
207 | * Set the title. |
||
208 | * |
||
209 | * @param string $title |
||
210 | * @param string $siteName |
||
211 | * @param string $separator |
||
212 | * |
||
213 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
214 | */ |
||
215 | 15 | public function setTitle($title, $siteName = null, $separator = null) |
|
222 | |||
223 | /** |
||
224 | * Set the site name. |
||
225 | * |
||
226 | * @param string $siteName |
||
227 | * |
||
228 | * @return self |
||
229 | */ |
||
230 | 15 | public function setSiteName($siteName) |
|
236 | |||
237 | /** |
||
238 | * Hide site name. |
||
239 | * |
||
240 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
241 | */ |
||
242 | 3 | public function hideSiteName() |
|
248 | |||
249 | /** |
||
250 | * Show site name. |
||
251 | * |
||
252 | * @return self |
||
253 | */ |
||
254 | 3 | public function showSiteName() |
|
260 | |||
261 | /** |
||
262 | * Set the description content. |
||
263 | * |
||
264 | * @param string $content |
||
265 | * |
||
266 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
267 | */ |
||
268 | 9 | public function setDescription($content) |
|
274 | |||
275 | /** |
||
276 | * Set the keywords content. |
||
277 | * |
||
278 | * @param array|string $content |
||
279 | * |
||
280 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
281 | */ |
||
282 | 15 | public function setKeywords($content) |
|
288 | |||
289 | /** |
||
290 | * Add a keyword. |
||
291 | * |
||
292 | * @param string $keyword |
||
293 | * |
||
294 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
295 | */ |
||
296 | 3 | public function addKeyword($keyword) |
|
302 | |||
303 | /** |
||
304 | * Add many keywords. |
||
305 | * |
||
306 | * @param array $keywords |
||
307 | * |
||
308 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
309 | */ |
||
310 | 3 | public function addKeywords(array $keywords) |
|
316 | |||
317 | /** |
||
318 | * Add a webmaster tool site verifier. |
||
319 | * |
||
320 | * @param string $webmaster |
||
321 | * @param string $content |
||
322 | * |
||
323 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
324 | */ |
||
325 | 3 | public function addWebmaster($webmaster, $content) |
|
331 | |||
332 | /** |
||
333 | * Set the current URL. |
||
334 | * |
||
335 | * @param string $url |
||
336 | * |
||
337 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
338 | */ |
||
339 | 30 | public function setUrl($url) |
|
346 | |||
347 | /** |
||
348 | * Set the Google Analytics code. |
||
349 | * |
||
350 | * @param string $code |
||
351 | * |
||
352 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
353 | */ |
||
354 | 3 | public function setGoogleAnalytics($code) |
|
360 | |||
361 | /* ----------------------------------------------------------------- |
||
362 | | Main Methods |
||
363 | | ----------------------------------------------------------------- |
||
364 | */ |
||
365 | /** |
||
366 | * Add a meta tag. |
||
367 | * |
||
368 | * @param string $name |
||
369 | * @param string $content |
||
370 | * |
||
371 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
372 | */ |
||
373 | 3 | public function addMeta($name, $content) |
|
379 | |||
380 | /** |
||
381 | * Add many meta tags. |
||
382 | * |
||
383 | * @param array $metas |
||
384 | * |
||
385 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
386 | */ |
||
387 | 3 | public function addMetas(array $metas) |
|
393 | |||
394 | /** |
||
395 | * Remove a meta from the meta collection by key. |
||
396 | * |
||
397 | * @param string|array $names |
||
398 | * |
||
399 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
400 | */ |
||
401 | 3 | public function removeMeta($names) |
|
407 | |||
408 | /** |
||
409 | * Reset the meta collection except the description and keywords metas. |
||
410 | * |
||
411 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
412 | */ |
||
413 | 3 | public function resetMetas() |
|
419 | |||
420 | /** |
||
421 | * Reset all webmaster tool site verifier metas. |
||
422 | * |
||
423 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
424 | */ |
||
425 | 3 | public function resetWebmasters() |
|
431 | |||
432 | /** |
||
433 | * Render all seo tags. |
||
434 | * |
||
435 | * @return string |
||
436 | */ |
||
437 | 69 | public function render() |
|
448 | |||
449 | /** |
||
450 | * Render all seo tags. |
||
451 | * |
||
452 | * @return string |
||
453 | */ |
||
454 | 24 | public function __toString() |
|
458 | } |
||
459 |