1 | <?php namespace Arcanedev\SeoHelper; |
||
9 | class SeoHelper implements Contracts\SeoHelper |
||
10 | { |
||
11 | /* ------------------------------------------------------------------------------------------------ |
||
12 | | Properties |
||
13 | | ------------------------------------------------------------------------------------------------ |
||
14 | */ |
||
15 | /** |
||
16 | * The SeoMeta instance. |
||
17 | * |
||
18 | * @var Contracts\SeoMeta |
||
19 | */ |
||
20 | private $seoMeta; |
||
21 | |||
22 | /** |
||
23 | * The SeoOpenGraph instance. |
||
24 | * |
||
25 | * @var Contracts\SeoOpenGraph |
||
26 | */ |
||
27 | private $seoOpenGraph; |
||
28 | |||
29 | /** |
||
30 | * The SeoTwitter instance. |
||
31 | * |
||
32 | * @var Contracts\SeoTwitter |
||
33 | */ |
||
34 | private $seoTwitter; |
||
35 | |||
36 | /* ------------------------------------------------------------------------------------------------ |
||
37 | | Constructor |
||
38 | | ------------------------------------------------------------------------------------------------ |
||
39 | */ |
||
40 | /** |
||
41 | * Make SeoHelper instance. |
||
42 | * |
||
43 | * @param Contracts\SeoMeta $seoMeta |
||
44 | * @param Contracts\SeoOpenGraph $seoOpenGraph |
||
45 | * @param Contracts\SeoTwitter $seoTwitter |
||
46 | */ |
||
47 | 51 | public function __construct( |
|
56 | |||
57 | /* ------------------------------------------------------------------------------------------------ |
||
58 | | Getters & Setters |
||
59 | | ------------------------------------------------------------------------------------------------ |
||
60 | */ |
||
61 | /** |
||
62 | * Get SeoMeta instance. |
||
63 | * |
||
64 | * @return Contracts\SeoMeta |
||
65 | */ |
||
66 | 33 | public function meta() |
|
70 | |||
71 | /** |
||
72 | * Set SeoMeta instance. |
||
73 | * |
||
74 | * @param Contracts\SeoMeta $seoMeta |
||
75 | * |
||
76 | * @return self |
||
77 | */ |
||
78 | 51 | public function setSeoMeta(Contracts\SeoMeta $seoMeta) |
|
84 | |||
85 | /** |
||
86 | * Get SeoOpenGraph instance. |
||
87 | * |
||
88 | * @return Contracts\SeoOpenGraph |
||
89 | */ |
||
90 | 33 | public function openGraph() |
|
94 | |||
95 | /** |
||
96 | * Get SeoOpenGraph instance (alias). |
||
97 | * |
||
98 | * @see \Arcanedev\SeoHelper\SeoHelper::openGraph() |
||
99 | * |
||
100 | * @return Contracts\SeoOpenGraph |
||
101 | */ |
||
102 | 3 | public function og() |
|
106 | |||
107 | /** |
||
108 | * Get SeoOpenGraph instance. |
||
109 | * |
||
110 | * @param Contracts\SeoOpenGraph $seoOpenGraph |
||
111 | * |
||
112 | * @return self |
||
113 | */ |
||
114 | 51 | public function setSeoOpenGraph(Contracts\SeoOpenGraph $seoOpenGraph) |
|
120 | |||
121 | /** |
||
122 | * Get SeoTwitter instance. |
||
123 | * |
||
124 | * @return Contracts\SeoTwitter |
||
125 | */ |
||
126 | 30 | public function twitter() |
|
130 | |||
131 | /** |
||
132 | * Set SeoTwitter instance. |
||
133 | * |
||
134 | * @param Contracts\SeoTwitter $seoTwitter |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | 51 | public function setSeoTwitter(Contracts\SeoTwitter $seoTwitter) |
|
144 | |||
145 | /** |
||
146 | * Set title. |
||
147 | * |
||
148 | * @param string $title |
||
149 | * @param string|null $siteName |
||
150 | * @param string|null $separator |
||
151 | * |
||
152 | * @return self |
||
153 | */ |
||
154 | 6 | public function setTitle($title, $siteName = null, $separator = null) |
|
155 | { |
||
156 | 6 | $this->meta()->setTitle($title, $siteName, $separator); |
|
157 | 6 | $this->openGraph()->setTitle($title); |
|
158 | 6 | $this->openGraph()->setSiteName($siteName); |
|
159 | 6 | $this->twitter()->setTitle($title); |
|
160 | |||
161 | 6 | return $this; |
|
162 | } |
||
163 | |||
164 | /** |
||
165 | * Set description. |
||
166 | * |
||
167 | * @param string $description |
||
168 | * |
||
169 | * @return \Arcanedev\SeoHelper\Contracts\SeoHelper |
||
170 | */ |
||
171 | 6 | public function setDescription($description) |
|
172 | { |
||
173 | 6 | $this->meta()->setDescription($description); |
|
174 | 6 | $this->openGraph()->setDescription($description); |
|
175 | 6 | $this->twitter()->setDescription($description); |
|
176 | |||
177 | 6 | return $this; |
|
178 | } |
||
179 | |||
180 | /** |
||
181 | * Set keywords. |
||
182 | * |
||
183 | * @param array|string $keywords |
||
184 | * |
||
185 | * @return self |
||
186 | */ |
||
187 | 6 | public function setKeywords($keywords) |
|
188 | { |
||
189 | 6 | $this->meta()->setKeywords($keywords); |
|
190 | |||
191 | 6 | return $this; |
|
192 | } |
||
193 | |||
194 | /* ------------------------------------------------------------------------------------------------ |
||
195 | | Main Functions |
||
196 | | ------------------------------------------------------------------------------------------------ |
||
197 | */ |
||
198 | /** |
||
199 | * Render all seo tags. |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | 27 | public function render() |
|
211 | |||
212 | /** |
||
213 | * Render the tag. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | 18 | public function __toString() |
|
221 | |||
222 | /** |
||
223 | * Enable the OpenGraph. |
||
224 | * |
||
225 | * @return self |
||
226 | */ |
||
227 | 3 | public function enableOpenGraph() |
|
233 | |||
234 | /** |
||
235 | * Disable the OpenGraph. |
||
236 | * |
||
237 | * @return self |
||
238 | */ |
||
239 | 3 | public function disableOpenGraph() |
|
245 | |||
246 | /** |
||
247 | * Enable the Twitter Card. |
||
248 | * |
||
249 | * @return self |
||
250 | */ |
||
251 | 3 | public function enableTwitter() |
|
257 | |||
258 | /** |
||
259 | * Disable the Twitter Card. |
||
260 | * |
||
261 | * @return self |
||
262 | */ |
||
263 | 3 | public function disableTwitter() |
|
269 | } |
||
270 |