Passed
Push — master ( 6080f3...d98100 )
by Sebastian
03:12
created
src/Request/URLComparer.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     
82 82
     public function addLimitParam(string $name) : Request_URLComparer
83 83
     {
84
-        if(!in_array($name, $this->limitParams, true))
84
+        if (!in_array($name, $this->limitParams, true))
85 85
         {
86 86
             $this->limitParams[] = $name;
87 87
         }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function addLimitParams(array $names) : Request_URLComparer
97 97
     {
98
-        foreach($names as $name)
98
+        foreach ($names as $name)
99 99
         {
100 100
             $this->addLimitParam($name);
101 101
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         return $this;
104 104
     }
105 105
     
106
-    public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer
106
+    public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer
107 107
     {
108 108
         $this->ignoreFragment = $ignore;
109 109
         return $this;
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
             'query' 
127 127
         );
128 128
         
129
-        if(!$this->ignoreFragment) {
129
+        if (!$this->ignoreFragment) {
130 130
             $keys[] = 'fragment';
131 131
         }
132 132
         
133
-        foreach($keys as $key)
133
+        foreach ($keys as $key)
134 134
         {
135
-            if(!$this->compareKey($key)) {
135
+            if (!$this->compareKey($key)) {
136 136
                 return false;
137 137
             }
138 138
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         
148 148
         $filter = 'filter_'.$key;
149 149
         
150
-        if(method_exists($this, $filter)) 
150
+        if (method_exists($this, $filter)) 
151 151
         {
152 152
             $sVal = $this->$filter($sVal);
153 153
             $tVal = $this->$filter($tVal);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     protected function filter_path(string $path) : string
160 160
     {
161 161
         // fix double slashes in URLs
162
-        while(strpos($path, '//') !== false)
162
+        while (strpos($path, '//') !== false)
163 163
         {
164 164
             $path = str_replace('//', '/', $path);
165 165
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     
170 170
     protected function filter_query(string $query) : string
171 171
     {
172
-        if(empty($query)) {
172
+        if (empty($query)) {
173 173
             return '';
174 174
         }
175 175
         
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
      */
189 189
     protected function limitParams(array $params) : array
190 190
     {
191
-        if(empty($this->limitParams)) {
191
+        if (empty($this->limitParams)) {
192 192
             return $params;
193 193
         }
194 194
         
195 195
         $keep = array();
196 196
         
197
-        foreach($this->limitParams as $name)
197
+        foreach ($this->limitParams as $name)
198 198
         {
199
-            if(isset($params[$name])) {
199
+            if (isset($params[$name])) {
200 200
                 $keep[$name] = $params[$name];
201 201
             }
202 202
         }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
  * @param bool $forceNew
13 13
  * @return NumberInfo
14 14
  */
15
-function parseNumber($value, bool $forceNew=false)
15
+function parseNumber($value, bool $forceNew = false)
16 16
 {
17
-    if($value instanceof NumberInfo && $forceNew !== true) {
17
+    if ($value instanceof NumberInfo && $forceNew !== true) {
18 18
         return $value;
19 19
     }
20 20
     
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     $args = func_get_args();
110 110
     
111 111
     // is the localization package installed?
112
-    if(function_exists('\AppLocalize\t'))
112
+    if (function_exists('\AppLocalize\t'))
113 113
     {
114 114
         return call_user_func_array('\AppLocalize\t', $args);
115 115
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  * @param bool $initial The initial boolean value to use.
125 125
  * @return Value_Bool
126 126
  */
127
-function valBool(bool $initial=false) : Value_Bool
127
+function valBool(bool $initial = false) : Value_Bool
128 128
 {
129 129
     return new Value_Bool($initial);
130 130
 }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
  * @param bool $initial
138 138
  * @return Value_Bool_True
139 139
  */
140
-function valBoolTrue(bool $initial=false) : Value_Bool_True
140
+function valBoolTrue(bool $initial = false) : Value_Bool_True
141 141
 {
142 142
     return new Value_Bool_True($initial);
143 143
 }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
  * @param bool $initial
151 151
  * @return Value_Bool_False
152 152
  */
153
-function valBoolFalse(bool $initial=true) : Value_Bool_False
153
+function valBoolFalse(bool $initial = true) : Value_Bool_False
154 154
 {
155 155
     return new Value_Bool_False($initial);
156 156
 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
  */
182 182
 function init() : void
183 183
 {
184
-    if(!class_exists('\AppLocalize\Localization')) {
184
+    if (!class_exists('\AppLocalize\Localization')) {
185 185
         return;
186 186
     }
187 187
     
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @param int $tabSize The amount of spaces per tab.
56 56
      * @return string
57 57
      */
58
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
58
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
59 59
     {
60 60
         return ConvertHelper_String::tabs2spaces($string, $tabSize);
61 61
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     * @param int $tabSize The amount of spaces per tab in the source string.
68 68
     * @return string
69 69
     */
70
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
70
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
71 71
     {
72 72
         return ConvertHelper_String::spaces2tabs($string, $tabSize);
73 73
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     * @deprecated Use the Highlighter class directly instead.
141 141
     * @see Highlighter::xml()
142 142
     */
143
-    public static function highlight_xml(string $xml, bool $formatSource=false) : string
143
+    public static function highlight_xml(string $xml, bool $formatSource = false) : string
144 144
     {
145 145
         return Highlighter::xml($xml, $formatSource);
146 146
     }
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
      * @param bool $html
207 207
      * @return string
208 208
      */
209
-    public static function var_dump($var, bool $html=true) : string
209
+    public static function var_dump($var, bool $html = true) : string
210 210
     {
211 211
         $info = parseVariable($var);
212 212
         
213
-        if($html) {
213
+        if ($html) {
214 214
             return $info->toHTML();
215 215
         }
216 216
         
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
     * @param bool $html Whether to style the dump as HTML.
226 226
     * @return string
227 227
     */
228
-    public static function print_r($var, bool $return=false, bool $html=true) : string
228
+    public static function print_r($var, bool $return = false, bool $html = true) : string
229 229
     {
230 230
         $result = parseVariable($var)->enableType()->toString();
231 231
         
232
-        if($html) 
232
+        if ($html) 
233 233
         {
234 234
             $result = 
235 235
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             '</pre>';
238 238
         }
239 239
         
240
-        if(!$return) 
240
+        if (!$return) 
241 241
         {
242 242
             echo $result;
243 243
         }
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
         $output = '';
420 420
         $split = str_split($unicodeChar);
421 421
         
422
-        foreach($split as $octet) 
422
+        foreach ($split as $octet) 
423 423
         {
424 424
             $ordInt = ord($octet);
425 425
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
426 426
             $ordHex = base_convert((string)$ordInt, 10, 16);
427
-            $output .= '\x' . $ordHex;
427
+            $output .= '\x'.$ordHex;
428 428
         }
429 429
         
430 430
         return $output;
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
     * 
639 639
     * @see JSHelper::buildRegexStatement()
640 640
     */
641
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string
641
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) : string
642 642
     {
643 643
         return JSHelper::buildRegexStatement($regex, $statementType);
644 644
     }
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
     * @throws ConvertHelper_Exception
658 658
     * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
659 659
     */
660
-    public static function var2json($variable, int $options=0, int $depth=512) : string
660
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
661 661
     {
662 662
         $result = json_encode($variable, $options, $depth);
663 663
         
664
-        if($result !== false) {
664
+        if ($result !== false) {
665 665
             return $result;
666 666
         }
667 667
         
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
     {
702 702
         $boms = FileHelper::createUnicodeHandling()->getUTFBOMs();
703 703
 
704
-        foreach($boms as $bomChars)
704
+        foreach ($boms as $bomChars)
705 705
         {
706 706
             $length = mb_strlen($bomChars);
707 707
             $text = mb_substr($string, 0, $length);
708 708
 
709
-            if($text===$bomChars)
709
+            if ($text === $bomChars)
710 710
             {
711 711
                 return mb_substr($string, $length);
712 712
             }
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
     * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE
779 779
     * @see ConvertHelper_TextComparer::OPTION_PRECISION
780 780
     */
781
-    public static function matchString(string $source, string $target, array $options=array()) : float
781
+    public static function matchString(string $source, string $target, array $options = array()) : float
782 782
     {
783 783
         return (new ConvertHelper_TextComparer())
784 784
             ->setOptions($options)
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
     * @see ConvertHelper::INTERVAL_HOURS
857 857
     * @see ConvertHelper::INTERVAL_DAYS
858 858
     */
859
-    public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int
859
+    public static function interval2total(DateInterval $interval, string $unit = self::INTERVAL_SECONDS) : int
860 860
     {
861 861
         return ConvertHelper_DateInterval::toTotal($interval, $unit);
862 862
     }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
     * @param bool $short
869 869
     * @return string|NULL
870 870
     */
871
-    public static function date2dayName(DateTime $date, bool $short=false) : ?string
871
+    public static function date2dayName(DateTime $date, bool $short = false) : ?string
872 872
     {
873 873
         return ConvertHelper_Date::toDayName($date, $short);
874 874
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
     * @param bool $short
889 889
     * @return string[]
890 890
     */
891
-    public static function getDayNames(bool $short=false) : array
891
+    public static function getDayNames(bool $short = false) : array
892 892
     {
893 893
         return ConvertHelper_Date::getDayNames($short);
894 894
     }
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
     * @param bool $caseInsensitive
1048 1048
     * @return ConvertHelper_StringMatch[]
1049 1049
     */
1050
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1050
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array
1051 1051
     {
1052 1052
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1053 1053
     }
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
     */
1098 1098
     public static function isInteger($value) : bool
1099 1099
     {
1100
-        if(is_int($value)) {
1100
+        if (is_int($value)) {
1101 1101
             return true;
1102 1102
         }
1103 1103
         
1104 1104
         // booleans get converted to numbers, so they would
1105 1105
         // actually match the regex.
1106
-        if(is_bool($value)) {
1106
+        if (is_bool($value)) {
1107 1107
             return false;
1108 1108
         }
1109 1109
         
1110
-        if(is_string($value) && $value !== '') {
1110
+        if (is_string($value) && $value !== '') {
1111 1111
             return preg_match('/\A-?\d+\z/', $value) === 1;
1112 1112
         }
1113 1113
         
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
      * @param bool $keepKeys
1174 1174
      * @return array<number|string,mixed>
1175 1175
      */
1176
-    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys=false) : array
1176
+    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys = false) : array
1177 1177
     {
1178 1178
         return ConvertHelper_Array::removeValues($sourceArray, $values, $keepKeys);
1179 1179
     }
Please login to merge, or discard this patch.
src/FileHelper/UploadFileSizeInfo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
52 52
         $result = (float)preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
53 53
 
54
-        if($unit)
54
+        if ($unit)
55 55
         {
56 56
             // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
57 57
             return (int)round($result * (1024 ** stripos('bkmgtpezy', $unit[0])));
Please login to merge, or discard this patch.
src/FileHelper/PathRelativizer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * @param int $depth The folder depth to reduce the path to
19 19
      * @return string
20 20
      */
21
-    public static function relativizeByDepth(string $path, int $depth=2) : string
21
+    public static function relativizeByDepth(string $path, int $depth = 2) : string
22 22
     {
23 23
         $path = FileHelper::normalizePath($path);
24 24
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
         $tokens = array_filter($tokens); // remove empty entries (trailing slash for example)
27 27
         $tokens = array_values($tokens); // re-index keys
28 28
 
29
-        if(empty($tokens)) {
29
+        if (empty($tokens)) {
30 30
             return '';
31 31
         }
32 32
 
33 33
         // remove the drive if present
34
-        if(strpos($tokens[0], ':') !== false) {
34
+        if (strpos($tokens[0], ':') !== false) {
35 35
             array_shift($tokens);
36 36
         }
37 37
 
38 38
         // path was only the drive
39
-        if(count($tokens) === 0) {
39
+        if (count($tokens) === 0) {
40 40
             return '';
41 41
         }
42 42
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 
46 46
         // reduce the path to the specified depth
47 47
         $length = count($tokens);
48
-        if($length > $depth) {
49
-            $tokens = array_slice($tokens, $length-$depth);
48
+        if ($length > $depth) {
49
+            $tokens = array_slice($tokens, $length - $depth);
50 50
         }
51 51
 
52 52
         // append the last element again
Please login to merge, or discard this patch.
src/FileHelper/FileFinder.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @see \AppUtils\FileHelper\FileFinder
8 8
  */
9 9
 
10
-declare(strict_types = 1);
10
+declare(strict_types=1);
11 11
 
12 12
 namespace AppUtils\FileHelper;
13 13
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param bool $enabled
91 91
      * @return FileFinder
92 92
      */
93
-    public function makeRecursive(bool $enabled=true) : FileFinder
93
+    public function makeRecursive(bool $enabled = true) : FileFinder
94 94
     {
95 95
         return $this->setOption('recursive', $enabled);
96 96
     }
@@ -295,22 +295,22 @@  discard block
 block discarded – undo
295 295
         return $this->getAll();
296 296
     }
297 297
     
298
-    protected function find(string $path, bool $isRoot=false) : void
298
+    protected function find(string $path, bool $isRoot = false) : void
299 299
     {
300
-        if($isRoot) {
300
+        if ($isRoot) {
301 301
             $this->found = array();
302 302
         }
303 303
         
304 304
         $recursive = $this->getBoolOption('recursive');
305 305
         
306 306
         $d = new DirectoryIterator($path);
307
-        foreach($d as $item)
307
+        foreach ($d as $item)
308 308
         {
309 309
             $pathname = $item->getPathname();
310 310
             
311
-            if($item->isDir())
311
+            if ($item->isDir())
312 312
             {
313
-                if($recursive && !$item->isDot()) {
313
+                if ($recursive && !$item->isDot()) {
314 314
                     $this->find($pathname);
315 315
                 }
316 316
                 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             
320 320
             $file = $this->filterFile($pathname);
321 321
             
322
-            if($file !== null) 
322
+            if ($file !== null) 
323 323
             {
324 324
                 $this->found[] = $file;
325 325
             }
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
         
333 333
         $extension = FileHelper::getExtension($path);
334 334
         
335
-        if(!$this->filterExclusion($extension)) {
335
+        if (!$this->filterExclusion($extension)) {
336 336
             return null;
337 337
         }
338 338
         
339 339
         $path = $this->filterPath($path);
340 340
         
341
-        if($this->getOption('strip-extensions') === true)
341
+        if ($this->getOption('strip-extensions') === true)
342 342
         {
343 343
             $path = str_replace('.'.$extension, '', $path);
344 344
         }
345 345
         
346
-        if($path === '') {
346
+        if ($path === '') {
347 347
             return null;
348 348
         }
349 349
         
350 350
         $replace = $this->getOption('slash-replacement');
351
-        if(!empty($replace)) {
351
+        if (!empty($replace)) {
352 352
             $path = str_replace('/', $replace, $path);
353 353
         }
354 354
         
@@ -367,13 +367,13 @@  discard block
 block discarded – undo
367 367
         $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS);
368 368
         $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS);
369 369
         
370
-        if(!empty($include))
370
+        if (!empty($include))
371 371
         {
372
-            if(!in_array($extension, $include, true)) {
372
+            if (!in_array($extension, $include, true)) {
373 373
                 return false;
374 374
             }
375 375
         }
376
-        else if(!empty($exclude) && in_array($extension, $exclude, true))
376
+        else if (!empty($exclude) && in_array($extension, $exclude, true))
377 377
         {
378 378
             return false;
379 379
         }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     */
390 390
     protected function filterPath(string $path) : string
391 391
     {
392
-        switch($this->getStringOption(self::OPTION_PATHMODE))
392
+        switch ($this->getStringOption(self::OPTION_PATHMODE))
393 393
         {
394 394
             case self::PATH_MODE_STRIP:
395 395
                 return basename($path);
Please login to merge, or discard this patch.
src/Request/RequestParam.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @return $this
125 125
      * @throws Request_Exception
126 126
      */
127
-    public function setCallback(callable $callback, array $args=array()) : self
127
+    public function setCallback(callable $callback, array $args = array()) : self
128 128
     {
129 129
         return $this->setValidation(
130 130
             self::VALIDATION_TYPE_CALLBACK, 
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
         // first off, apply filtering
150 150
         $value = $this->filter($value);
151 151
         
152
-        if($this->valueType === self::VALUE_TYPE_LIST)
152
+        if ($this->valueType === self::VALUE_TYPE_LIST)
153 153
         {
154
-            if(!is_array($value))
154
+            if (!is_array($value))
155 155
             {
156 156
                 $value = explode(',', $value);
157 157
             }
158 158
             
159 159
             $keep = array();
160 160
             
161
-            foreach($value as $subval)
161
+            foreach ($value as $subval)
162 162
             {
163 163
                 $subval = $this->filter($subval);
164 164
                 
165 165
                 $subval = $this->applyValidations($subval, true);
166 166
 
167
-                if($subval !== null) {
167
+                if ($subval !== null) {
168 168
                     $keep[] = $subval;
169 169
                 }
170 170
             }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     * @param mixed $value
184 184
     * @return mixed
185 185
     */
186
-    protected function applyValidations($value, bool $subval=false)
186
+    protected function applyValidations($value, bool $subval = false)
187 187
     {
188 188
         // go through all enqueued validations in turn, each time
189 189
         // replacing the value with the adjusted, validated value.
190
-        foreach($this->validations as $validateDef)
190
+        foreach ($this->validations as $validateDef)
191 191
         {
192 192
             $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval);
193 193
         }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     {
211 211
         $class = Request_Param_Validator::class.'_'.ucfirst($type);
212 212
         
213
-        if(!class_exists($class))
213
+        if (!class_exists($class))
214 214
         {
215 215
             throw new Request_Exception(
216 216
                 'Unknown validation type.',
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     {
362 362
         $args = func_get_args(); // cannot be used as function parameter in some PHP versions
363 363
         
364
-        if(is_array($args[0])) 
364
+        if (is_array($args[0])) 
365 365
         {
366 366
             $args = $args[0];
367 367
         }
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
     * @param mixed $default
512 512
     * @return mixed
513 513
     */
514
-    public function get($default=null)
514
+    public function get($default = null)
515 515
     {
516 516
         $value = $this->request->getParam($this->paramName);
517
-        if($value !== null && $value !== '') {
517
+        if ($value !== null && $value !== '') {
518 518
             return $value;
519 519
         }
520 520
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     {
539 539
         foreach ($this->filters as $filter)
540 540
         {
541
-            $method = 'applyFilter_' . $filter['type'];
541
+            $method = 'applyFilter_'.$filter['type'];
542 542
             $value = $this->$method($value, $filter['params']);
543 543
         }
544 544
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         
558 558
         $filter = new $class($this);
559 559
 
560
-        if($filter instanceof Request_Param_Filter)
560
+        if ($filter instanceof Request_Param_Filter)
561 561
         {
562 562
             $filter->setOptions($config['params']);
563 563
             return $filter->filter($value);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
     * @param bool $stripEmptyEntries Remove empty entries from the array?
717 717
     * @return $this
718 718
     */
719
-    public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self
719
+    public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : self
720 720
     {
721 721
         $this->setArray();
722 722
         
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      * @return $this
736 736
      * @throws Request_Exception
737 737
      */
738
-    protected function addClassFilter(string $name, array $params=array()) : self
738
+    protected function addClassFilter(string $name, array $params = array()) : self
739 739
     {
740 740
         return $this->addFilter(
741 741
             self::FILTER_TYPE_CLASS,
Please login to merge, or discard this patch.
src/CSVHelper.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     
171 171
     public function isHeadersPosition($position)
172 172
     {
173
-        if($this->headersPosition === $position) {
173
+        if ($this->headersPosition === $position) {
174 174
             return true;
175 175
         }
176 176
         
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             self::HEADERS_TOP
198 198
         );
199 199
         
200
-        if(!in_array($position, $validPositions)) {
200
+        if (!in_array($position, $validPositions)) {
201 201
             throw new CSVHelper_Exception(
202 202
                 'Invalid headers position',
203 203
                 sprintf(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     */
254 254
     public function getRow($index)
255 255
     {
256
-        if(isset($this->data[$index])) {
256
+        if (isset($this->data[$index])) {
257 257
             return $this->data[$index];
258 258
         }
259 259
         
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
     public function getColumn($index)
321 321
     {
322 322
         $data = array();
323
-        for($i=0; $i < $this->rowCount; $i++) {
323
+        for ($i = 0; $i < $this->rowCount; $i++) {
324 324
             $value = '';
325
-            if(isset($this->data[$i][$index])) {
325
+            if (isset($this->data[$i][$index])) {
326 326
                 $value = $this->data[$i][$index];
327 327
             }
328 328
             
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     */
340 340
     public function columnExists($index)
341 341
     {
342
-        if($index < $this->columnCount) {
342
+        if ($index < $this->columnCount) {
343 343
             return true;
344 344
         }
345 345
         
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     {
351 351
         $this->reset();
352 352
         
353
-        if(empty(trim($this->csv))) {
353
+        if (empty(trim($this->csv))) {
354 354
             $this->addError('Tried to parse an empty CSV string.');
355 355
             return;
356 356
         }
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
         
363 363
         $parser = self::createParser();
364 364
 
365
-        if(!$parser->parse($this->csv)) {
365
+        if (!$parser->parse($this->csv)) {
366 366
             $this->addError('The CSV string could not be parsed.');
367 367
             return;
368 368
         }
369 369
 
370 370
         $result = $parser->data;
371 371
 
372
-        switch($this->headersPosition)
372
+        switch ($this->headersPosition)
373 373
         {
374 374
             case self::HEADERS_TOP:
375 375
                 $this->headers = array_shift($result);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             case self::HEADERS_LEFT:
379 379
                 $keep = array();
380 380
                 $total = count($result);
381
-                for($i=0; $i < $total; $i++) {
381
+                for ($i = 0; $i < $total; $i++) {
382 382
                     $row = $result[$i];
383 383
                     $this->headers[] = array_shift($row);
384 384
                     $keep[] = $row;
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
         $this->data = $result;
392 392
         $this->rowCount = count($this->data);
393 393
         
394
-        for($i=0; $i < $this->rowCount; $i++) {
394
+        for ($i = 0; $i < $this->rowCount; $i++) {
395 395
             $amount = count($this->data[$i]);
396
-            if($amount > $this->columnCount) {
396
+            if ($amount > $this->columnCount) {
397 397
                 $this->columnCount = $amount;
398 398
             }
399 399
         }
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
             ',,' => ','
438 438
         );
439 439
         
440
-        foreach($search as $char => $separator) {
441
-            if(strstr($this->csv, $char)) {
440
+        foreach ($search as $char => $separator) {
441
+            if (strstr($this->csv, $char)) {
442 442
                 return $separator;
443 443
             }
444 444
         }
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
      * @param string $delimiter
453 453
      * @return Csv
454 454
      */
455
-    public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv
455
+    public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv
456 456
     {
457 457
         $csv = new Csv();
458 458
 
459
-        if($delimiter !== self::DELIMITER_AUTO) {
459
+        if ($delimiter !== self::DELIMITER_AUTO) {
460 460
             $csv->delimiter = $delimiter;
461 461
         }
462 462
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 
485 485
         $result = $parser->auto($path);
486 486
 
487
-        if(is_string($result)) {
487
+        if (is_string($result)) {
488 488
             return $parser->data;
489 489
         }
490 490
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
         $parser = self::createParser();
518 518
         $result = $parser->parse($string);
519 519
 
520
-        if($result === true) {
520
+        if ($result === true) {
521 521
             return $parser->data;
522 522
         }
523 523
 
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $value = $_REQUEST[$name] ?? $default;
93 93
 
94
-        if(isset($this->knownParams[$name])) {
94
+        if (isset($this->knownParams[$name])) {
95 95
             $value = $this->knownParams[$name]->validate($value);
96 96
         }
97 97
         
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
189 189
      * @return string
190 190
      */
191
-    public function buildURL(array $params = array(), string $dispatcher='') : string
191
+    public function buildURL(array $params = array(), string $dispatcher = '') : string
192 192
     {
193
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
193
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
194 194
         
195 195
         // append any leftover parameters to the end of the URL
196 196
         if (!empty($params)) {
197
-            $url .= '?' . http_build_query($params, '', '&amp;');
197
+            $url .= '?'.http_build_query($params, '', '&amp;');
198 198
         }
199 199
         
200 200
         return $url;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function registerParam(string $name) : RequestParam
227 227
     {
228
-        if(!isset($this->knownParams[$name])) {
228
+        if (!isset($this->knownParams[$name])) {
229 229
             $param = new RequestParam($this, $name);
230 230
             $this->knownParams[$name] = $param;
231 231
         }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     */
243 243
     public function getRegisteredParam(string $name) : RequestParam
244 244
     {
245
-        if(isset($this->knownParams[$name])) {
245
+        if (isset($this->knownParams[$name])) {
246 246
             return $this->knownParams[$name];
247 247
         }
248 248
         
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     {
303 303
         static $accept;
304 304
         
305
-        if(!isset($accept)) {
305
+        if (!isset($accept)) {
306 306
             $accept = new Request_AcceptHeaders();
307 307
         }
308 308
         
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     {
322 322
         $_REQUEST[$name] = $value;
323 323
         
324
-        if(isset($this->knownParams[$name])) {
324
+        if (isset($this->knownParams[$name])) {
325 325
             unset($this->knownParams[$name]);
326 326
         }
327 327
         
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
     */
352 352
     public function removeParam(string $name) : Request
353 353
     {
354
-        if(isset($_REQUEST[$name])) {
354
+        if (isset($_REQUEST[$name])) {
355 355
             unset($_REQUEST[$name]);
356 356
         }
357 357
         
358
-        if(isset($this->knownParams[$name])) {
358
+        if (isset($this->knownParams[$name])) {
359 359
             unset($this->knownParams[$name]);
360 360
         }
361 361
         
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     */
371 371
     public function removeParams(array $names) : Request
372 372
     {
373
-        foreach($names as $name) {
373
+        foreach ($names as $name) {
374 374
             $this->removeParam($name);
375 375
         }
376 376
         
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
      * @return bool
389 389
      * @throws ConvertHelper_Exception
390 390
      */
391
-    public function getBool(string $name, bool $default=false) : bool
391
+    public function getBool(string $name, bool $default = false) : bool
392 392
     {
393 393
         $value = $this->getParam($name, $default);
394 394
 
395
-        if(ConvertHelper::isBoolean($value)) {
395
+        if (ConvertHelper::isBoolean($value)) {
396 396
             return ConvertHelper::string2bool($value);
397 397
         }
398 398
         
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
     
402 402
     public function validate() : void
403 403
     {
404
-        foreach($this->knownParams as $param) 
404
+        foreach ($this->knownParams as $param) 
405 405
         {
406 406
             $name = $param->getName();
407 407
             
408
-            if($param->isRequired() && !$this->hasParam($name)) 
408
+            if ($param->isRequired() && !$this->hasParam($name)) 
409 409
             {
410 410
                 throw new Request_Exception(
411 411
                     'Missing request parameter '.$name,
@@ -427,26 +427,26 @@  discard block
 block discarded – undo
427 427
      * @param mixed $default
428 428
      * @return mixed
429 429
      */
430
-    public function getFilteredParam(string $name, $default=null)
430
+    public function getFilteredParam(string $name, $default = null)
431 431
     {
432 432
         $val = $this->getParam($name, $default);
433 433
 
434
-        if(is_string($val))
434
+        if (is_string($val))
435 435
         {
436 436
             return htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
437 437
         }
438 438
 
439
-        if(is_bool($val))
439
+        if (is_bool($val))
440 440
         {
441 441
             return ConvertHelper::boolStrict2string($val);
442 442
         }
443 443
 
444
-        if(is_numeric($val))
444
+        if (is_numeric($val))
445 445
         {
446 446
             return (string)$val;
447 447
         }
448 448
 
449
-        if(is_null($val))
449
+        if (is_null($val))
450 450
         {
451 451
             return '';
452 452
         }
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
      * @see Request::getJSONObject()
467 467
      * @see Request::getJSONAssoc()
468 468
      */
469
-    public function getJSON(string $name, bool $assoc=true)
469
+    public function getJSON(string $name, bool $assoc = true)
470 470
     {
471 471
         $value = $this->getParam($name);
472 472
         
473
-        if(!empty($value) && is_string($value)) 
473
+        if (!empty($value) && is_string($value)) 
474 474
         {
475 475
             try
476 476
             {
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
                 return array();
482 482
             }
483 483
             
484
-            if($assoc && is_array($data)) {
484
+            if ($assoc && is_array($data)) {
485 485
                 return $data;
486 486
             }
487 487
             
488
-            if(is_object($data)) {
488
+            if (is_object($data)) {
489 489
                 return $data;
490 490
             }
491 491
         }
492 492
         
493
-        if($assoc) {
493
+        if ($assoc) {
494 494
             return array();
495 495
         }
496 496
         
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     public function getJSONAssoc(string $name) : array
508 508
     {
509 509
         $result = $this->getJSON($name);
510
-        if(is_array($result)) {
510
+        if (is_array($result)) {
511 511
             return $result;
512 512
         }
513 513
         
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
     public function getJSONObject(string $name) : object
525 525
     {
526 526
         $result = $this->getJSON($name, false);
527
-        if(is_object($result)) {
527
+        if (is_object($result)) {
528 528
             return $result;
529 529
         }
530 530
         
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     {
542 542
         $payload = $data;
543 543
 
544
-        if(!is_string($payload)) {
544
+        if (!is_string($payload)) {
545 545
             $payload = json_encode($payload, JSON_THROW_ON_ERROR);
546 546
         }
547 547
         
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present)
599 599
     * @return Request_URLComparer
600 600
     */
601
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
601
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
602 602
     {
603 603
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
604 604
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.