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 | 210 | 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 | 261 | 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 | 210 | public function add($name, $content) |
|
104 | |||
105 | /** |
||
106 | * Make a meta and add it to collection. |
||
107 | * |
||
108 | * @param string $name |
||
109 | * @param string|array $content |
||
110 | * |
||
111 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
112 | */ |
||
113 | 210 | protected function addMeta($name, $content) |
|
121 | |||
122 | /** |
||
123 | * Remove a meta from the collection by key. |
||
124 | * |
||
125 | * @param array|string $names |
||
126 | * |
||
127 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
128 | */ |
||
129 | 9 | public function remove($names) |
|
135 | |||
136 | /** |
||
137 | * Render the tag. |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function render() |
||
149 | |||
150 | /** |
||
151 | * Reset the collection. |
||
152 | * |
||
153 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
154 | */ |
||
155 | 12 | public function reset() |
|
161 | |||
162 | /** |
||
163 | * Render the tag. |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | 3 | public function __toString() |
|
171 | |||
172 | /* ----------------------------------------------------------------- |
||
173 | | Check Functions |
||
174 | | ----------------------------------------------------------------- |
||
175 | */ |
||
176 | |||
177 | /** |
||
178 | * Check if meta is ignored. |
||
179 | * |
||
180 | * @param string $name |
||
181 | * |
||
182 | * @return bool |
||
183 | */ |
||
184 | 138 | protected function isIgnored($name) |
|
188 | |||
189 | /* ----------------------------------------------------------------- |
||
190 | | Other Functions |
||
191 | | ----------------------------------------------------------------- |
||
192 | */ |
||
193 | |||
194 | /** |
||
195 | * Remove an item from the collection by key. |
||
196 | * |
||
197 | * @param string|array $keys |
||
198 | * |
||
199 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
200 | */ |
||
201 | 9 | public function forget($keys) |
|
209 | |||
210 | /** |
||
211 | * Refresh meta collection items. |
||
212 | * |
||
213 | * @return \Arcanedev\SeoHelper\Bases\MetaCollection |
||
214 | */ |
||
215 | private function refresh() |
||
221 | |||
222 | /** |
||
223 | * Prepare names. |
||
224 | * |
||
225 | * @param array|string $names |
||
226 | * |
||
227 | * @return array |
||
228 | */ |
||
229 | protected function prepareName($names) |
||
235 | } |
||
236 |