1 | <?php namespace Arcanesoft\Sidebar; |
||
14 | class Item 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\Collection */ |
||
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 | 56 | 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 | 56 | public function setTitle(string $title) |
|
102 | |||
103 | /** |
||
104 | * Set the url. |
||
105 | * |
||
106 | * @param string $url |
||
107 | * |
||
108 | * @return $this |
||
109 | */ |
||
110 | 56 | 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 | * Make a sidebar item. |
||
159 | * |
||
160 | * @param array $attributes |
||
161 | * |
||
162 | * @return \Arcanesoft\Sidebar\Item |
||
163 | */ |
||
164 | 8 | public static function make(array $attributes = []) |
|
168 | |||
169 | /** |
||
170 | * Set the url from the route. |
||
171 | * |
||
172 | * @param string $name |
||
173 | * @param array $params |
||
174 | * |
||
175 | * @return $this |
||
176 | */ |
||
177 | 8 | public function route($name, array $params = []) |
|
183 | |||
184 | /** |
||
185 | * Set the url from the action. |
||
186 | * |
||
187 | * @param string|array $name |
||
188 | * @param array $params |
||
189 | * |
||
190 | * @return $this |
||
191 | */ |
||
192 | 4 | public function action($name, array $params = []) |
|
198 | |||
199 | /** |
||
200 | * Get the active/inactive class. |
||
201 | * |
||
202 | * @param string $active |
||
203 | * @param string $inactive |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | 4 | public function active($active = 'active', $inactive = '') : string |
|
211 | |||
212 | /** |
||
213 | * Push multiple child items. |
||
214 | * |
||
215 | * @param array $items |
||
216 | * |
||
217 | * @return $this |
||
218 | */ |
||
219 | 4 | public function addChildren(array $items) |
|
225 | |||
226 | /* ----------------------------------------------------------------- |
||
227 | | Check Methods |
||
228 | | ----------------------------------------------------------------- |
||
229 | */ |
||
230 | |||
231 | /** |
||
232 | * Check if has children. |
||
233 | * |
||
234 | * @return bool |
||
235 | */ |
||
236 | 44 | public function hasChildren() : bool |
|
240 | |||
241 | /** |
||
242 | * Check if has any selected children. |
||
243 | * |
||
244 | * @return bool |
||
245 | */ |
||
246 | 40 | public function hasAnySelectedChildren() : bool |
|
251 | |||
252 | /** |
||
253 | * Check if the item is active. |
||
254 | * |
||
255 | * @return bool |
||
256 | */ |
||
257 | 40 | public function isActive() : bool |
|
261 | |||
262 | /** |
||
263 | * Check if the item is selected. |
||
264 | * |
||
265 | * @return bool |
||
266 | */ |
||
267 | 40 | public function isSelected() : bool |
|
271 | |||
272 | /* ----------------------------------------------------------------- |
||
273 | | Other Methods |
||
274 | | ----------------------------------------------------------------- |
||
275 | */ |
||
276 | |||
277 | /** |
||
278 | * Parse the url attribute. |
||
279 | * |
||
280 | * @param array $attributes |
||
281 | * |
||
282 | * @return void |
||
283 | */ |
||
284 | 56 | protected function parseUrl(array $attributes) : void |
|
295 | |||
296 | /** |
||
297 | * Get the instance as an array. |
||
298 | * |
||
299 | * @return array |
||
300 | */ |
||
301 | 24 | public function toArray() |
|
314 | |||
315 | /** |
||
316 | * Convert the object into something JSON serializable. |
||
317 | * |
||
318 | * @return array |
||
319 | */ |
||
320 | 8 | public function jsonSerialize() |
|
324 | |||
325 | /** |
||
326 | * Get the collection of items as JSON. |
||
327 | * |
||
328 | * @param int $options |
||
329 | * |
||
330 | * @return string |
||
331 | */ |
||
332 | 4 | public function toJson($options = 0) |
|
336 | |||
337 | /** |
||
338 | * Check if has roles. |
||
339 | * |
||
340 | * @return bool |
||
341 | */ |
||
342 | 8 | public function hasRoles() |
|
346 | |||
347 | /** |
||
348 | * Check if has permissions. |
||
349 | * |
||
350 | * @return bool |
||
351 | */ |
||
352 | 8 | public function hasPermissions() |
|
356 | } |
||
357 |
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..