1 | <?php namespace Arcanedev\SeoHelper; |
||
12 | class SeoOpenGraph implements Contracts\SeoOpenGraph |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Traits |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | use Configurable; |
||
19 | |||
20 | /* ------------------------------------------------------------------------------------------------ |
||
21 | | Properties |
||
22 | | ------------------------------------------------------------------------------------------------ |
||
23 | */ |
||
24 | /** |
||
25 | * Enable or Disable the OpenGraph. |
||
26 | * |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $enabled; |
||
30 | |||
31 | /** |
||
32 | * The Open Graph instance. |
||
33 | * |
||
34 | * @var OpenGraphInterface |
||
35 | */ |
||
36 | protected $openGraph; |
||
37 | |||
38 | /* ------------------------------------------------------------------------------------------------ |
||
39 | | Constructor |
||
40 | | ------------------------------------------------------------------------------------------------ |
||
41 | */ |
||
42 | /** |
||
43 | * Make SeoOpenGraph instance. |
||
44 | * |
||
45 | * @param array $configs |
||
46 | */ |
||
47 | 87 | public function __construct(array $configs) |
|
56 | |||
57 | /* ------------------------------------------------------------------------------------------------ |
||
58 | | Getters & Setters |
||
59 | | ------------------------------------------------------------------------------------------------ |
||
60 | */ |
||
61 | /** |
||
62 | * Set the enabled status for the OpenGraph. |
||
63 | * |
||
64 | * @param bool $enabled |
||
65 | * |
||
66 | * @return self |
||
67 | */ |
||
68 | 87 | private function setEnabled($enabled) |
|
74 | |||
75 | /** |
||
76 | * Set the Open Graph instance. |
||
77 | * |
||
78 | * @param OpenGraphInterface $openGraph |
||
79 | * |
||
80 | * @return self |
||
81 | */ |
||
82 | 87 | public function setOpenGraph(OpenGraphInterface $openGraph) |
|
88 | |||
89 | /** |
||
90 | * Set the open graph prefix. |
||
91 | * |
||
92 | * @param string $prefix |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | 3 | public function setPrefix($prefix) |
|
102 | |||
103 | /** |
||
104 | * Set type property. |
||
105 | * |
||
106 | * @param string $type |
||
107 | * |
||
108 | * @return self |
||
109 | */ |
||
110 | 3 | public function setType($type) |
|
116 | |||
117 | /** |
||
118 | * Set title property. |
||
119 | * |
||
120 | * @param string $title |
||
121 | * |
||
122 | * @return self |
||
123 | */ |
||
124 | 9 | public function setTitle($title) |
|
130 | |||
131 | /** |
||
132 | * Set description property. |
||
133 | * |
||
134 | * @param string $description |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | 9 | public function setDescription($description) |
|
144 | |||
145 | /** |
||
146 | * Set url property. |
||
147 | * |
||
148 | * @param string $url |
||
149 | * |
||
150 | * @return self |
||
151 | */ |
||
152 | 3 | public function setUrl($url) |
|
158 | |||
159 | /** |
||
160 | * Set image property. |
||
161 | * |
||
162 | * @param string $image |
||
163 | * |
||
164 | * @return self |
||
165 | */ |
||
166 | 3 | public function setImage($image) |
|
172 | |||
173 | /** |
||
174 | * Set site name property. |
||
175 | * |
||
176 | * @param string $siteName |
||
177 | * |
||
178 | * @return self |
||
179 | */ |
||
180 | 9 | public function setSiteName($siteName) |
|
186 | |||
187 | /** |
||
188 | * Add many open graph properties. |
||
189 | * |
||
190 | * @param array $properties |
||
191 | * |
||
192 | * @return self |
||
193 | */ |
||
194 | 3 | public function addProperties(array $properties) |
|
200 | |||
201 | /** |
||
202 | * Add an open graph property. |
||
203 | * |
||
204 | * @param string $property |
||
205 | * @param string $content |
||
206 | * |
||
207 | * @return self |
||
208 | */ |
||
209 | 3 | public function addProperty($property, $content) |
|
215 | |||
216 | /* ------------------------------------------------------------------------------------------------ |
||
217 | | Main Functions |
||
218 | | ------------------------------------------------------------------------------------------------ |
||
219 | */ |
||
220 | /** |
||
221 | * Render the tag. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | 60 | public function render() |
|
233 | |||
234 | /** |
||
235 | * Render the tag. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | 30 | public function __toString() |
|
243 | |||
244 | /** |
||
245 | * Enable the OpenGraph. |
||
246 | * |
||
247 | * @return self |
||
248 | */ |
||
249 | 6 | public function enable() |
|
253 | |||
254 | /** |
||
255 | * Disable the OpenGraph. |
||
256 | * |
||
257 | * @return self |
||
258 | */ |
||
259 | 6 | public function disable() |
|
263 | |||
264 | /* ------------------------------------------------------------------------------------------------ |
||
265 | | Check Function |
||
266 | | ------------------------------------------------------------------------------------------------ |
||
267 | */ |
||
268 | /** |
||
269 | * Check if the OpenGraph is enabled. |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | 60 | public function isEnabled() |
|
277 | |||
278 | /** |
||
279 | * Check if the OpenGraph is disabled. |
||
280 | * |
||
281 | * @return bool |
||
282 | */ |
||
283 | 6 | public function isDisabled() |
|
287 | } |
||
288 |