1 | <?php namespace Arcanedev\SeoHelper\Bases; |
||
15 | abstract class MetaCollection extends Collection implements MetaCollectionContract |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Meta tag prefix. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $prefix = ''; |
||
28 | |||
29 | /** |
||
30 | * Meta tag name property. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $nameProperty = 'name'; |
||
35 | |||
36 | /** |
||
37 | * The items contained in the collection. |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $items = []; |
||
42 | |||
43 | /** |
||
44 | * Ignored tags, they have dedicated class. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $ignored = []; |
||
49 | |||
50 | /* ----------------------------------------------------------------- |
||
51 | | Getters & Setters |
||
52 | | ----------------------------------------------------------------- |
||
53 | */ |
||
54 | |||
55 | /** |
||
56 | * Set meta prefix name. |
||
57 | * |
||
58 | * @param string $prefix |
||
59 | * |
||
60 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
61 | */ |
||
62 | 280 | public function setPrefix($prefix) |
|
68 | |||
69 | /* ----------------------------------------------------------------- |
||
70 | | Main Functions |
||
71 | | ----------------------------------------------------------------- |
||
72 | */ |
||
73 | |||
74 | /** |
||
75 | * Add many meta tags. |
||
76 | * |
||
77 | * @param array $metas |
||
78 | * |
||
79 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
80 | */ |
||
81 | 348 | public function addMany(array $metas) |
|
89 | |||
90 | /** |
||
91 | * Add a meta to collection. |
||
92 | * |
||
93 | * @param string $name |
||
94 | * @param string|array $content |
||
95 | * |
||
96 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
97 | */ |
||
98 | 280 | public function addOne($name, $content) |
|
105 | |||
106 | /** |
||
107 | * Make a meta and add it to collection. |
||
108 | * |
||
109 | * @param string $name |
||
110 | * @param string|array $content |
||
111 | * |
||
112 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
113 | */ |
||
114 | 280 | protected function addMeta($name, $content) |
|
120 | |||
121 | /** |
||
122 | * Remove a meta from the collection by key. |
||
123 | * |
||
124 | * @param array|string $names |
||
125 | * |
||
126 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
127 | */ |
||
128 | 12 | public function remove($names) |
|
134 | |||
135 | /** |
||
136 | * Render the tag. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 312 | public function render() |
|
148 | |||
149 | /** |
||
150 | * Reset the collection. |
||
151 | * |
||
152 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
153 | */ |
||
154 | 16 | public function reset() |
|
160 | |||
161 | /** |
||
162 | * Render the tag. |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | 4 | public function __toString() |
|
170 | |||
171 | /* ----------------------------------------------------------------- |
||
172 | | Check Functions |
||
173 | | ----------------------------------------------------------------- |
||
174 | */ |
||
175 | |||
176 | /** |
||
177 | * Check if meta is ignored. |
||
178 | * |
||
179 | * @param string $name |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | 184 | protected function isIgnored($name) |
|
187 | |||
188 | /* ----------------------------------------------------------------- |
||
189 | | Other Functions |
||
190 | | ----------------------------------------------------------------- |
||
191 | */ |
||
192 | |||
193 | /** |
||
194 | * Remove an item from the collection by key. |
||
195 | * |
||
196 | * @param string|array $keys |
||
197 | * |
||
198 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
199 | */ |
||
200 | 12 | public function forget($keys) |
|
208 | |||
209 | /** |
||
210 | * Refresh meta collection items. |
||
211 | * |
||
212 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
213 | */ |
||
214 | 280 | private function refresh() |
|
220 | |||
221 | /** |
||
222 | * Prepare names. |
||
223 | * |
||
224 | * @param array|string $names |
||
225 | * |
||
226 | * @return array |
||
227 | */ |
||
228 | 12 | protected function prepareName($names) |
|
234 | } |
||
235 |