1 | <?php |
||
19 | abstract class AbstractMetaCollection extends Collection implements MetaCollectionContract |
||
20 | { |
||
21 | /* ----------------------------------------------------------------- |
||
22 | | Properties |
||
23 | | ----------------------------------------------------------------- |
||
24 | */ |
||
25 | |||
26 | /** |
||
27 | * Meta tag prefix. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $prefix = ''; |
||
32 | |||
33 | /** |
||
34 | * Meta tag name property. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $nameProperty = 'name'; |
||
39 | |||
40 | /** |
||
41 | * The items contained in the collection. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $items = []; |
||
46 | |||
47 | /** |
||
48 | * Ignored tags, they have dedicated class. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $ignored = []; |
||
53 | |||
54 | /* ----------------------------------------------------------------- |
||
55 | | Getters & Setters |
||
56 | | ----------------------------------------------------------------- |
||
57 | */ |
||
58 | |||
59 | /** |
||
60 | * Set meta prefix name. |
||
61 | * |
||
62 | * @param string $prefix |
||
63 | * |
||
64 | * @return $this |
||
65 | */ |
||
66 | 426 | public function setPrefix($prefix) |
|
72 | |||
73 | /* ----------------------------------------------------------------- |
||
74 | | Main Methods |
||
75 | | ----------------------------------------------------------------- |
||
76 | */ |
||
77 | |||
78 | /** |
||
79 | * Add many meta tags. |
||
80 | * |
||
81 | * @param array $metas |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | 528 | public function addMany(array $metas) |
|
93 | |||
94 | /** |
||
95 | * Add a meta to collection. |
||
96 | * |
||
97 | * @param string $name |
||
98 | * @param string|array $content |
||
99 | * |
||
100 | * @return $this |
||
101 | */ |
||
102 | 426 | public function addOne($name, $content) |
|
109 | |||
110 | /** |
||
111 | * Make a meta and add it to collection. |
||
112 | * |
||
113 | * @param string $name |
||
114 | * @param string|array $content |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 426 | protected function addMeta($name, $content) |
|
124 | |||
125 | /** |
||
126 | * Remove a meta from the collection by key. |
||
127 | * |
||
128 | * @param array|string $names |
||
129 | * |
||
130 | * @return $this |
||
131 | */ |
||
132 | 18 | public function remove($names) |
|
138 | |||
139 | /** |
||
140 | * Render the tag. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | 474 | public function render() |
|
152 | |||
153 | /** |
||
154 | * Reset the collection. |
||
155 | * |
||
156 | * @return $this |
||
157 | */ |
||
158 | 24 | public function reset() |
|
164 | |||
165 | /** |
||
166 | * Render the tag. |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | 6 | public function __toString() |
|
174 | |||
175 | /* ----------------------------------------------------------------- |
||
176 | | Check Functions |
||
177 | | ----------------------------------------------------------------- |
||
178 | */ |
||
179 | |||
180 | /** |
||
181 | * Check if meta is ignored. |
||
182 | * |
||
183 | * @param string $name |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 282 | protected function isIgnored($name) |
|
191 | |||
192 | /* ----------------------------------------------------------------- |
||
193 | | Other Functions |
||
194 | | ----------------------------------------------------------------- |
||
195 | */ |
||
196 | |||
197 | /** |
||
198 | * Refresh meta collection items. |
||
199 | * |
||
200 | * @return $this |
||
201 | */ |
||
202 | 426 | private function refresh() |
|
208 | |||
209 | /** |
||
210 | * Prepare names. |
||
211 | * |
||
212 | * @param array|string $names |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | 18 | protected static function prepareName($names) |
|
222 | } |
||
223 |