1 | <?php namespace Arcanesoft\Sidebar; |
||
15 | class SidebarItem implements Arrayable, Jsonable, JsonSerializable |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Properties |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $name; |
||
24 | |||
25 | /** @var string */ |
||
26 | public $title; |
||
27 | |||
28 | /** @var string */ |
||
29 | public $url; |
||
30 | |||
31 | /** @var string */ |
||
32 | public $icon; |
||
33 | |||
34 | /** @var \Arcanesoft\Sidebar\SidebarCollection */ |
||
35 | public $children; |
||
36 | |||
37 | /** @var array */ |
||
38 | protected $roles; |
||
39 | |||
40 | /** @var array */ |
||
41 | protected $permissions; |
||
42 | |||
43 | /** @var boolean */ |
||
44 | private $selected; |
||
45 | |||
46 | /* ----------------------------------------------------------------- |
||
47 | | Constructor |
||
48 | | ----------------------------------------------------------------- |
||
49 | */ |
||
50 | |||
51 | /** |
||
52 | * SidebarItem constructor. |
||
53 | * |
||
54 | * @param array $attributes |
||
55 | */ |
||
56 | 52 | public function __construct(array $attributes) |
|
70 | |||
71 | /* ----------------------------------------------------------------- |
||
72 | | Setters & Getters |
||
73 | | ----------------------------------------------------------------- |
||
74 | */ |
||
75 | |||
76 | /** |
||
77 | * Get the sidebar item's name. |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | 8 | public function name() |
|
85 | |||
86 | /** |
||
87 | * Set the title. |
||
88 | * |
||
89 | * @param string $title |
||
90 | * |
||
91 | * @return $this |
||
92 | */ |
||
93 | 52 | public function setTitle(string $title) |
|
101 | |||
102 | /** |
||
103 | * Set the url. |
||
104 | * |
||
105 | * @param string $url |
||
106 | * |
||
107 | * @return $this |
||
108 | */ |
||
109 | 52 | public function setUrl(string $url) |
|
115 | |||
116 | /** |
||
117 | * Set the selected item. |
||
118 | * |
||
119 | * @param string $name |
||
120 | * |
||
121 | * @return $this |
||
122 | */ |
||
123 | 12 | public function setSelected(string $name) |
|
130 | |||
131 | /** |
||
132 | * Get the roles. |
||
133 | * |
||
134 | * @return array|mixed |
||
135 | */ |
||
136 | 8 | public function roles() |
|
140 | |||
141 | /** |
||
142 | * Get the permissions. |
||
143 | * |
||
144 | * @return array|mixed |
||
145 | */ |
||
146 | 8 | public function permissions() |
|
150 | |||
151 | /* ----------------------------------------------------------------- |
||
152 | | Main Methods |
||
153 | | ----------------------------------------------------------------- |
||
154 | */ |
||
155 | |||
156 | /** |
||
157 | * Set the url from the route. |
||
158 | * |
||
159 | * @param string $name |
||
160 | * @param array $params |
||
161 | * |
||
162 | * @return $this |
||
163 | */ |
||
164 | 4 | public function route($name, array $params = []) |
|
170 | |||
171 | /** |
||
172 | * Set the url from the action. |
||
173 | * |
||
174 | * @param string|array $name |
||
175 | * @param array $params |
||
176 | * |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function action($name, array $params = []) |
||
185 | |||
186 | /** |
||
187 | * Set the icon. |
||
188 | * |
||
189 | * @param string $classes |
||
190 | * |
||
191 | * @return \Illuminate\Support\HtmlString |
||
192 | */ |
||
193 | public function icon($classes = '') : HtmlString |
||
201 | |||
202 | /** |
||
203 | * Get the active/inactive class. |
||
204 | * |
||
205 | * @param string $active |
||
206 | * @param string $inactive |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | 4 | public function active($active = 'active', $inactive = ''): string |
|
214 | |||
215 | /** |
||
216 | * Push multiple child items. |
||
217 | * |
||
218 | * @param array $items |
||
219 | * |
||
220 | * @return $this |
||
221 | */ |
||
222 | 4 | public function addChildren(array $items) |
|
228 | |||
229 | /* ----------------------------------------------------------------- |
||
230 | | Check Methods |
||
231 | | ----------------------------------------------------------------- |
||
232 | */ |
||
233 | |||
234 | /** |
||
235 | * Check if has children. |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | 44 | public function hasChildren(): bool |
|
243 | |||
244 | /** |
||
245 | * Check if has any selected children. |
||
246 | * |
||
247 | * @return bool |
||
248 | */ |
||
249 | 40 | public function hasAnySelectedChildren() |
|
254 | |||
255 | /** |
||
256 | * Check if the item is active. |
||
257 | * |
||
258 | * @return bool |
||
259 | */ |
||
260 | 40 | public function isActive() : bool |
|
264 | |||
265 | /** |
||
266 | * Check if the item is selected. |
||
267 | * |
||
268 | * @return bool |
||
269 | */ |
||
270 | 40 | public function isSelected() : bool |
|
274 | |||
275 | /* ----------------------------------------------------------------- |
||
276 | | Other Methods |
||
277 | | ----------------------------------------------------------------- |
||
278 | */ |
||
279 | |||
280 | /** |
||
281 | * Parse the url attribute. |
||
282 | * |
||
283 | * @param array $attributes |
||
284 | * |
||
285 | * @return void |
||
286 | */ |
||
287 | 52 | protected function parseUrl(array $attributes) : void |
|
298 | |||
299 | /** |
||
300 | * Get the instance as an array. |
||
301 | * |
||
302 | * @return array |
||
303 | */ |
||
304 | 24 | public function toArray() |
|
317 | |||
318 | /** |
||
319 | * Convert the object into something JSON serializable. |
||
320 | * |
||
321 | * @return array |
||
322 | */ |
||
323 | 8 | public function jsonSerialize() |
|
327 | |||
328 | /** |
||
329 | * Get the collection of items as JSON. |
||
330 | * |
||
331 | * @param int $options |
||
332 | * |
||
333 | * @return string |
||
334 | */ |
||
335 | 4 | public function toJson($options = 0) |
|
339 | |||
340 | /** |
||
341 | * Check if has roles. |
||
342 | * |
||
343 | * @return bool |
||
344 | */ |
||
345 | 8 | public function hasRoles() |
|
349 | |||
350 | /** |
||
351 | * Check if has permissions. |
||
352 | * |
||
353 | * @return bool |
||
354 | */ |
||
355 | 8 | public function hasPermissions() |
|
359 | } |
||
360 |
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..