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 | 224 | public function __construct(array $configs) |
|
93 | |||
94 | /** |
||
95 | * Start the engine. |
||
96 | */ |
||
97 | 224 | 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 | 224 | 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 | 224 | 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 | 224 | 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 | 224 | 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 | 224 | 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 | 224 | 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 | 32 | 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 | 32 | public function setSiteName($siteName) |
|
236 | |||
237 | /** |
||
238 | * Set the description content. |
||
239 | * |
||
240 | * @param string $content |
||
241 | * |
||
242 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
243 | */ |
||
244 | 24 | public function setDescription($content) |
|
250 | |||
251 | /** |
||
252 | * Set the keywords content. |
||
253 | * |
||
254 | * @param array|string $content |
||
255 | * |
||
256 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
257 | */ |
||
258 | 40 | public function setKeywords($content) |
|
264 | |||
265 | /** |
||
266 | * Add a keyword. |
||
267 | * |
||
268 | * @param string $keyword |
||
269 | * |
||
270 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
271 | */ |
||
272 | 8 | public function addKeyword($keyword) |
|
278 | |||
279 | /** |
||
280 | * Add many keywords. |
||
281 | * |
||
282 | * @param array $keywords |
||
283 | * |
||
284 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
285 | */ |
||
286 | 8 | public function addKeywords(array $keywords) |
|
292 | |||
293 | /** |
||
294 | * Add a webmaster tool site verifier. |
||
295 | * |
||
296 | * @param string $webmaster |
||
297 | * @param string $content |
||
298 | * |
||
299 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
300 | */ |
||
301 | 8 | public function addWebmaster($webmaster, $content) |
|
307 | |||
308 | /** |
||
309 | * Set the current URL. |
||
310 | * |
||
311 | * @param string $url |
||
312 | * |
||
313 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
314 | */ |
||
315 | 80 | public function setUrl($url) |
|
322 | |||
323 | /** |
||
324 | * Set the Google Analytics code. |
||
325 | * |
||
326 | * @param string $code |
||
327 | * |
||
328 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
329 | */ |
||
330 | 8 | public function setGoogleAnalytics($code) |
|
336 | |||
337 | /* ------------------------------------------------------------------------------------------------ |
||
338 | | Main Functions |
||
339 | | ------------------------------------------------------------------------------------------------ |
||
340 | */ |
||
341 | /** |
||
342 | * Add a meta tag. |
||
343 | * |
||
344 | * @param string $name |
||
345 | * @param string $content |
||
346 | * |
||
347 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
348 | */ |
||
349 | 8 | public function addMeta($name, $content) |
|
355 | |||
356 | /** |
||
357 | * Add many meta tags. |
||
358 | * |
||
359 | * @param array $metas |
||
360 | * |
||
361 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
362 | */ |
||
363 | 8 | public function addMetas(array $metas) |
|
369 | |||
370 | /** |
||
371 | * Remove a meta from the meta collection by key. |
||
372 | * |
||
373 | * @param string|array $names |
||
374 | * |
||
375 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
376 | */ |
||
377 | 8 | public function removeMeta($names) |
|
383 | |||
384 | /** |
||
385 | * Reset the meta collection except the description and keywords metas. |
||
386 | * |
||
387 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
388 | */ |
||
389 | 8 | public function resetMetas() |
|
395 | |||
396 | /** |
||
397 | * Reset all webmaster tool site verifier metas. |
||
398 | * |
||
399 | * @return \Arcanedev\SeoHelper\SeoMeta |
||
400 | */ |
||
401 | 8 | public function resetWebmasters() |
|
407 | |||
408 | /** |
||
409 | * Render all seo tags. |
||
410 | * |
||
411 | * @return string |
||
412 | */ |
||
413 | 160 | public function render() |
|
424 | |||
425 | /** |
||
426 | * Render all seo tags. |
||
427 | * |
||
428 | * @return string |
||
429 | */ |
||
430 | 64 | public function __toString() |
|
434 | } |
||
435 |