1 | <?php namespace Arcanedev\SeoHelper; |
||
14 | class SeoHelper implements SeoHelperContract |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | /** |
||
21 | * The SeoMeta instance. |
||
22 | * |
||
23 | * @var \Arcanedev\SeoHelper\Contracts\SeoMeta |
||
24 | */ |
||
25 | private $seoMeta; |
||
26 | |||
27 | /** |
||
28 | * The SeoOpenGraph instance. |
||
29 | * |
||
30 | * @var \Arcanedev\SeoHelper\Contracts\SeoOpenGraph |
||
31 | */ |
||
32 | private $seoOpenGraph; |
||
33 | |||
34 | /** |
||
35 | * The SeoTwitter instance. |
||
36 | * |
||
37 | * @var \Arcanedev\SeoHelper\Contracts\SeoTwitter |
||
38 | */ |
||
39 | private $seoTwitter; |
||
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Constructor |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | /** |
||
46 | * Make SeoHelper instance. |
||
47 | * |
||
48 | * @param \Arcanedev\SeoHelper\Contracts\SeoMeta $seoMeta |
||
49 | * @param \Arcanedev\SeoHelper\Contracts\SeoOpenGraph $seoOpenGraph |
||
50 | * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter |
||
51 | */ |
||
52 | 63 | public function __construct( |
|
53 | SeoMetaContract $seoMeta, |
||
54 | SeoOpenGraphContract $seoOpenGraph, |
||
55 | SeoTwitterContract $seoTwitter |
||
56 | ) { |
||
57 | 63 | $this->setSeoMeta($seoMeta); |
|
58 | 63 | $this->setSeoOpenGraph($seoOpenGraph); |
|
59 | 63 | $this->setSeoTwitter($seoTwitter); |
|
60 | 63 | } |
|
61 | |||
62 | /* ----------------------------------------------------------------- |
||
63 | | Getters & Setters |
||
64 | | ----------------------------------------------------------------- |
||
65 | */ |
||
66 | /** |
||
67 | * Get SeoMeta instance. |
||
68 | * |
||
69 | * @return \Arcanedev\SeoHelper\Contracts\SeoMeta |
||
70 | */ |
||
71 | 45 | public function meta() |
|
75 | |||
76 | /** |
||
77 | * Set SeoMeta instance. |
||
78 | * |
||
79 | * @param \Arcanedev\SeoHelper\Contracts\SeoMeta $seoMeta |
||
80 | * |
||
81 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
82 | */ |
||
83 | 63 | public function setSeoMeta(SeoMetaContract $seoMeta) |
|
89 | |||
90 | /** |
||
91 | * Get SeoOpenGraph instance. |
||
92 | * |
||
93 | * @return \Arcanedev\SeoHelper\Contracts\SeoOpenGraph |
||
94 | */ |
||
95 | 45 | public function openGraph() |
|
99 | |||
100 | /** |
||
101 | * Get SeoOpenGraph instance (alias). |
||
102 | * |
||
103 | * @see openGraph() |
||
104 | * |
||
105 | * @return \Arcanedev\SeoHelper\Contracts\SeoOpenGraph |
||
106 | */ |
||
107 | 3 | public function og() |
|
111 | |||
112 | /** |
||
113 | * Get SeoOpenGraph instance. |
||
114 | * |
||
115 | * @param \Arcanedev\SeoHelper\Contracts\SeoOpenGraph $seoOpenGraph |
||
116 | * |
||
117 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
118 | */ |
||
119 | 63 | public function setSeoOpenGraph(SeoOpenGraphContract $seoOpenGraph) |
|
125 | |||
126 | /** |
||
127 | * Get SeoTwitter instance. |
||
128 | * |
||
129 | * @return \Arcanedev\SeoHelper\Contracts\SeoTwitter |
||
130 | */ |
||
131 | 42 | public function twitter() |
|
135 | |||
136 | /** |
||
137 | * Set SeoTwitter instance. |
||
138 | * |
||
139 | * @param \Arcanedev\SeoHelper\Contracts\SeoTwitter $seoTwitter |
||
140 | * |
||
141 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
142 | */ |
||
143 | 63 | public function setSeoTwitter(SeoTwitterContract $seoTwitter) |
|
149 | |||
150 | /** |
||
151 | * Set title. |
||
152 | * |
||
153 | * @param string $title |
||
154 | * @param string|null $siteName |
||
155 | * @param string|null $separator |
||
156 | * |
||
157 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
158 | */ |
||
159 | 12 | public function setTitle($title, $siteName = null, $separator = null) |
|
167 | |||
168 | /** |
||
169 | * Set the site name. |
||
170 | * |
||
171 | * @param string $siteName |
||
172 | * |
||
173 | * @return self |
||
174 | */ |
||
175 | 12 | public function setSiteName($siteName) |
|
182 | |||
183 | /** |
||
184 | * Hide the site name. |
||
185 | * |
||
186 | * @return self |
||
187 | */ |
||
188 | 3 | public function hideSiteName() |
|
194 | |||
195 | /** |
||
196 | * Show the site name. |
||
197 | * |
||
198 | * @return self |
||
199 | */ |
||
200 | 3 | public function showSiteName() |
|
206 | |||
207 | /** |
||
208 | * Set description. |
||
209 | * |
||
210 | * @param string $description |
||
211 | * |
||
212 | * @return \Arcanedev\SeoHelper\Contracts\SeoHelper |
||
213 | */ |
||
214 | 6 | public function setDescription($description) |
|
222 | |||
223 | /** |
||
224 | * Set keywords. |
||
225 | * |
||
226 | * @param array|string $keywords |
||
227 | * |
||
228 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
229 | */ |
||
230 | 6 | public function setKeywords($keywords) |
|
236 | |||
237 | /** |
||
238 | * Set Image. |
||
239 | * |
||
240 | * @param string $imageUrl |
||
241 | * |
||
242 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
243 | */ |
||
244 | 3 | public function setImage($imageUrl) |
|
251 | |||
252 | /* ----------------------------------------------------------------- |
||
253 | | Main Methods |
||
254 | | ----------------------------------------------------------------- |
||
255 | */ |
||
256 | /** |
||
257 | * Render all seo tags. |
||
258 | * |
||
259 | * @return string |
||
260 | */ |
||
261 | 39 | public function render() |
|
269 | |||
270 | /** |
||
271 | * Render all seo tags with HtmlString object. |
||
272 | * |
||
273 | * @return \Illuminate\Support\HtmlString |
||
274 | */ |
||
275 | 3 | public function renderHtml() |
|
281 | |||
282 | /** |
||
283 | * Render the tag. |
||
284 | * |
||
285 | * @return string |
||
286 | */ |
||
287 | 21 | public function __toString() |
|
291 | |||
292 | /** |
||
293 | * Enable the OpenGraph. |
||
294 | * |
||
295 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
296 | */ |
||
297 | 3 | public function enableOpenGraph() |
|
303 | |||
304 | /** |
||
305 | * Disable the OpenGraph. |
||
306 | * |
||
307 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
308 | */ |
||
309 | 3 | public function disableOpenGraph() |
|
315 | |||
316 | /** |
||
317 | * Enable the Twitter Card. |
||
318 | * |
||
319 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
320 | */ |
||
321 | 3 | public function enableTwitter() |
|
327 | |||
328 | /** |
||
329 | * Disable the Twitter Card. |
||
330 | * |
||
331 | * @return \Arcanedev\SeoHelper\SeoHelper |
||
332 | */ |
||
333 | 3 | public function disableTwitter() |
|
339 | } |
||
340 |