1 | <?php namespace Arcanedev\SeoHelper; |
||
12 | class SeoMeta implements SeoMetaContract |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Traits |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | use Configurable; |
||
19 | |||
20 | /* ------------------------------------------------------------------------------------------------ |
||
21 | | Properties |
||
22 | | ------------------------------------------------------------------------------------------------ |
||
23 | */ |
||
24 | /** |
||
25 | * Current URL. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $currentUrl = ''; |
||
30 | |||
31 | /** |
||
32 | * The Title instance. |
||
33 | * |
||
34 | * @var \Arcanedev\SeoHelper\Contracts\Entities\TitleInterface |
||
35 | */ |
||
36 | protected $title; |
||
37 | |||
38 | /** |
||
39 | * The Description instance. |
||
40 | * |
||
41 | * @var \Arcanedev\SeoHelper\Contracts\Entities\DescriptionInterface |
||
42 | */ |
||
43 | protected $description; |
||
44 | |||
45 | /** |
||
46 | * The Keywords instance. |
||
47 | * |
||
48 | * @var \Arcanedev\SeoHelper\Contracts\Entities\KeywordsInterface |
||
49 | */ |
||
50 | protected $keywords; |
||
51 | |||
52 | /** |
||
53 | * The MiscTags instance. |
||
54 | * |
||
55 | * @var \Arcanedev\SeoHelper\Contracts\Entities\MiscTagsInterface |
||
56 | */ |
||
57 | protected $misc; |
||
58 | |||
59 | /** |
||
60 | * The Webmasters instance. |
||
61 | * |
||
62 | * @var \Arcanedev\SeoHelper\Contracts\Entities\WebmastersInterface |
||
63 | */ |
||
64 | protected $webmasters; |
||
65 | |||
66 | /** |
||
67 | * The Analytics instance. |
||
68 | * |
||
69 | * @var \Arcanedev\SeoHelper\Contracts\Entities\AnalyticsInterface |
||
70 | */ |
||
71 | protected $analytics; |
||
72 | |||
73 | /* ------------------------------------------------------------------------------------------------ |
||
74 | | Constructor |
||
75 | | ------------------------------------------------------------------------------------------------ |
||
76 | */ |
||
77 | /** |
||
78 | * Make SeoMeta instance. |
||
79 | * |
||
80 | * @param array $configs |
||
81 | */ |
||
82 | 324 | public function __construct(array $configs) |
|
87 | |||
88 | /** |
||
89 | * Start the engine. |
||
90 | */ |
||
91 | 324 | private function init() |
|
112 | |||
113 | /* ------------------------------------------------------------------------------------------------ |
||
114 | | Getters & Setters |
||
115 | | ------------------------------------------------------------------------------------------------ |
||
116 | */ |
||
117 | /** |
||
118 | * Set the Title instance. |
||
119 | * |
||
120 | * @param \Arcanedev\SeoHelper\Contracts\Entities\TitleInterface $title |
||
121 | * |
||
122 | * @return self |
||
123 | */ |
||
124 | 324 | public function title(Contracts\Entities\TitleInterface $title) |
|
130 | |||
131 | /** |
||
132 | * Set the Description instance. |
||
133 | * |
||
134 | * @param \Arcanedev\SeoHelper\Contracts\Entities\DescriptionInterface $description |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | 324 | public function description(Contracts\Entities\DescriptionInterface $description) { |
|
143 | |||
144 | /** |
||
145 | * Set the Keywords instance. |
||
146 | * |
||
147 | * @param \Arcanedev\SeoHelper\Contracts\Entities\KeywordsInterface $keywords |
||
148 | * |
||
149 | * @return self |
||
150 | */ |
||
151 | 324 | public function keywords(Contracts\Entities\KeywordsInterface $keywords) |
|
157 | |||
158 | /** |
||
159 | * Set the MiscTags instance. |
||
160 | * |
||
161 | * @param \Arcanedev\SeoHelper\Contracts\Entities\MiscTagsInterface $misc |
||
162 | * |
||
163 | * @return self |
||
164 | */ |
||
165 | 324 | public function misc(Contracts\Entities\MiscTagsInterface $misc) |
|
171 | |||
172 | /** |
||
173 | * Set the Webmasters instance. |
||
174 | * |
||
175 | * @param \Arcanedev\SeoHelper\Contracts\Entities\WebmastersInterface $webmasters |
||
176 | * |
||
177 | * @return self |
||
178 | */ |
||
179 | 324 | public function webmasters(Contracts\Entities\WebmastersInterface $webmasters) |
|
185 | |||
186 | /** |
||
187 | * Set the Analytics instance. |
||
188 | * |
||
189 | * @param \Arcanedev\SeoHelper\Contracts\Entities\AnalyticsInterface $analytics |
||
190 | * |
||
191 | * @return self |
||
192 | */ |
||
193 | 324 | private function analytics(Contracts\Entities\AnalyticsInterface $analytics) |
|
199 | |||
200 | /** |
||
201 | * Set the title. |
||
202 | * |
||
203 | * @param string $title |
||
204 | * @param string $siteName |
||
205 | * @param string $separator |
||
206 | * |
||
207 | * @return self |
||
208 | */ |
||
209 | 36 | public function setTitle($title, $siteName = null, $separator = null) |
|
223 | |||
224 | /** |
||
225 | * Set the description content. |
||
226 | * |
||
227 | * @param string $content |
||
228 | * |
||
229 | * @return self |
||
230 | */ |
||
231 | 36 | public function setDescription($content) |
|
237 | |||
238 | /** |
||
239 | * Set the keywords content. |
||
240 | * |
||
241 | * @param array|string $content |
||
242 | * |
||
243 | * @return self |
||
244 | */ |
||
245 | 60 | public function setKeywords($content) |
|
251 | |||
252 | /** |
||
253 | * Add a keyword. |
||
254 | * |
||
255 | * @param string $keyword |
||
256 | * |
||
257 | * @return self |
||
258 | */ |
||
259 | 12 | public function addKeyword($keyword) |
|
265 | |||
266 | /** |
||
267 | * Add many keywords. |
||
268 | * |
||
269 | * @param array $keywords |
||
270 | * |
||
271 | * @return self |
||
272 | */ |
||
273 | 12 | public function addKeywords(array $keywords) |
|
279 | |||
280 | /** |
||
281 | * Add a webmaster tool site verifier. |
||
282 | * |
||
283 | * @param string $webmaster |
||
284 | * @param string $content |
||
285 | * |
||
286 | * @return self |
||
287 | */ |
||
288 | 12 | public function addWebmaster($webmaster, $content) |
|
294 | |||
295 | /** |
||
296 | * Set the current URL. |
||
297 | * |
||
298 | * @param string $url |
||
299 | * |
||
300 | * @return self |
||
301 | */ |
||
302 | 120 | public function setUrl($url) |
|
309 | |||
310 | /** |
||
311 | * Set the Google Analytics code. |
||
312 | * |
||
313 | * @param string $code |
||
314 | * |
||
315 | * @return self |
||
316 | */ |
||
317 | 12 | public function setGoogleAnalytics($code) |
|
323 | |||
324 | /* ------------------------------------------------------------------------------------------------ |
||
325 | | Main Functions |
||
326 | | ------------------------------------------------------------------------------------------------ |
||
327 | */ |
||
328 | /** |
||
329 | * Add a meta tag. |
||
330 | * |
||
331 | * @param string $name |
||
332 | * @param string $content |
||
333 | * |
||
334 | * @return self |
||
335 | */ |
||
336 | 12 | public function addMeta($name, $content) |
|
342 | |||
343 | /** |
||
344 | * Add many meta tags. |
||
345 | * |
||
346 | * @param array $metas |
||
347 | * |
||
348 | * @return self |
||
349 | */ |
||
350 | 12 | public function addMetas(array $metas) |
|
356 | |||
357 | /** |
||
358 | * Remove a meta from the meta collection by key. |
||
359 | * |
||
360 | * @param string|array $names |
||
361 | * |
||
362 | * @return self |
||
363 | */ |
||
364 | 12 | public function removeMeta($names) |
|
370 | |||
371 | /** |
||
372 | * Reset the meta collection except the description and keywords metas. |
||
373 | * |
||
374 | * @return self |
||
375 | */ |
||
376 | 12 | public function resetMetas() |
|
382 | |||
383 | /** |
||
384 | * Reset all webmaster tool site verifier metas. |
||
385 | * |
||
386 | * @return self |
||
387 | */ |
||
388 | 12 | public function resetWebmasters() |
|
394 | |||
395 | /** |
||
396 | * Render all seo tags. |
||
397 | * |
||
398 | * @return string |
||
399 | */ |
||
400 | 228 | public function render() |
|
411 | |||
412 | /** |
||
413 | * Render all seo tags. |
||
414 | * |
||
415 | * @return string |
||
416 | */ |
||
417 | 96 | public function __toString() |
|
421 | } |
||
422 |