Completed
Push — master ( c1fd74...f54537 )
by Mihail
17:26
created
src/Ffcms/Core/Helper/HTML/SimplePagination.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Ffcms\Core\Helper\Type\Any;
6 6
 use Ffcms\Core\Helper\Type\Arr;
7
-use Ffcms\Core\Helper\Type\Obj;
8 7
 
9 8
 /**
10 9
  * Class SimplePagination. Build and display html pagination block
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,17 +37,20 @@  discard block
 block discarded – undo
37 37
     public function display(array $property = null): ?string
38 38
     {
39 39
         // total items is less to pagination requirement
40
-        if (($this->page * $this->step) + 1 > $this->total)
41
-            return null;
40
+        if (($this->page * $this->step) + 1 > $this->total) {
41
+                    return null;
42
+        }
42 43
 
43 44
         $lastPage = ceil($this->total / $this->step); // 6/5 ~ 2 = 0..2
44 45
 
45
-        if ($lastPage <= 1)
46
-            return null;
46
+        if ($lastPage <= 1) {
47
+                    return null;
48
+        }
47 49
 
48 50
         // prevent hack-boy's any try
49
-        if ($this->page > $lastPage)
50
-            return null;
51
+        if ($this->page > $lastPage) {
52
+                    return null;
53
+        }
51 54
 
52 55
         $items = [];
53 56
         // more then 10 items in pagination
@@ -137,8 +140,9 @@  discard block
 block discarded – undo
137 140
     protected function generateItems($start, $end)
138 141
     {
139 142
         // prevent any shit's
140
-        if ($end <= $start)
141
-            return null;
143
+        if ($end <= $start) {
144
+                    return null;
145
+        }
142 146
 
143 147
         $items = [];
144 148
         for ($i = $start; $i < $end; $i++) {
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/HTML/System/NativeGenerator.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Ffcms\Core\App;
6 6
 use Ffcms\Core\Helper\Type\Any;
7
-use Ffcms\Core\Helper\Type\Obj;
8 7
 use Ffcms\Core\Helper\Type\Str;
9 8
 use Ffcms\Core\Helper\Url;
10 9
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
             $purifier = App::$Memory->get('object.purifier.helpers');
25 25
         } else {
26 26
             $config = \HTMLPurifier_Config::createDefault();
27
-            $config->set('Cache.SerializerPath', root . '/Private/Cache/HTMLPurifier/');
27
+            $config->set('Cache.SerializerPath', root.'/Private/Cache/HTMLPurifier/');
28 28
             $config->set('AutoFormat.AutoParagraph', false);
29 29
 
30 30
             // allow use target=_blank for links
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $build = null;
66 66
         foreach ($property as $p => $v) {
67 67
             if ($v === null || $v === false || $v === true) {
68
-                $build .= ' ' . self::nohtml($p);
68
+                $build .= ' '.self::nohtml($p);
69 69
             } else {
70
-                $build .= ' ' . self::nohtml($p) . '="' . self::nohtml($v) . '"';
70
+                $build .= ' '.self::nohtml($p).'="'.self::nohtml($v).'"';
71 71
             }
72 72
         }
73 73
         return $build;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public static function buildSingleTag($tagName, array $property = null, $closeSlash = true)
84 84
     {
85
-        return '<' . self::nohtml($tagName) . self::applyProperty($property) . ($closeSlash ? '/>' : '>');
85
+        return '<'.self::nohtml($tagName).self::applyProperty($property).($closeSlash ? '/>' : '>');
86 86
     }
87 87
 
88 88
     /**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         if ($valueHtml !== true)
100 100
             $value = self::nohtml($value);
101 101
         
102
-        return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>';
102
+        return '<'.$tagName.self::applyProperty($property).'>'.$value.'</'.$tagName.'>';
103 103
     }
104 104
 
105 105
     /**
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
                 if (!Str::contains('/', $elementPoint) || count($elementArray) < 2) {
141 141
                     $active = $elementPoint === $currentPoint;
142 142
                 } else {
143
-                    $elementPoint = $elementArray[0] . '/' . $elementArray[1];
143
+                    $elementPoint = $elementArray[0].'/'.$elementArray[1];
144 144
                     $active = Str::startsWith($elementPoint, $currentPoint);
145 145
                 }
146 146
                 break;
147 147
             case 'id':
148 148
                 $elementArray = explode('/', $elementPoint);
149
-                $elementPoint = $elementArray[0] . '/' . $elementArray[1];
149
+                $elementPoint = $elementArray[0].'/'.$elementArray[1];
150 150
                 if ($elementArray[2] === null) { // looks like id is not defined in element
151 151
                     if (Str::contains('?', $currentPoint)) {
152 152
                         $currentPoint = Str::firstIn($currentPoint, '?');
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                     $currentToId = implode('/', array_slice($currentArray, 0, 3));
156 156
                     $active = $elementPoint === $currentToId;
157 157
                 } else {
158
-                    $elementPoint .= '/' . $elementArray[2];
158
+                    $elementPoint .= '/'.$elementArray[2];
159 159
                     $active = Str::startsWith($elementPoint, $currentPoint);
160 160
                 }
161 161
                 break;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public static function convertLink($uri)
212 212
     {
213
-        $link = App::$Alias->baseUrl . '/';
213
+        $link = App::$Alias->baseUrl.'/';
214 214
         if (Any::isArray($uri)) {
215 215
             $link .= Url::buildPathway($uri);
216 216
         } elseif (Str::startsWith('http', $uri)) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         if (Str::likeEmpty($uri))
234 234
             return null;
235 235
 
236
-        return implode('/', array_map(function($v){
236
+        return implode('/', array_map(function($v) {
237 237
             return urlencode($v);
238 238
         }, explode('/', $uri)));
239 239
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public static function applyProperty(array $property = null)
61 61
     {
62
-        if ($property === null || count($property) < 1)
63
-            return null;
62
+        if ($property === null || count($property) < 1) {
63
+                    return null;
64
+        }
64 65
         
65 66
         $build = null;
66 67
         foreach ($property as $p => $v) {
@@ -96,8 +97,9 @@  discard block
 block discarded – undo
96 97
     public static function buildContainerTag($tagName, array $property = null, $value = null, $valueHtml = false)
97 98
     {
98 99
         $tagName = self::nohtml($tagName);
99
-        if ($valueHtml !== true)
100
-            $value = self::nohtml($value);
100
+        if ($valueHtml !== true) {
101
+                    $value = self::nohtml($value);
102
+        }
101 103
         
102 104
         return '<' . $tagName . self::applyProperty($property) . '>' . $value . '</' . $tagName . '>';
103 105
     }
@@ -111,8 +113,9 @@  discard block
 block discarded – undo
111 113
     public static function safeUri($string, $encode = true)
112 114
     {
113 115
         $string = self::nohtml($string);
114
-        if ($encode === true)
115
-            $string = self::encode($string);
116
+        if ($encode === true) {
117
+                    $string = self::encode($string);
118
+        }
116 119
 
117 120
         return $string;
118 121
     }
@@ -230,8 +233,9 @@  discard block
 block discarded – undo
230 233
      */
231 234
     public static function encode(?string $uri = null)
232 235
     {
233
-        if (Str::likeEmpty($uri))
234
-            return null;
236
+        if (Str::likeEmpty($uri)) {
237
+                    return null;
238
+        }
235 239
 
236 240
         return implode('/', array_map(function($v){
237 241
             return urlencode($v);
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/HTML/Table.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 use Ffcms\Core\Helper\HTML\System\NativeGenerator;
8 8
 use Ffcms\Core\Helper\Type\Any;
9 9
 use Ffcms\Core\Helper\Type\Arr;
10
-use Ffcms\Core\Helper\Type\Obj;
11 10
 
12 11
 /**
13 12
  * Class Table. Helper for drawing tables using php static call Table::display([params])
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
         // init dom model
36 36
         $dom = new Dom();
37 37
         // draw response
38
-        $table = $dom->table(function () use ($dom, $elements, $selectOptions) {
38
+        $table = $dom->table(function() use ($dom, $elements, $selectOptions) {
39 39
             $res = null;
40 40
             // check if thead is defined
41 41
             if (isset($elements['thead']) && Any::isArray($elements['thead']) && count($elements['thead']) > 0 && Any::isArray($elements['thead']['titles'])) {
42 42
                 // add thead container
43
-                $res .= $dom->thead(function () use ($dom, $elements, $selectOptions) {
44
-                    return $dom->tr(function () use ($dom, $elements, $selectOptions) {
43
+                $res .= $dom->thead(function() use ($dom, $elements, $selectOptions) {
44
+                    return $dom->tr(function() use ($dom, $elements, $selectOptions) {
45 45
                         $tr = null;
46 46
                         foreach ($elements['thead']['titles'] as $order => $title) {
47 47
                             $th = null;
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
                             }
57 57
                             // make global checkbox for selectable columns
58 58
                             if ($selectOptions !== false && $order + 1 === $selectOptions['attachOrder']) {
59
-                                $th = $dom->input(function () {
59
+                                $th = $dom->input(function() {
60 60
                                     return null;
61
-                                }, ['type' => 'checkbox', 'name' => 'selectAll']) . ' ' . $th;
61
+                                }, ['type' => 'checkbox', 'name' => 'selectAll']).' '.$th;
62 62
                             }
63 63
                             // build tr row collecting all th's
64
-                            $tr .= $dom->th(function () use ($th) {
64
+                            $tr .= $dom->th(function() use ($th) {
65 65
                                 return $th;
66 66
                             }, $title['property']);
67 67
                         }
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
                         // sort td items inside row by key increment
81 81
                         ksort($row);
82 82
                         // add data in tr container
83
-                        $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) {
83
+                        $tr .= $dom->tr(function() use ($dom, $row, $selectOptions) {
84 84
                             $td = null;
85 85
                             foreach ($row as $order => $item) {
86 86
                                 if (!Any::isInt($order))
87 87
                                     continue;
88 88
 
89 89
                                 // collect td item
90
-                                $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) {
90
+                                $td .= $dom->td(function() use ($dom, $order, $item, $selectOptions) {
91 91
                                     $text = null;
92 92
                                     // make text secure based on passed options
93 93
                                     if ($item['html'] === true) {
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
                                     }
102 102
                                     // check if selectable box is enabled and equal current order id
103 103
                                     if ($selectOptions !== false && $order === $selectOptions['attachOrder']) {
104
-                                        $text = $dom->input(function (){
104
+                                        $text = $dom->input(function() {
105 105
                                             return null;
106
-                                        }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])) . ' ' . $text;
106
+                                        }, Arr::merge($selectOptions['selector'], ['value' => htmlentities($text, null, 'UTF-8')])).' '.$text;
107 107
                                     }
108 108
                                     return $text;
109 109
                                 }, $item['property']);
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
             // build js code for "selectAll" checkbox
127 127
             self::buildSelectorHtml($selectOptions);
128 128
             // return response inside "form" tag
129
-            return $dom->form(function () use ($dom, $selectOptions, $table) {
129
+            return $dom->form(function() use ($dom, $selectOptions, $table) {
130 130
                 foreach ($selectOptions['buttons'] as $btn) {
131 131
                     if (!Any::isArray($btn))
132 132
                         continue;
133 133
 
134
-                    $table .= $dom->input(function(){
134
+                    $table .= $dom->input(function() {
135 135
                         return null;
136
-                    }, $btn) . ' ';
136
+                    }, $btn).' ';
137 137
                 }
138 138
                 return $table;
139 139
             }, $selectOptions['form']);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     private static function buildSelectorHtml(array $opt)
150 150
     {
151 151
         $js = '$(function () {
152
-            var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'] . '"]\');
152
+            var targetSwitchbox = $(\'input[name="' . $opt['selector']['name'].'"]\');
153 153
             $(\'input[name="selectAll"]\').change(function() {
154 154
                 $(targetSwitchbox).each(function () {
155 155
                     $(this).prop(\'checked\', !$(this).is(\':checked\'));
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function display(array $elements): ?string
25 25
     {
26
-        if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1)
27
-            return null;
26
+        if (!array_key_exists('tbody', $elements) || !Any::isArray($elements['tbody']['items']) || count($elements['tbody']['items']) < 1) {
27
+                    return null;
28
+        }
28 29
 
29 30
         $selectOptions = false;
30 31
         if (isset($elements['selectableBox'])) {
@@ -83,8 +84,9 @@  discard block
 block discarded – undo
83 84
                         $tr .= $dom->tr(function () use ($dom, $row, $selectOptions) {
84 85
                             $td = null;
85 86
                             foreach ($row as $order => $item) {
86
-                                if (!Any::isInt($order))
87
-                                    continue;
87
+                                if (!Any::isInt($order)) {
88
+                                                                    continue;
89
+                                }
88 90
 
89 91
                                 // collect td item
90 92
                                 $td .= $dom->td(function () use ($dom, $order, $item, $selectOptions) {
@@ -128,8 +130,9 @@  discard block
 block discarded – undo
128 130
             // return response inside "form" tag
129 131
             return $dom->form(function () use ($dom, $selectOptions, $table) {
130 132
                 foreach ($selectOptions['buttons'] as $btn) {
131
-                    if (!Any::isArray($btn))
132
-                        continue;
133
+                    if (!Any::isArray($btn)) {
134
+                                            continue;
135
+                    }
133 136
 
134 137
                     $table .= $dom->input(function(){
135 138
                         return null;
Please login to merge, or discard this patch.
src/Ffcms/Core/Helper/ModelFilters.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Ffcms\Core\Helper\Type\Any;
6 6
 use Ffcms\Core\Helper\Type\Arr;
7
-use Ffcms\Core\Helper\Type\Obj;
8 7
 use Ffcms\Core\Helper\Type\Str;
9 8
 
10 9
 /**
Please login to merge, or discard this patch.
Braces   +66 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,8 +23,9 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function length_min($object, $length): bool
25 25
     {
26
-        if (!Any::isLine($object))
27
-            return false;
26
+        if (!Any::isLine($object)) {
27
+                    return false;
28
+        }
28 29
 
29 30
         return Str::length((string)$object) >= $length;
30 31
     }
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
      */
38 39
     public static function length_max($object, $length): bool
39 40
     {
40
-        if (!Any::isLine($object))
41
-            return false;
41
+        if (!Any::isLine($object)) {
42
+                    return false;
43
+        }
42 44
 
43 45
         return Str::length((string)$object) <= $length;
44 46
     }
@@ -51,12 +53,14 @@  discard block
 block discarded – undo
51 53
      */
52 54
     public static function in($object, array $handle): bool
53 55
     {
54
-        if (!Any::isLine($object))
55
-            return false;
56
+        if (!Any::isLine($object)) {
57
+                    return false;
58
+        }
56 59
 
57 60
         // allow empty, validate on required rule
58
-        if (Any::isEmpty($object))
59
-            return true;
61
+        if (Any::isEmpty($object)) {
62
+                    return true;
63
+        }
60 64
 
61 65
         $object = Any::guessValueType($object);
62 66
 
@@ -82,8 +86,9 @@  discard block
 block discarded – undo
82 86
      */
83 87
     public static function checked($object): bool
84 88
     {
85
-        if (!Any::isBool($object))
86
-            return false;
89
+        if (!Any::isBool($object)) {
90
+                    return false;
91
+        }
87 92
 
88 93
         return (bool)$object;
89 94
     }
@@ -155,11 +160,14 @@  discard block
 block discarded – undo
155 160
      */
156 161
     public static function email($object): bool
157 162
     {
158
-        if (Any::isEmpty($object)) // allow empty
163
+        if (Any::isEmpty($object)) {
164
+            // allow empty
159 165
             return true;
166
+        }
160 167
 
161
-        if (!Any::isLine($object))
162
-            return false;
168
+        if (!Any::isLine($object)) {
169
+                    return false;
170
+        }
163 171
 
164 172
         return Str::isEmail($object);
165 173
     }
@@ -171,11 +179,14 @@  discard block
 block discarded – undo
171 179
      */
172 180
     public static function phone($object): bool
173 181
     {
174
-        if (Any::isEmpty($object)) // allow empty
182
+        if (Any::isEmpty($object)) {
183
+            // allow empty
175 184
             return true;
185
+        }
176 186
 
177
-        if (!Any::isLine($object))
178
-            return false;
187
+        if (!Any::isLine($object)) {
188
+                    return false;
189
+        }
179 190
 
180 191
         return Str::isPhone($object);
181 192
     }
@@ -187,11 +198,14 @@  discard block
 block discarded – undo
187 198
      */
188 199
     public static function url($object): bool
189 200
     {
190
-        if (Any::isEmpty($object)) // allow empty
201
+        if (Any::isEmpty($object)) {
202
+            // allow empty
191 203
             return true;
204
+        }
192 205
 
193
-        if (!Any::isLine($object))
194
-            return false;
206
+        if (!Any::isLine($object)) {
207
+                    return false;
208
+        }
195 209
 
196 210
         return Str::isUrl($object);
197 211
     }
@@ -204,8 +218,9 @@  discard block
 block discarded – undo
204 218
      */
205 219
     public static function equal($object, $value = null): bool
206 220
     {
207
-        if (!Any::isLine($object))
208
-            return false;
221
+        if (!Any::isLine($object)) {
222
+                    return false;
223
+        }
209 224
 
210 225
         return $object === $value;
211 226
     }
@@ -218,8 +233,9 @@  discard block
 block discarded – undo
218 233
      */
219 234
     public static function notequal($object, $value = null): bool
220 235
     {
221
-        if (!Any::isLine($object))
222
-            return false;
236
+        if (!Any::isLine($object)) {
237
+                    return false;
238
+        }
223 239
 
224 240
         return $object !== $value;
225 241
     }
@@ -254,11 +270,13 @@  discard block
 block discarded – undo
254 270
      */
255 271
     public static function reg_match($object, $value): bool
256 272
     {
257
-        if (!Any::isLine($object))
258
-            return false;
273
+        if (!Any::isLine($object)) {
274
+                    return false;
275
+        }
259 276
 
260
-        if (Str::likeEmpty($object))
261
-            return true;
277
+        if (Str::likeEmpty($object)) {
278
+                    return true;
279
+        }
262 280
 
263 281
         // what the f*ck? -> return preg_match($value, $object) > 0;
264 282
         return (bool)preg_match($value, $object);
@@ -272,8 +290,9 @@  discard block
 block discarded – undo
272 290
      */
273 291
     public static function intList($object, $value): bool
274 292
     {
275
-        if (!Any::isLine($object))
276
-            return false;
293
+        if (!Any::isLine($object)) {
294
+                    return false;
295
+        }
277 296
 
278 297
         return !preg_match('/[^0-9\s,]/$', $object);
279 298
     }
@@ -287,8 +306,9 @@  discard block
 block discarded – undo
287 306
     public static function isFile($object, $value): bool
288 307
     {
289 308
         // allow empty fields, "required" option filter that
290
-        if ($object === null)
291
-            return true;
309
+        if ($object === null) {
310
+                    return true;
311
+        }
292 312
 
293 313
         $all = false;
294 314
         // if string is given
@@ -301,13 +321,15 @@  discard block
 block discarded – undo
301 321
         }
302 322
 
303 323
         // input file is not object?
304
-        if ($object === null || !Any::isObj($object))
305
-            return false;
324
+        if ($object === null || !Any::isObj($object)) {
325
+                    return false;
326
+        }
306 327
 
307 328
         // get guess file type, based on mime-type
308 329
         $type = $object->guessExtension();
309
-        if ($type === null)
310
-            return false;
330
+        if ($type === null) {
331
+                    return false;
332
+        }
311 333
 
312 334
         return ($all ? true : Arr::in($type, $value));
313 335
     }
@@ -321,21 +343,24 @@  discard block
 block discarded – undo
321 343
     public static function sizeFile($object, $value): bool
322 344
     {
323 345
         // allow empty field, validate on filter 'required'
324
-        if ($object === null)
325
-            return true;
346
+        if ($object === null) {
347
+                    return true;
348
+        }
326 349
 
327 350
         if (!Any::isArray($value)) {
328 351
             $value = [0, $value];
329 352
         }
330 353
 
331 354
         // input file is not object?
332
-        if ($object === null || !Any::isObj($object))
333
-            return false;
355
+        if ($object === null || !Any::isObj($object)) {
356
+                    return false;
357
+        }
334 358
 
335 359
         // get file upload size in bytes
336 360
         $realSize = $object->getClientSize();
337
-        if ($realSize === null)
338
-            return false;
361
+        if ($realSize === null) {
362
+                    return false;
363
+        }
339 364
 
340 365
         return $realSize > $value[0] && $realSize <= $value[1];
341 366
     }
Please login to merge, or discard this patch.
src/Ffcms/Core/I18n/Translate.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 use Ffcms\Core\Helper\Serialize;
10 10
 use Ffcms\Core\Helper\Type\Any;
11 11
 use Ffcms\Core\Helper\Type\Arr;
12
-use Ffcms\Core\Helper\Type\Obj;
13 12
 use Ffcms\Core\Helper\Type\Str;
14 13
 
15 14
 /**
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
         if (Any::isArray($params) && count($params) > 0) {
56 56
             foreach ($params as $var => $value) {
57
-                $text = Str::replace('%' . $var . '%', $value, $text);
57
+                $text = Str::replace('%'.$var.'%', $value, $text);
58 58
             }
59 59
         }
60 60
         return $text;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function translate(string $text, array $params = null)
70 70
     {
71 71
         $index = null;
72
-        $namespace = 'Apps\Controller\\' . env_name . '\\';
72
+        $namespace = 'Apps\Controller\\'.env_name.'\\';
73 73
         foreach (@debug_backtrace() as $caller) {
74 74
             if (isset($caller['class']) && Str::startsWith($namespace, $caller['class'])) {
75 75
                 $index = Str::sub((string)$caller['class'], Str::length($namespace));
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     protected function load(string $index): ?array
87 87
     {
88
-        $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php';
88
+        $file = root.'/I18n/'.env_name.'/'.App::$Request->getLanguage().'/'.$index.'.php';
89 89
         if (!File::exist($file))
90 90
             return [];
91 91
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function getAvailableLangs(): array
122 122
     {
123 123
         $langs = ['en'];
124
-        $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true);
124
+        $scan = Directory::scan(root.'/I18n/'.env_name.'/', GLOB_ONLYDIR, true);
125 125
         foreach ($scan as $row) {
126 126
             $langs[] = trim($row, '/');
127 127
         }
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
                 $this->indexes[] = $index;
49 49
             }
50 50
 
51
-            if ($this->cached && Any::isStr($text) && isset($this->cached[$text]))
52
-                $text = $this->cached[$text];
51
+            if ($this->cached && Any::isStr($text) && isset($this->cached[$text])) {
52
+                            $text = $this->cached[$text];
53
+            }
53 54
         }
54 55
 
55 56
         if (Any::isArray($params) && count($params) > 0) {
@@ -86,8 +87,9 @@  discard block
 block discarded – undo
86 87
     protected function load(string $index): ?array
87 88
     {
88 89
         $file = root . '/I18n/' . env_name . '/' . App::$Request->getLanguage() . '/' . $index . '.php';
89
-        if (!File::exist($file))
90
-            return [];
90
+        if (!File::exist($file)) {
91
+                    return [];
92
+        }
91 93
 
92 94
         return require($file);
93 95
     }
@@ -101,13 +103,15 @@  discard block
 block discarded – undo
101 103
     {
102 104
         $path = Normalize::diskFullPath($path);
103 105
         // check if file exist
104
-        if (!File::exist($path))
105
-            return false;
106
+        if (!File::exist($path)) {
107
+                    return false;
108
+        }
106 109
 
107 110
         // load file translations
108 111
         $addTranslation = require($path);
109
-        if (!Any::isArray($addTranslation))
110
-            return false;
112
+        if (!Any::isArray($addTranslation)) {
113
+                    return false;
114
+        }
111 115
 
112 116
         // merge data
113 117
         $this->cached = Arr::merge($this->cached, $addTranslation);
@@ -142,11 +146,13 @@  discard block
 block discarded – undo
142 146
             $lang = App::$Request->getLanguage();
143 147
         }
144 148
         // unserialize from string to array
145
-        if (Any::isStr($input))
146
-            $input = Serialize::decode($input);
149
+        if (Any::isStr($input)) {
150
+                    $input = Serialize::decode($input);
151
+        }
147 152
 
148
-        if (Any::isArray($input) && array_key_exists($lang, $input))
149
-            return $input[$lang];
153
+        if (Any::isArray($input) && array_key_exists($lang, $input)) {
154
+                    return $input[$lang];
155
+        }
150 156
 
151 157
         return $default;
152 158
     }
Please login to merge, or discard this patch.
src/Ffcms/Core/Managers/EventManager.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use Ffcms\Core\App;
5 5
 use Ffcms\Core\Helper\Type\Any;
6
-use Ffcms\Core\Helper\Type\Obj;
7 6
 
8 7
 /**
9 8
  * Class EventManager. Control and run events.
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,8 +33,9 @@  discard block
 block discarded – undo
33 33
     public function on($event, \Closure $callback): void
34 34
     {
35 35
         // check if event is a single string and parse it to array single item
36
-        if (!Any::isArray($event))
37
-            $event = [$event];
36
+        if (!Any::isArray($event)) {
37
+                    $event = [$event];
38
+        }
38 39
         
39 40
         foreach ($event as $item) {
40 41
             $this->events[$item][] = $callback;
@@ -50,13 +51,15 @@  discard block
 block discarded – undo
50 51
     public function listen($event, \Closure $callback)
51 52
     {
52 53
         // check if $event is a single string and set it as array with one item
53
-        if (!Any::isArray($event))
54
-            $event = [$event];
54
+        if (!Any::isArray($event)) {
55
+                    $event = [$event];
56
+        }
55 57
         
56 58
         // each every one event in array
57 59
         foreach ($event as $item) {
58
-            if (Any::isArray($this->runned) && array_key_exists($item, $this->runned))
59
-                return call_user_func_array($callback, $this->runned[$item]);
60
+            if (Any::isArray($this->runned) && array_key_exists($item, $this->runned)) {
61
+                            return call_user_func_array($callback, $this->runned[$item]);
62
+            }
60 63
         }
61 64
         
62 65
         return false;
@@ -71,8 +74,9 @@  discard block
 block discarded – undo
71 74
         // dynamicly parse input params
72 75
         $args = func_get_args();
73 76
         
74
-        if (count($args) < 1)
75
-            return false;
77
+        if (count($args) < 1) {
78
+                    return false;
79
+        }
76 80
         
77 81
         // get event name
78 82
         $eventName = array_shift($args);
Please login to merge, or discard this patch.
src/Ffcms/Core/Managers/MigrationsManager.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Ffcms\Core\Helper\FileSystem\Normalize;
9 9
 use Ffcms\Core\Helper\Type\Any;
10 10
 use Ffcms\Core\Helper\Type\Arr;
11
-use Ffcms\Core\Helper\Type\Obj;
12 11
 use Ffcms\Core\Helper\Type\Str;
13 12
 
14 13
 /**
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 continue;
71 71
             }
72 72
             // check initialize conditions (equals to $exist)
73
-            if (File::exist($this->dir . '/' . $migration)) {
73
+            if (File::exist($this->dir.'/'.$migration)) {
74 74
                 if (Arr::in($fullName, $dbmigrations) === $exist) {
75 75
                     $found[] = $migration;
76 76
                 }
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         // check if migration file is exists
103
-        if (!File::exist($this->dir . '/' . $file))
103
+        if (!File::exist($this->dir.'/'.$file))
104 104
             return false;
105 105
 
106 106
         // check if migration file located in extend directory and copy to default
107 107
         if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) {
108
-            File::copy($this->dir . DIRECTORY_SEPARATOR . $file, static::DEFAULT_DIR . DIRECTORY_SEPARATOR . $file);
108
+            File::copy($this->dir.DIRECTORY_SEPARATOR.$file, static::DEFAULT_DIR.DIRECTORY_SEPARATOR.$file);
109 109
         }
110 110
 
111 111
         // include migration and get class name
112
-        File::inc($this->dir . '/' . $file, false, false);
112
+        File::inc($this->dir.'/'.$file, false, false);
113 113
         $fullName = Str::cleanExtension($file);
114 114
         $class = Str::firstIn($fullName, '-');
115 115
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         }
145 145
 
146 146
         // check if exists
147
-        if (!File::exist($this->dir . '/' . $file))
147
+        if (!File::exist($this->dir.'/'.$file))
148 148
             return false;
149 149
 
150
-        File::inc($this->dir . '/' . $file, false, false);
150
+        File::inc($this->dir.'/'.$file, false, false);
151 151
         $fullName = Str::cleanExtension($file);
152 152
         $class = Str::firstIn($fullName, '-');
153 153
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,14 +30,16 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function __construct(?string $dir = null, ?string $connectionName = null)
32 32
     {
33
-        if ($dir === null)
34
-            $dir = static::DEFAULT_DIR;
33
+        if ($dir === null) {
34
+                    $dir = static::DEFAULT_DIR;
35
+        }
35 36
 
36 37
         $this->dir = rtrim($dir, '/');
37 38
         $this->connection = $connectionName;
38 39
 
39
-        if ($this->dir !== static::DEFAULT_DIR)
40
-            $this->customDir = true;
40
+        if ($this->dir !== static::DEFAULT_DIR) {
41
+                    $this->customDir = true;
42
+        }
41 43
     }
42 44
 
43 45
     /**
@@ -50,16 +52,18 @@  discard block
 block discarded – undo
50 52
     {
51 53
         // initialize db migration record
52 54
         $records = new Migration();
53
-        if ($this->connection !== null)
54
-            $records->setConnection($this->connection);
55
+        if ($this->connection !== null) {
56
+                    $records->setConnection($this->connection);
57
+        }
55 58
 
56 59
         // get installed migrations
57 60
         $dbmigrations = Arr::pluck('migration', $records->get()->toArray());
58 61
 
59 62
         // list migrations
60 63
         $migrations = File::listFiles($this->dir, ['.php'], true);
61
-        if (!Any::isArray($migrations) || count($migrations) < 1)
62
-            return false;
64
+        if (!Any::isArray($migrations) || count($migrations) < 1) {
65
+                    return false;
66
+        }
63 67
 
64 68
         $found = false;
65 69
         foreach ($migrations as $migration) {
@@ -100,8 +104,9 @@  discard block
 block discarded – undo
100 104
         }
101 105
 
102 106
         // check if migration file is exists
103
-        if (!File::exist($this->dir . '/' . $file))
104
-            return false;
107
+        if (!File::exist($this->dir . '/' . $file)) {
108
+                    return false;
109
+        }
105 110
 
106 111
         // check if migration file located in extend directory and copy to default
107 112
         if (Normalize::diskFullPath($this->dir) !== Normalize::diskFullPath(static::DEFAULT_DIR)) {
@@ -114,8 +119,9 @@  discard block
 block discarded – undo
114 119
         $class = Str::firstIn($fullName, '-');
115 120
 
116 121
         // check if class is instance of migration interface
117
-        if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true))
118
-            return false;
122
+        if (!class_exists($class) || !is_a($class, 'Ffcms\Core\Migrations\MigrationInterface', true)) {
123
+                    return false;
124
+        }
119 125
 
120 126
         // implement migration
121 127
         $init = new $class($fullName, $this->connection);
@@ -144,8 +150,9 @@  discard block
 block discarded – undo
144 150
         }
145 151
 
146 152
         // check if exists
147
-        if (!File::exist($this->dir . '/' . $file))
148
-            return false;
153
+        if (!File::exist($this->dir . '/' . $file)) {
154
+                    return false;
155
+        }
149 156
 
150 157
         File::inc($this->dir . '/' . $file, false, false);
151 158
         $fullName = Str::cleanExtension($file);
Please login to merge, or discard this patch.
src/Ffcms/Core/Traits/ModelValidator.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Ffcms\Core\Exception\SyntaxException;
9 9
 use Ffcms\Core\Helper\ModelFilters;
10 10
 use Ffcms\Core\Helper\Type\Any;
11
-use Ffcms\Core\Helper\Type\Obj;
12 11
 use Ffcms\Core\Helper\Type\Str;
13 12
 
14 13
 /**
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                     } elseif (method_exists($class, $obj)) { // maybe its a function?
138 138
                         $class = $class::$obj; // call function
139 139
                     } else {
140
-                        throw new SyntaxException('Filter callback execution failed: ' . $filterName);
140
+                        throw new SyntaxException('Filter callback execution failed: '.$filterName);
141 141
                     }
142 142
                 }
143 143
             }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             if (method_exists($class, $method)) {
147 147
                 $check = @$class::$method($fieldValue, $filterArgs);
148 148
             } else {
149
-                throw new SyntaxException('Filter callback execution failed: ' . $filterName);
149
+                throw new SyntaxException('Filter callback execution failed: '.$filterName);
150 150
             }
151 151
         } elseif (method_exists('Ffcms\Core\Helper\ModelFilters', $filterName)) { // only full namespace\class path based :(
152 152
             if ($filterArgs != null) {
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
                 $check = ModelFilters::$filterName($fieldValue);
156 156
             }
157 157
         } else {
158
-            throw new SyntaxException('Filter "' . $filterName . '" is not exist');
158
+            throw new SyntaxException('Filter "'.$filterName.'" is not exist');
159 159
         }
160 160
 
161 161
         // if one from all validation tests is fail - mark as incorrect attribute
162 162
         if ($check !== true) {
163 163
             $this->_badAttr[] = $propertyName;
164 164
             if (App::$Debug)
165
-                App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning');
165
+                App::$Debug->addMessage('Validation failed. Property: '.$propertyName.', filter: '.$filterName, 'warning');
166 166
         } else {
167 167
             $field_set_name = $propertyName;
168 168
             // prevent array-type setting
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -59,21 +59,24 @@  discard block
 block discarded – undo
59 59
     public function runValidate(array $rules = null)
60 60
     {
61 61
         // skip validation on empty rules
62
-        if ($rules === null)
63
-            return true;
62
+        if ($rules === null) {
63
+                    return true;
64
+        }
64 65
 
65 66
         $success = true;
66 67
         // list each rule as single one
67 68
         foreach ($rules as $rule) {
68 69
             // 0 = field (property) name, 1 = filter name, 2 = filter value
69
-            if ($rule[0] === null || $rule[1] === null)
70
-                continue;
70
+            if ($rule[0] === null || $rule[1] === null) {
71
+                            continue;
72
+            }
71 73
 
72 74
             $propertyName = $rule[0];
73 75
             $validationRule = $rule[1];
74 76
             $validationValue = null;
75
-            if (isset($rule[2]))
76
-                $validationValue = $rule[2];
77
+            if (isset($rule[2])) {
78
+                            $validationValue = $rule[2];
79
+            }
77 80
 
78 81
             // check if target field defined as array and make recursive validation
79 82
             if (Any::isArray($propertyName)) {
@@ -161,8 +164,9 @@  discard block
 block discarded – undo
161 164
         // if one from all validation tests is fail - mark as incorrect attribute
162 165
         if ($check !== true) {
163 166
             $this->_badAttr[] = $propertyName;
164
-            if (App::$Debug)
165
-                App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning');
167
+            if (App::$Debug) {
168
+                            App::$Debug->addMessage('Validation failed. Property: ' . $propertyName . ', filter: ' . $filterName, 'warning');
169
+            }
166 170
         } else {
167 171
             $field_set_name = $propertyName;
168 172
             // prevent array-type setting
@@ -173,8 +177,9 @@  discard block
 block discarded – undo
173 177
                 if ($propertyName !== $field_set_name) { // array-based property
174 178
                     $dot_path = trim(strstr($propertyName, '.'), '.');
175 179
                     // prevent throws any exceptions for null and false objects
176
-                    if (!Any::isArray($this->{$field_set_name}))
177
-                        $this->{$field_set_name} = [];
180
+                    if (!Any::isArray($this->{$field_set_name})) {
181
+                                            $this->{$field_set_name} = [];
182
+                    }
178 183
 
179 184
                     // use dot-data provider to compile output array
180 185
                     $dotData = new DotData($this->{$field_set_name});
@@ -204,14 +209,16 @@  discard block
 block discarded – undo
204 209
         $sources = $this->sources();
205 210
         $types = $this->types();
206 211
         // validate sources for current field
207
-        if (array_key_exists($propertyName, $sources))
208
-            $inputType = Str::lowerCase($sources[$propertyName]);
212
+        if (array_key_exists($propertyName, $sources)) {
213
+                    $inputType = Str::lowerCase($sources[$propertyName]);
214
+        }
209 215
 
210 216
 
211 217
         // check if field is array-nested element by dots and use first element as general
212 218
         $filterField = $propertyName;
213
-        if (array_key_exists($filterField, $types))
214
-            $filterType = Str::lowerCase($types[$filterField]);
219
+        if (array_key_exists($filterField, $types)) {
220
+                    $filterType = Str::lowerCase($types[$filterField]);
221
+        }
215 222
 
216 223
         // get clear field value
217 224
         $propertyValue = $this->getRequest($propertyName, $inputType);
@@ -313,8 +320,9 @@  discard block
 block discarded – undo
313 320
      */
314 321
     public function getRequest($param, $method = null)
315 322
     {
316
-        if ($method === null)
317
-            $method = $this->_sendMethod;
323
+        if ($method === null) {
324
+                    $method = $this->_sendMethod;
325
+        }
318 326
 
319 327
         $method = Str::lowerCase($method);
320 328
         // get root request as array or string
@@ -338,8 +346,9 @@  discard block
 block discarded – undo
338 346
         if (Str::contains('.', $param)) {
339 347
             $response = $request;
340 348
             foreach (explode('.', $param) as $path) {
341
-                if (!array_key_exists($path, $response))
342
-                    return null;
349
+                if (!array_key_exists($path, $response)) {
350
+                                    return null;
351
+                }
343 352
                 // find deep array nesting offset
344 353
                 $response = $response[$path];
345 354
             }
Please login to merge, or discard this patch.
src/Ffcms/Core/Debug/Manager.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
         $this->render = $this->bar->getJavascriptRenderer();
30 30
         try {
31 31
             $this->bar->addCollector(new ConfigCollector());
32
-        } catch (\Exception $oe){}
32
+        } catch (\Exception $oe) {}
33 33
     }
34 34
 
35 35
     /**
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@
 block discarded – undo
80 80
      */
81 81
     public function addMessage($m, $type = 'info')
82 82
     {
83
-        if (!Any::isStr($m) || !Any::isStr($type))
84
-            return;
83
+        if (!Any::isStr($m) || !Any::isStr($type)) {
84
+                    return;
85
+        }
85 86
 
86 87
         $m = App::$Security->secureHtml($m);
87 88
         try {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -5,10 +5,8 @@
 block discarded – undo
5 5
 use Cassandra\Exception;
6 6
 use DebugBar\DataCollector\ConfigCollector;
7 7
 use DebugBar\DebugBarException;
8
-use DebugBar\StandardDebugBar;
9 8
 use Ffcms\Core\App;
10 9
 use Ffcms\Core\Helper\Type\Any;
11
-use Ffcms\Core\Helper\Type\Obj;
12 10
 
13 11
 /**
14 12
  * Class Debug. Provide methods of display information about debug and collected data in debug bar
Please login to merge, or discard this patch.