Completed
Push — master ( c9b7ea...c1fd74 )
by Mihail
02:38
created
src/Ffcms/Core/Helper/HTML/Listing.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,8 +24,9 @@  discard block
 block discarded – undo
24 24
     public static function display($elements)
25 25
     {
26 26
         // check input elements
27
-        if (!Arr::in($elements['type'], ['ul', 'ol']) || count($elements['items']) < 1)
28
-            return null;
27
+        if (!Arr::in($elements['type'], ['ul', 'ol']) || count($elements['items']) < 1) {
28
+                    return null;
29
+        }
29 30
 
30 31
         // initialize new DOM model
31 32
         $dom = new Dom();
@@ -62,11 +63,13 @@  discard block
 block discarded – undo
62 63
      */
63 64
     private static function buildDropdown($dom, $item)
64 65
     {
65
-        if (!Any::isArray($item['items']))
66
-            return null;
66
+        if (!Any::isArray($item['items'])) {
67
+                    return null;
68
+        }
67 69
 
68
-        if (!isset($item['menuProperty']['class']))
69
-            $item['menuProperty']['class'] = 'dropdown-menu';
70
+        if (!isset($item['menuProperty']['class'])) {
71
+                    $item['menuProperty']['class'] = 'dropdown-menu';
72
+        }
70 73
 
71 74
         return $dom->li(function() use($dom, $item){
72 75
             $dropdownLink = $dom->a(function() use ($dom, $item){
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/Type/Arr.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
     public static function in(?string $needle, ?array $haystack = null, bool $strict = true): bool
20 20
     {
21 21
         // prevent errors
22
-        if (!Any::isArray($haystack) || $needle === null)
23
-            return false;
22
+        if (!Any::isArray($haystack) || $needle === null) {
23
+                    return false;
24
+        }
24 25
 
25 26
         return in_array($needle, $haystack, $strict);
26 27
     }
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
     {
34 35
         $arguments = [];
35 36
         foreach (func_get_args() as $key => $val) {
36
-            if (!Any::isArray($val))
37
-                $val = [];
37
+            if (!Any::isArray($val)) {
38
+                            $val = [];
39
+            }
38 40
 
39 41
             $arguments[$key] = $val;
40 42
         }
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
     {
50 52
         $arguments = [];
51 53
         foreach (func_get_args() as $key => $val) {
52
-            if (!Any::isArray($val))
53
-                $val = [];
54
+            if (!Any::isArray($val)) {
55
+                            $val = [];
56
+            }
54 57
 
55 58
             $arguments[$key] = $val;
56 59
         }
@@ -67,18 +70,21 @@  discard block
 block discarded – undo
67 70
     public static function getByPath(string $path, ?array $array = null, $delimiter = '.')
68 71
     {
69 72
         // path of nothing? interest
70
-        if (!Any::isArray($array) || count($array) < 1 || !Any::isStr($path) || Str::likeEmpty($path))
71
-            return null;
73
+        if (!Any::isArray($array) || count($array) < 1 || !Any::isStr($path) || Str::likeEmpty($path)) {
74
+                    return null;
75
+        }
72 76
 
73 77
         // c'mon man, what the f*ck are you doing? ))
74
-        if (!Str::contains($delimiter, $path))
75
-            return $array[$path];
78
+        if (!Str::contains($delimiter, $path)) {
79
+                    return $array[$path];
80
+        }
76 81
 
77 82
         $output = $array;
78 83
         $pathArray = explode($delimiter, $path);
79 84
         foreach ($pathArray as $key) {
80
-            if (!Any::isArray($output) || !array_key_exists($key, $output))
81
-                return null;
85
+            if (!Any::isArray($output) || !array_key_exists($key, $output)) {
86
+                            return null;
87
+            }
82 88
 
83 89
             $output = $output[$key];
84 90
         }
@@ -93,14 +99,16 @@  discard block
 block discarded – undo
93 99
      */
94 100
     public static function pluck(?string $key = null, ?array $array = null): array
95 101
     {
96
-        if (!Any::isArray($array) || !Any::isStr($key))
97
-            return [];
102
+        if (!Any::isArray($array) || !Any::isStr($key)) {
103
+                    return [];
104
+        }
98 105
 
99 106
         $output = [];
100 107
         foreach ($array as $item) {
101 108
             $object = $item[$key];
102
-            if (!self::in($object, $output))
103
-                $output[] = $object;
109
+            if (!self::in($object, $output)) {
110
+                            $output[] = $object;
111
+            }
104 112
         }
105 113
         return $output;
106 114
     }
@@ -148,8 +156,9 @@  discard block
 block discarded – undo
148 156
      */
149 157
     public static function onlyNumericValues(?array $array = null)
150 158
     {
151
-        if (!Any::isArray($array))
152
-            return false;
159
+        if (!Any::isArray($array)) {
160
+                    return false;
161
+        }
153 162
 
154 163
         return is_numeric(implode('', $array));
155 164
     }
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/Type/Any.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,12 +17,14 @@  discard block
 block discarded – undo
17 17
     public static function isEmpty($var = null): bool
18 18
     {
19 19
         // var is array type?
20
-        if (is_array($var))
21
-            return count($var) < 1;
20
+        if (is_array($var)) {
21
+                    return count($var) < 1;
22
+        }
22 23
 
23 24
         // var seems to be object?
24
-        if (is_object($var))
25
-            return count(get_object_vars($var)) < 1;
25
+        if (is_object($var)) {
26
+                    return count(get_object_vars($var)) < 1;
27
+        }
26 28
 
27 29
         // float,int,string,bool and null left. Check if not empty. Int and float will never equal to null.
28 30
         return ($var === null || $var === '' || $var === false);
@@ -123,14 +125,17 @@  discard block
 block discarded – undo
123 125
     public static function guessValueType($var = null)
124 126
     {
125 127
         // pass var by reference and guess var type
126
-        if (self::isInt($var))
127
-            return $var;
128
+        if (self::isInt($var)) {
129
+                    return $var;
130
+        }
128 131
 
129
-        if (self::isFloat($var))
130
-            return $var;
132
+        if (self::isFloat($var)) {
133
+                    return $var;
134
+        }
131 135
 
132
-        if (self::isBool($var))
133
-            return $var;
136
+        if (self::isBool($var)) {
137
+                    return $var;
138
+        }
134 139
 
135 140
 
136 141
         return $var;
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/Url.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public static function to($controller_action, $id = null, $add = null, array $params = null, $encode = true)
26 26
     {
27 27
         $pathway = self::buildPathway([$controller_action, $id, $add, $params], $encode);
28
-        return App::$Alias->baseUrl . '/' . $pathway;
28
+        return App::$Alias->baseUrl.'/'.$pathway;
29 29
     }
30 30
 
31 31
     /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 $controller = Str::lastIn($controller, '\\', true);
62 62
             }
63 63
 
64
-            $response = $controller . '/' . $action;
64
+            $response = $controller.'/'.$action;
65 65
         }
66 66
 
67 67
         // check if controller and action is defined
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 
72 72
         // id is defined?
73 73
         if (isset($to[1]) && !Str::likeEmpty($to[1])) {
74
-            $response .= '/' . self::safeUri($to[1], $encode);
74
+            $response .= '/'.self::safeUri($to[1], $encode);
75 75
         }
76 76
 
77 77
         // add param is defined?
78 78
         if (isset($to[2]) && !Str::likeEmpty($to[2])) {
79
-            $response .= '/' . self::safeUri($to[2], $encode);
79
+            $response .= '/'.self::safeUri($to[2], $encode);
80 80
         }
81 81
 
82 82
         // try to find static alias
83
-        if (isset($routing['Alias'][env_name]) && Arr::in('/' . $response, $routing['Alias'][env_name])) {
84
-            $pathAlias = array_search('/' . $response, $routing['Alias'][env_name]);
83
+        if (isset($routing['Alias'][env_name]) && Arr::in('/'.$response, $routing['Alias'][env_name])) {
84
+            $pathAlias = array_search('/'.$response, $routing['Alias'][env_name]);
85 85
             if ($pathAlias !== false) {
86 86
                 $response = Str::lowerCase(trim($pathAlias, '/'));
87 87
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             }
98 98
             $queryString = http_build_query($to[3]);
99 99
             if (Str::length($queryString) > 0) {
100
-                $response .= '?' . http_build_query($to[3]);
100
+                $response .= '?'.http_build_query($to[3]);
101 101
             }
102 102
             if ($anchor !== false) {
103 103
                 $response .= $anchor;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public static function buildPathwayFromRequest()
120 120
     {
121 121
         return self::buildPathway([
122
-            Str::lowerCase(App::$Request->getController()) . '/' . Str::lowerCase(App::$Request->getAction()),
122
+            Str::lowerCase(App::$Request->getController()).'/'.Str::lowerCase(App::$Request->getAction()),
123 123
             App::$Request->getID(),
124 124
             App::$Request->getAdd(),
125 125
             App::$Request->query->all()
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
             $to = [$to];
141 141
 
142 142
         // call Url::to(args)
143
-        $callbackTo = call_user_func_array([__NAMESPACE__ . '\Url', 'to'], $to);
143
+        $callbackTo = call_user_func_array([__NAMESPACE__.'\Url', 'to'], $to);
144 144
 
145
-        return '<a href="' . $callbackTo . '"' . $compile_property . '>' . $name . '</a>';
145
+        return '<a href="'.$callbackTo.'"'.$compile_property.'>'.$name.'</a>';
146 146
     }
147 147
 
148 148
     /**
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
     {
156 156
         /** @var array $configs */
157 157
         $configs = \App::$Properties->getAll('default');
158
-        $httpHost = $configs['baseProto'] . '://' . $configs['baseDomain'];
158
+        $httpHost = $configs['baseProto'].'://'.$configs['baseDomain'];
159 159
         if ($configs['basePath'] !== '/') {
160
-            $httpHost .= $configs['basePath'] . '/';
160
+            $httpHost .= $configs['basePath'].'/';
161 161
         }
162 162
 
163 163
         // check if is this is URI not URL
164 164
         if (!Str::startsWith($httpHost, $uri)) {
165 165
             // check if lang is defined in URI or define it
166 166
             if ($lang !== null && $configs['multiLanguage'] && !Str::startsWith($lang, $uri)) {
167
-                $uri = $lang . '/' . ltrim($uri, '/');
167
+                $uri = $lang.'/'.ltrim($uri, '/');
168 168
             }
169 169
             // add basic httpHost data
170
-            $uri = rtrim($httpHost, '/') . '/' . ltrim($uri, '/');
170
+            $uri = rtrim($httpHost, '/').'/'.ltrim($uri, '/');
171 171
         }
172 172
 
173 173
         return $uri;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,8 +136,9 @@
 block discarded – undo
136 136
     public static function link($to, $name, array $property = null)
137 137
     {
138 138
         $compile_property = self::applyProperty($property);
139
-        if (!Any::isArray($to))
140
-            $to = [$to];
139
+        if (!Any::isArray($to)) {
140
+                    $to = [$to];
141
+        }
141 142
 
142 143
         // call Url::to(args)
143 144
         $callbackTo = call_user_func_array([__NAMESPACE__ . '\Url', 'to'], $to);
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/Simplify.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,13 +21,15 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public static function parseUserNick($userId = null, $onEmpty = 'guest'): ?string
23 23
     {
24
-        if (!Any::isInt($userId))
25
-            return \App::$Security->strip_tags($onEmpty);
24
+        if (!Any::isInt($userId)) {
25
+                    return \App::$Security->strip_tags($onEmpty);
26
+        }
26 27
 
27 28
         // try to find user active record as object
28 29
         $identity = App::$User->identity($userId);
29
-        if (!$identity)
30
-            return \App::$Security->strip_tags($onEmpty);
30
+        if (!$identity) {
31
+                    return \App::$Security->strip_tags($onEmpty);
32
+        }
31 33
 
32 34
         // return user nickname from profile
33 35
         return $identity->profile->getNickname();
@@ -44,8 +46,9 @@  discard block
 block discarded – undo
44 46
     {
45 47
         $nick = self::parseUserNick($userId, $onEmpty);
46 48
         // new name is not found, lets return default
47
-        if ($nick === $onEmpty || (int)$userId < 1)
48
-            return $nick;
49
+        if ($nick === $onEmpty || (int)$userId < 1) {
50
+                    return $nick;
51
+        }
49 52
 
50 53
         return Url::link([$controllerAction, (int)$userId], $nick);
51 54
     }
Please login to merge, or discard this patch.