1 | <?php namespace Arcanedev\SeoHelper; |
||
14 | class SeoTwitter implements Contracts\SeoTwitter |
||
15 | { |
||
16 | /* ------------------------------------------------------------------------------------------------ |
||
17 | | Traits |
||
18 | | ------------------------------------------------------------------------------------------------ |
||
19 | */ |
||
20 | use Configurable; |
||
21 | |||
22 | /* ------------------------------------------------------------------------------------------------ |
||
23 | | Properties |
||
24 | | ------------------------------------------------------------------------------------------------ |
||
25 | */ |
||
26 | /** |
||
27 | * Enable or Disable the Twitter Card. |
||
28 | * |
||
29 | * @var bool |
||
30 | */ |
||
31 | protected $enabled; |
||
32 | |||
33 | /** |
||
34 | * The Twitter Card instance. |
||
35 | * |
||
36 | * @var TwitterCardInterface |
||
37 | */ |
||
38 | protected $card; |
||
39 | |||
40 | /* ------------------------------------------------------------------------------------------------ |
||
41 | | Constructor |
||
42 | | ------------------------------------------------------------------------------------------------ |
||
43 | */ |
||
44 | /** |
||
45 | * Make SeoTwitter instance. |
||
46 | * |
||
47 | * @param array $configs |
||
48 | */ |
||
49 | 84 | public function __construct(array $configs) |
|
58 | |||
59 | /* ------------------------------------------------------------------------------------------------ |
||
60 | | Getters & Setters |
||
61 | | ------------------------------------------------------------------------------------------------ |
||
62 | */ |
||
63 | /** |
||
64 | * Set the enabled status for the Twitter Card. |
||
65 | * |
||
66 | * @param bool $enabled |
||
67 | * |
||
68 | * @return self |
||
69 | */ |
||
70 | 84 | private function setEnabled($enabled) |
|
76 | |||
77 | /** |
||
78 | * Set the Twitter Card instance. |
||
79 | * |
||
80 | * @param \Arcanedev\SeoHelper\Contracts\Entities\TwitterCardInterface $card |
||
81 | * |
||
82 | * @return self |
||
83 | */ |
||
84 | 84 | public function setCard(TwitterCardInterface $card) |
|
90 | |||
91 | /** |
||
92 | * Set the card type. |
||
93 | * |
||
94 | * @param string $type |
||
95 | * |
||
96 | * @return self |
||
97 | */ |
||
98 | 6 | public function setType($type) |
|
104 | |||
105 | /** |
||
106 | * Set the card site. |
||
107 | * |
||
108 | * @param string $site |
||
109 | * |
||
110 | * @return self |
||
111 | */ |
||
112 | 6 | public function setSite($site) |
|
118 | |||
119 | /** |
||
120 | * Set the card title. |
||
121 | * |
||
122 | * @param string $title |
||
123 | * |
||
124 | * @return self |
||
125 | */ |
||
126 | 12 | public function setTitle($title) |
|
132 | |||
133 | /** |
||
134 | * Set the card description. |
||
135 | * |
||
136 | * @param string $description |
||
137 | * |
||
138 | * @return self |
||
139 | */ |
||
140 | 9 | public function setDescription($description) |
|
146 | |||
147 | /** |
||
148 | * Add image to the card. |
||
149 | * |
||
150 | * @param string $url |
||
151 | * |
||
152 | * @return self |
||
153 | */ |
||
154 | 6 | public function addImage($url) |
|
160 | |||
161 | /** |
||
162 | * Add many metas to the card. |
||
163 | * |
||
164 | * @param array $metas |
||
165 | * |
||
166 | * @return self |
||
167 | */ |
||
168 | 3 | public function addMetas(array $metas) |
|
174 | |||
175 | /** |
||
176 | * Add a meta to the Twitter Card. |
||
177 | * |
||
178 | * @param string $name |
||
179 | * @param string $content |
||
180 | * |
||
181 | * @return self |
||
182 | */ |
||
183 | 3 | public function addMeta($name, $content) |
|
189 | |||
190 | /* ------------------------------------------------------------------------------------------------ |
||
191 | | Main Functions |
||
192 | | ------------------------------------------------------------------------------------------------ |
||
193 | */ |
||
194 | /** |
||
195 | * Reset the Twitter Card. |
||
196 | * |
||
197 | * @return self |
||
198 | */ |
||
199 | 3 | public function reset() |
|
205 | |||
206 | /** |
||
207 | * Render the tag. |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | 57 | public function render() |
|
219 | |||
220 | /** |
||
221 | * Render the tag. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | 21 | public function __toString() |
|
229 | |||
230 | /** |
||
231 | * Enable the Twitter Card. |
||
232 | * |
||
233 | * @return self |
||
234 | */ |
||
235 | 6 | public function enable() |
|
239 | |||
240 | /** |
||
241 | * Disable the Twitter Card. |
||
242 | * |
||
243 | * @return self |
||
244 | */ |
||
245 | 6 | public function disable() |
|
249 | |||
250 | /* ------------------------------------------------------------------------------------------------ |
||
251 | | Check Function |
||
252 | | ------------------------------------------------------------------------------------------------ |
||
253 | */ |
||
254 | /** |
||
255 | * Check if the Twitter Card is enabled. |
||
256 | * |
||
257 | * @return bool |
||
258 | */ |
||
259 | 57 | public function isEnabled() |
|
263 | |||
264 | /** |
||
265 | * Check if the Twitter Card is disabled. |
||
266 | * |
||
267 | * @return bool |
||
268 | */ |
||
269 | 6 | public function isDisabled() |
|
273 | } |
||
274 |