@@ -174,8 +174,9 @@ discard block |
||
174 | 174 | |
175 | 175 | $submenu = null; |
176 | 176 | |
177 | - if(!empty($this->submenu)) |
|
178 | - $submenu = $this->submenu; |
|
177 | + if(!empty($this->submenu)) { |
|
178 | + $submenu = $this->submenu; |
|
179 | + } |
|
179 | 180 | |
180 | 181 | $result = [ |
181 | 182 | 'name' => $this->route, |
@@ -189,8 +190,9 @@ discard block |
||
189 | 190 | 'sub' => $submenu |
190 | 191 | ]; |
191 | 192 | |
192 | - if(empty($this->submenu)) |
|
193 | - unset($result['sub']); |
|
193 | + if(empty($this->submenu)) { |
|
194 | + unset($result['sub']); |
|
195 | + } |
|
194 | 196 | |
195 | 197 | return $result; |
196 | 198 |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function sub($route, $callback) |
57 | 57 | { |
58 | 58 | $sub = SideNav::addSub($route, $callback); |
59 | - array_push($this->submenu,$sub); |
|
59 | + array_push($this->submenu, $sub); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function subWithCheckStatus($route, $callback) |
70 | 70 | { |
71 | - if(SideNav::checkStatus($route) === true) |
|
71 | + if (SideNav::checkStatus($route) === true) |
|
72 | 72 | { |
73 | 73 | $sub = SideNav::addSub($route, $callback); |
74 | - array_push($this->submenu,$sub); |
|
74 | + array_push($this->submenu, $sub); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | $submenu = null; |
204 | 204 | |
205 | - if(!empty($this->submenu)) |
|
205 | + if (!empty($this->submenu)) |
|
206 | 206 | $submenu = $this->submenu; |
207 | 207 | |
208 | 208 | $result = [ |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'sub' => $submenu |
218 | 218 | ]; |
219 | 219 | |
220 | - if(empty($this->submenu)) |
|
220 | + if (empty($this->submenu)) |
|
221 | 221 | unset($result['sub']); |
222 | 222 | |
223 | 223 | return $result; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function hasSub($menu) |
23 | 23 | { |
24 | 24 | // check menu has sub |
25 | - if(! empty($menu['sub'])) |
|
25 | + if (!empty($menu['sub'])) |
|
26 | 26 | return true; |
27 | 27 | |
28 | 28 | return false; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $tag = $value['tag']; |
42 | 42 | |
43 | - if($value['tag'] === null) |
|
43 | + if ($value['tag'] === null) |
|
44 | 44 | $tag = 'i'; |
45 | 45 | |
46 | 46 | return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>'; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function new_tab($newTab) |
57 | 57 | { |
58 | - if($newTab) |
|
58 | + if ($newTab) |
|
59 | 59 | return 'target="_blank"'; |
60 | 60 | |
61 | 61 | return null; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @return bool |
16 | 16 | */ |
17 | 17 | function hasSub($menu){ |
18 | - if(! empty($menu['sub'])) |
|
19 | - return true; |
|
18 | + if(! empty($menu['sub'])) { |
|
19 | + return true; |
|
20 | + } |
|
20 | 21 | return false; |
21 | 22 | } |
22 | 23 | } |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | |
32 | 33 | $tag = $value['tag']; |
33 | 34 | |
34 | - if($value['tag'] === null) |
|
35 | - $tag = 'i'; |
|
35 | + if($value['tag'] === null) { |
|
36 | + $tag = 'i'; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>'; |
38 | 40 | } |
@@ -45,8 +47,9 @@ discard block |
||
45 | 47 | * @return null|string |
46 | 48 | */ |
47 | 49 | function new_tab($newTab){ |
48 | - if($newTab) |
|
49 | - return 'target="_blank"'; |
|
50 | + if($newTab) { |
|
51 | + return 'target="_blank"'; |
|
52 | + } |
|
50 | 53 | |
51 | 54 | return null; |
52 | 55 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @since 19 Sep 2016 |
47 | 47 | * @param $class |
48 | 48 | */ |
49 | - public static function checkStatusObject($class,$method) |
|
49 | + public static function checkStatusObject($class, $method) |
|
50 | 50 | { |
51 | 51 | self::$checkStatusObject = [ |
52 | 52 | 'object' => $class, |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | self::$routes[self::$currentRoute] = []; |
90 | 90 | |
91 | 91 | // make menu array |
92 | - $array = self::add($route,$callback); |
|
92 | + $array = self::add($route, $callback); |
|
93 | 93 | |
94 | 94 | if (self::checkGroupId(self::$type)) |
95 | 95 | // add to the group render array |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | * @param $callback |
108 | 108 | * @param $checkCallback |
109 | 109 | */ |
110 | - public static function registerWithCheckStatus($route , $callback , $checkCallback = null) |
|
110 | + public static function registerWithCheckStatus($route, $callback, $checkCallback = null) |
|
111 | 111 | { |
112 | 112 | // check status of route |
113 | - if (self::checkStatus($route,$checkCallback)){ |
|
113 | + if (self::checkStatus($route, $checkCallback)) { |
|
114 | 114 | self::register($route, $callback); |
115 | 115 | } |
116 | 116 | } |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | public static function addSub($route, $callback) |
127 | 127 | { |
128 | 128 | // register route name |
129 | - array_push(self::$routes[self::$currentRoute],$route); |
|
129 | + array_push(self::$routes[self::$currentRoute], $route); |
|
130 | 130 | |
131 | 131 | // return submenu array |
132 | - return self::add($route,$callback); |
|
132 | + return self::add($route, $callback); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param $callback |
141 | 141 | * @return array |
142 | 142 | */ |
143 | - private static function add($route,$callback) |
|
143 | + private static function add($route, $callback) |
|
144 | 144 | { |
145 | 145 | // instance of menu class |
146 | 146 | $menu = new Menu; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public static function routes() |
162 | 162 | { |
163 | 163 | // return json array of all routes-name |
164 | - if(self::$resultType === 'json') |
|
164 | + if (self::$resultType === 'json') |
|
165 | 165 | return json_encode(self::$routes); |
166 | 166 | |
167 | 167 | // return array of all routes-name |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public static function render($type = null) |
191 | 191 | { |
192 | - if(self::checkGroupId($type)) |
|
192 | + if (self::checkGroupId($type)) |
|
193 | 193 | { |
194 | 194 | |
195 | 195 | // render the menu json array |
196 | - if(self::$resultType === 'json') |
|
196 | + if (self::$resultType === 'json') |
|
197 | 197 | return json_encode(self::$menu[$type]); |
198 | 198 | |
199 | 199 | // render the menu array |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | // return single menu json array |
204 | - if(self::$resultType === 'json') |
|
204 | + if (self::$resultType === 'json') |
|
205 | 205 | return json_encode(self::$menu); |
206 | 206 | |
207 | 207 | // return single menu array |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public static function checkGroupId($type) |
218 | 218 | { |
219 | - if($type !== null && isset(self::$type)) |
|
219 | + if ($type !== null && isset(self::$type)) |
|
220 | 220 | return true; |
221 | 221 | |
222 | 222 | return false; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param $callback |
231 | 231 | * @return bool |
232 | 232 | */ |
233 | - public static function checkStatus($route,$callback = false) |
|
233 | + public static function checkStatus($route, $callback = false) |
|
234 | 234 | { |
235 | 235 | if ($callback instanceof \Closure) { |
236 | 236 | if ($callback()) |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | // check status method name |
244 | 244 | $method = self::$checkStatusObject['method']; |
245 | 245 | |
246 | - if(class_exists($obj)) { |
|
246 | + if (class_exists($obj)) { |
|
247 | 247 | // instance of class |
248 | 248 | $class = new $obj; |
249 | 249 |
@@ -91,9 +91,10 @@ discard block |
||
91 | 91 | // make menu array |
92 | 92 | $array = self::add($route,$callback); |
93 | 93 | |
94 | - if (self::checkGroupId(self::$type)) |
|
95 | - // add to the group render array |
|
94 | + if (self::checkGroupId(self::$type)) { |
|
95 | + // add to the group render array |
|
96 | 96 | array_push(self::$menu[self::$type], $array); |
97 | + } |
|
97 | 98 | |
98 | 99 | // add to the single render array |
99 | 100 | array_push(self::$menu, $array); |
@@ -161,8 +162,9 @@ discard block |
||
161 | 162 | public static function routes() |
162 | 163 | { |
163 | 164 | // return json array of all routes-name |
164 | - if(self::$resultType === 'json') |
|
165 | - return json_encode(self::$routes); |
|
165 | + if(self::$resultType === 'json') { |
|
166 | + return json_encode(self::$routes); |
|
167 | + } |
|
166 | 168 | |
167 | 169 | // return array of all routes-name |
168 | 170 | return self::$routes; |
@@ -193,16 +195,18 @@ discard block |
||
193 | 195 | { |
194 | 196 | |
195 | 197 | // render the menu json array |
196 | - if(self::$resultType === 'json') |
|
197 | - return json_encode(self::$menu[$type]); |
|
198 | + if(self::$resultType === 'json') { |
|
199 | + return json_encode(self::$menu[$type]); |
|
200 | + } |
|
198 | 201 | |
199 | 202 | // render the menu array |
200 | 203 | return self::$menu[$type]; |
201 | 204 | } |
202 | 205 | |
203 | 206 | // return single menu json array |
204 | - if(self::$resultType === 'json') |
|
205 | - return json_encode(self::$menu); |
|
207 | + if(self::$resultType === 'json') { |
|
208 | + return json_encode(self::$menu); |
|
209 | + } |
|
206 | 210 | |
207 | 211 | // return single menu array |
208 | 212 | return self::$menu[0]; |
@@ -216,8 +220,9 @@ discard block |
||
216 | 220 | */ |
217 | 221 | public static function checkGroupId($type) |
218 | 222 | { |
219 | - if($type !== null && isset(self::$type)) |
|
220 | - return true; |
|
223 | + if($type !== null && isset(self::$type)) { |
|
224 | + return true; |
|
225 | + } |
|
221 | 226 | |
222 | 227 | return false; |
223 | 228 | } |
@@ -233,8 +238,9 @@ discard block |
||
233 | 238 | public static function checkStatus($route,$callback = false) |
234 | 239 | { |
235 | 240 | if ($callback instanceof \Closure) { |
236 | - if ($callback()) |
|
237 | - return true; |
|
241 | + if ($callback()) { |
|
242 | + return true; |
|
243 | + } |
|
238 | 244 | } |
239 | 245 | |
240 | 246 | // check status class name |
@@ -248,8 +254,9 @@ discard block |
||
248 | 254 | $class = new $obj; |
249 | 255 | |
250 | 256 | // call method of class |
251 | - if ($class->$method($route)) |
|
252 | - return true; |
|
257 | + if ($class->$method($route)) { |
|
258 | + return true; |
|
259 | + } |
|
253 | 260 | return false; |
254 | 261 | } else { |
255 | 262 | throw new \Exception("The CheckStatus class not found !"); |