1 | <?php namespace Arcanesoft\Sidebar; |
||
14 | class SidebarItem implements Arrayable, Jsonable, JsonSerializable |
||
15 | { |
||
16 | /* ----------------------------------------------------------------- |
||
17 | | Properties |
||
18 | | ----------------------------------------------------------------- |
||
19 | */ |
||
20 | |||
21 | /** @var string */ |
||
22 | protected $name; |
||
23 | |||
24 | /** @var string */ |
||
25 | public $title; |
||
26 | |||
27 | /** @var string */ |
||
28 | public $url; |
||
29 | |||
30 | /** @var string */ |
||
31 | public $icon; |
||
32 | |||
33 | /** @var \Arcanesoft\Sidebar\SidebarCollection */ |
||
34 | public $children; |
||
35 | |||
36 | /** @var array */ |
||
37 | protected $roles; |
||
38 | |||
39 | /** @var array */ |
||
40 | protected $permissions; |
||
41 | |||
42 | /** @var boolean */ |
||
43 | private $selected; |
||
44 | |||
45 | /* ----------------------------------------------------------------- |
||
46 | | Constructor |
||
47 | | ----------------------------------------------------------------- |
||
48 | */ |
||
49 | |||
50 | /** |
||
51 | * SidebarItem constructor. |
||
52 | * |
||
53 | * @param array $attributes |
||
54 | */ |
||
55 | 52 | public function __construct(array $attributes) |
|
69 | |||
70 | /* ----------------------------------------------------------------- |
||
71 | | Setters & Getters |
||
72 | | ----------------------------------------------------------------- |
||
73 | */ |
||
74 | |||
75 | /** |
||
76 | * Get the sidebar item's name. |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | 8 | public function name() |
|
84 | |||
85 | /** |
||
86 | * Set the title. |
||
87 | * |
||
88 | * @param string $title |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 52 | public function setTitle(string $title) |
|
102 | |||
103 | /** |
||
104 | * Set the url. |
||
105 | * |
||
106 | * @param string $url |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | 52 | public function setUrl(string $url) |
|
116 | |||
117 | /** |
||
118 | * Set the selected item. |
||
119 | * |
||
120 | * @param string $name |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | 12 | public function setSelected(string $name) |
|
131 | |||
132 | /** |
||
133 | * Get the roles. |
||
134 | * |
||
135 | * @return array|mixed |
||
136 | */ |
||
137 | 8 | public function roles() |
|
141 | |||
142 | /** |
||
143 | * Get the permissions. |
||
144 | * |
||
145 | * @return array|mixed |
||
146 | */ |
||
147 | 8 | public function permissions() |
|
151 | |||
152 | /* ----------------------------------------------------------------- |
||
153 | | Main Methods |
||
154 | | ----------------------------------------------------------------- |
||
155 | */ |
||
156 | |||
157 | /** |
||
158 | * Set the url from the route. |
||
159 | * |
||
160 | * @param string $name |
||
161 | * @param array $params |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | 4 | public function route($name, array $params = []) |
|
171 | |||
172 | /** |
||
173 | * Set the url from the action. |
||
174 | * |
||
175 | * @param string|array $name |
||
176 | * @param array $params |
||
177 | * |
||
178 | * @return $this |
||
179 | */ |
||
180 | public function action($name, array $params = []) |
||
186 | |||
187 | /** |
||
188 | * Get the active/inactive class. |
||
189 | * |
||
190 | * @param string $active |
||
191 | * @param string $inactive |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | 4 | public function active($active = 'active', $inactive = '') : string |
|
199 | |||
200 | /** |
||
201 | * Push multiple child items. |
||
202 | * |
||
203 | * @param array $items |
||
204 | * |
||
205 | * @return $this |
||
206 | */ |
||
207 | 4 | public function addChildren(array $items) |
|
213 | |||
214 | /* ----------------------------------------------------------------- |
||
215 | | Check Methods |
||
216 | | ----------------------------------------------------------------- |
||
217 | */ |
||
218 | |||
219 | /** |
||
220 | * Check if has children. |
||
221 | * |
||
222 | * @return bool |
||
223 | */ |
||
224 | 44 | public function hasChildren() : bool |
|
228 | |||
229 | /** |
||
230 | * Check if has any selected children. |
||
231 | * |
||
232 | * @return bool |
||
233 | */ |
||
234 | 40 | public function hasAnySelectedChildren() : bool |
|
239 | |||
240 | /** |
||
241 | * Check if the item is active. |
||
242 | * |
||
243 | * @return bool |
||
244 | */ |
||
245 | 40 | public function isActive() : bool |
|
249 | |||
250 | /** |
||
251 | * Check if the item is selected. |
||
252 | * |
||
253 | * @return bool |
||
254 | */ |
||
255 | 40 | public function isSelected() : bool |
|
259 | |||
260 | /* ----------------------------------------------------------------- |
||
261 | | Other Methods |
||
262 | | ----------------------------------------------------------------- |
||
263 | */ |
||
264 | |||
265 | /** |
||
266 | * Parse the url attribute. |
||
267 | * |
||
268 | * @param array $attributes |
||
269 | * |
||
270 | * @return void |
||
271 | */ |
||
272 | 52 | protected function parseUrl(array $attributes) : void |
|
283 | |||
284 | /** |
||
285 | * Get the instance as an array. |
||
286 | * |
||
287 | * @return array |
||
288 | */ |
||
289 | 24 | public function toArray() |
|
302 | |||
303 | /** |
||
304 | * Convert the object into something JSON serializable. |
||
305 | * |
||
306 | * @return array |
||
307 | */ |
||
308 | 8 | public function jsonSerialize() |
|
312 | |||
313 | /** |
||
314 | * Get the collection of items as JSON. |
||
315 | * |
||
316 | * @param int $options |
||
317 | * |
||
318 | * @return string |
||
319 | */ |
||
320 | 4 | public function toJson($options = 0) |
|
324 | |||
325 | /** |
||
326 | * Check if has roles. |
||
327 | * |
||
328 | * @return bool |
||
329 | */ |
||
330 | 8 | public function hasRoles() |
|
334 | |||
335 | /** |
||
336 | * Check if has permissions. |
||
337 | * |
||
338 | * @return bool |
||
339 | */ |
||
340 | 8 | public function hasPermissions() |
|
344 | } |
||
345 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..