1 | <?php namespace Arcanedev\SeoHelper\Bases; |
||
15 | abstract class MetaCollection extends Collection implements MetaCollectionInterface |
||
16 | { |
||
17 | /* ------------------------------------------------------------------------------------------------ |
||
18 | | Properties |
||
19 | | ------------------------------------------------------------------------------------------------ |
||
20 | */ |
||
21 | /** |
||
22 | * Meta tag prefix. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $prefix = ''; |
||
27 | |||
28 | /** |
||
29 | * Meta tag name property. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $nameProperty = 'name'; |
||
34 | |||
35 | /** |
||
36 | * The items contained in the collection. |
||
37 | * |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $items = []; |
||
41 | |||
42 | /** |
||
43 | * Ignored tags, they have dedicated class. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $ignored = []; |
||
48 | |||
49 | /* ------------------------------------------------------------------------------------------------ |
||
50 | | Getters & Setters |
||
51 | | ------------------------------------------------------------------------------------------------ |
||
52 | */ |
||
53 | /** |
||
54 | * Set meta prefix name. |
||
55 | * |
||
56 | * @param string $prefix |
||
57 | * |
||
58 | * @return self |
||
59 | */ |
||
60 | 744 | public function setPrefix($prefix) |
|
67 | |||
68 | /* ------------------------------------------------------------------------------------------------ |
||
69 | | Main Functions |
||
70 | | ------------------------------------------------------------------------------------------------ |
||
71 | */ |
||
72 | /** |
||
73 | * Add many meta tags. |
||
74 | * |
||
75 | * @param array $metas |
||
76 | * |
||
77 | * @return self |
||
78 | */ |
||
79 | 408 | public function addMany(array $metas) |
|
87 | |||
88 | /** |
||
89 | * Add a meta to collection. |
||
90 | * |
||
91 | * @param string $name |
||
92 | * @param string $content |
||
93 | * |
||
94 | * @return self |
||
95 | */ |
||
96 | 744 | public function add($name, $content) |
|
104 | |||
105 | /** |
||
106 | * Make a meta and add it to collection. |
||
107 | * |
||
108 | * @param string $name |
||
109 | * @param string $content |
||
110 | * |
||
111 | * @return self |
||
112 | */ |
||
113 | 744 | 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 self |
||
128 | */ |
||
129 | 36 | public function remove($names) |
|
135 | |||
136 | /** |
||
137 | * Render the tag. |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | 840 | public function render() |
|
149 | |||
150 | /** |
||
151 | * Render the tag. |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 12 | public function __toString() |
|
159 | |||
160 | /* ------------------------------------------------------------------------------------------------ |
||
161 | | Check Functions |
||
162 | | ------------------------------------------------------------------------------------------------ |
||
163 | */ |
||
164 | /** |
||
165 | * Check if meta is ignored. |
||
166 | * |
||
167 | * @param string $name |
||
168 | * |
||
169 | * @return bool |
||
170 | */ |
||
171 | 504 | protected function isIgnored($name) |
|
175 | |||
176 | /* ------------------------------------------------------------------------------------------------ |
||
177 | | Other Functions |
||
178 | | ------------------------------------------------------------------------------------------------ |
||
179 | */ |
||
180 | /** |
||
181 | * Remove an item from the collection by key. |
||
182 | * |
||
183 | * @param string|array $keys |
||
184 | * |
||
185 | * @return self |
||
186 | */ |
||
187 | 36 | public function forget($keys) |
|
195 | |||
196 | /** |
||
197 | * Refresh meta collection items. |
||
198 | */ |
||
199 | 744 | private function refresh() |
|
207 | |||
208 | /** |
||
209 | * Prepare names. |
||
210 | * |
||
211 | * @param array|string $names |
||
212 | * |
||
213 | * @return array |
||
214 | */ |
||
215 | protected function prepareName($names) |
||
223 | } |
||
224 |