Passed
Push — master ( ba00c7...bfa3fc )
by Sebastian
08:42
created
src/FileHelper/PHPFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function checkSyntax()
58 58
     {
59
-        if(!FileHelper::canMakePHPCalls())
59
+        if (!FileHelper::canMakePHPCalls())
60 60
         {
61 61
             return true;
62 62
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         // when the validation is successful, the first entry
69 69
         // in the array contains the success message. When it
70 70
         // is invalid, the first entry is always empty.
71
-        if(!empty($output[0])) {
71
+        if (!empty($output[0])) {
72 72
             return true;
73 73
         }
74 74
 
Please login to merge, or discard this patch.
src/FileHelper/FolderInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $pathString = AbstractPathInfo::type2string($path);
32 32
 
33
-        if(empty($path)) {
33
+        if (empty($path)) {
34 34
             throw new FileHelper_Exception(
35 35
                 'Invalid',
36 36
                 '',
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             );
39 39
         }
40 40
 
41
-        if($path instanceof FileInfo || FileInfo::is_file($pathString))
41
+        if ($path instanceof FileInfo || FileInfo::is_file($pathString))
42 42
         {
43 43
             throw new FileHelper_Exception(
44 44
                 'Cannot use a file',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             );
51 51
         }
52 52
 
53
-        if(!isset(self::$infoCache[$pathString]))
53
+        if (!isset(self::$infoCache[$pathString]))
54 54
         {
55 55
             self::$infoCache[$pathString] = new FolderInfo($pathString);
56 56
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $path = trim($path);
88 88
         $test = trim($path, '/\\');
89 89
 
90
-        if($path === '' || $test === '.' || $test === '..')
90
+        if ($path === '' || $test === '.' || $test === '..')
91 91
         {
92 92
             return false;
93 93
         }
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function delete() : FolderInfo
107 107
     {
108
-        if(!$this->exists())
108
+        if (!$this->exists())
109 109
         {
110 110
             return $this;
111 111
         }
112 112
 
113
-        if(rmdir($this->path))
113
+        if (rmdir($this->path))
114 114
         {
115 115
             return $this;
116 116
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function create() : FolderInfo
138 138
     {
139
-        if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
139
+        if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
140 140
         {
141 141
             return $this;
142 142
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         return FileHelper::createFolder($this->getPath().'/'.$name);
187 187
     }
188 188
 
189
-    public function saveFile(string $fileName, string $content='') : FileInfo
189
+    public function saveFile(string $fileName, string $content = '') : FileInfo
190 190
     {
191 191
         return FileHelper::saveFile($this.'/'.$fileName, $content);
192 192
     }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return JSONFile
199 199
      * @throws FileHelper_Exception
200 200
      */
201
-    public function saveJSONFile(array $data, string $fileName, bool $pretty=false) : JSONFile
201
+    public function saveJSONFile(array $data, string $fileName, bool $pretty = false) : JSONFile
202 202
     {
203 203
         return FileHelper::saveAsJSON($data, $this.'/'.$fileName, $pretty);
204 204
     }
Please login to merge, or discard this patch.
src/FileHelper/FileInfo.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $pathString = AbstractPathInfo::type2string($path);
67 67
         $endingChar = $pathString[strlen($pathString) - 1];
68 68
 
69
-        if(empty($path)) {
69
+        if (empty($path)) {
70 70
             throw new FileHelper_Exception(
71 71
                 'Invalid',
72 72
                 '',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             );
75 75
         }
76 76
 
77
-        if($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
77
+        if ($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
78 78
         {
79 79
             throw new FileHelper_Exception(
80 80
                 'Cannot use a folder as a file',
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 
89 89
         $key = $pathString.';'.static::class;
90 90
 
91
-        if(!isset(self::$infoCache[$key]))
91
+        if (!isset(self::$infoCache[$key]))
92 92
         {
93 93
             $class = static::class;
94 94
             $instance = new $class($pathString);
95 95
 
96
-            if(!$instance instanceof self) {
96
+            if (!$instance instanceof self) {
97 97
                 throw new FileHelper_Exception(
98 98
                     'Invalid class created',
99 99
                     sprintf(
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $path = trim($path);
130 130
 
131
-        if(empty($path) || FolderInfo::is_dir($path))
131
+        if (empty($path) || FolderInfo::is_dir($path))
132 132
         {
133 133
             return false;
134 134
         }
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
         return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== '';
137 137
     }
138 138
 
139
-    public function removeExtension(bool $keepPath=false) : string
139
+    public function removeExtension(bool $keepPath = false) : string
140 140
     {
141
-        if(!$keepPath)
141
+        if (!$keepPath)
142 142
         {
143 143
             return (string)pathinfo($this->getName(), PATHINFO_FILENAME);
144 144
         }
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
         return $this->removeExtension();
164 164
     }
165 165
 
166
-    public function getExtension(bool $lowercase=true) : string
166
+    public function getExtension(bool $lowercase = true) : string
167 167
     {
168 168
         $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION);
169 169
 
170
-        if($lowercase)
170
+        if ($lowercase)
171 171
         {
172 172
             $ext = mb_strtolower($ext);
173 173
         }
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function delete() : FileInfo
190 190
     {
191
-        if(!$this->exists())
191
+        if (!$this->exists())
192 192
         {
193 193
             return $this;
194 194
         }
195 195
 
196
-        if(unlink($this->path))
196
+        if (unlink($this->path))
197 197
         {
198 198
             return $this;
199 199
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $target = $this->checkCopyPrerequisites($targetPath);
222 222
 
223
-        if(copy($this->path, (string)$target))
223
+        if (copy($this->path, (string)$target))
224 224
         {
225 225
             return $target;
226 226
         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $target = FileHelper::getPathInfo($targetPath);
258 258
 
259 259
         // It's a file? Then we can use it as-is.
260
-        if($target instanceof self) {
260
+        if ($target instanceof self) {
261 261
             return $target
262 262
                 ->requireIsFile()
263 263
                 ->createFolder();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // but is not a folder: very likely a file without extension.
268 268
         // In this case we create an empty file to be able to return
269 269
         // a FileInfo instance.
270
-        if($target instanceof IndeterminatePath)
270
+        if ($target instanceof IndeterminatePath)
271 271
         {
272 272
             return $target->convertToFile();
273 273
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function getLineReader() : LineReader
298 298
     {
299
-        if($this->lineReader === null)
299
+        if ($this->lineReader === null)
300 300
         {
301 301
             $this->lineReader = new LineReader($this);
302 302
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
         $result = file_get_contents($this->getPath());
317 317
 
318
-        if($result !== false) {
318
+        if ($result !== false) {
319 319
             return $result;
320 320
         }
321 321
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function putContents(string $content) : FileInfo
339 339
     {
340
-        if($this->exists())
340
+        if ($this->exists())
341 341
         {
342 342
             $this->requireWritable();
343 343
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 ->requireWritable();
349 349
         }
350 350
 
351
-        if(file_put_contents($this->path, $content) !== false)
351
+        if (file_put_contents($this->path, $content) !== false)
352 352
         {
353 353
             return $this;
354 354
         }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     private function createFolder() : FileInfo
380 380
     {
381
-        if(!$this->exists())
381
+        if (!$this->exists())
382 382
         {
383 383
             FolderInfo::factory($this->getFolderPath())
384 384
                 ->create()
Please login to merge, or discard this patch.
src/ArrayDataCollection.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     /**
43 43
      * @param array<string,mixed> $data
44 44
      */
45
-    public function __construct(array $data=array())
45
+    public function __construct(array $data = array())
46 46
     {
47 47
         $this->data = $data;
48 48
     }
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      * @param ArrayDataCollection|array<string,mixed>|NULL $data
52 52
      * @return ArrayDataCollection
53 53
      */
54
-    public static function create($data=array()) : ArrayDataCollection
54
+    public static function create($data = array()) : ArrayDataCollection
55 55
     {
56
-        if($data instanceof self) {
56
+        if ($data instanceof self) {
57 57
             return $data;
58 58
         }
59 59
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function setKeys(array $data) : self
76 76
     {
77
-        foreach($data as $key => $value)
77
+        foreach ($data as $key => $value)
78 78
         {
79 79
             $this->setKey($key, $value);
80 80
         }
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
     {
143 143
         $value = $this->getKey($name);
144 144
 
145
-        if(is_string($value)) {
145
+        if (is_string($value)) {
146 146
             return $value;
147 147
         }
148 148
 
149
-        if(is_numeric($value)) {
149
+        if (is_numeric($value)) {
150 150
             return (string)$value;
151 151
         }
152 152
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         $value = $this->getKey($name);
167 167
 
168
-        if(is_numeric($value)) {
168
+        if (is_numeric($value)) {
169 169
             return (int)$value;
170 170
         }
171 171
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
         $value = $this->getKey($name);
188 188
 
189 189
         // Does not need to be decoded after all
190
-        if(is_array($value)) {
190
+        if (is_array($value)) {
191 191
             return $value;
192 192
         }
193 193
 
194
-        if(empty($value) || !is_string($value)) {
194
+        if (empty($value) || !is_string($value)) {
195 195
             return array();
196 196
         }
197 197
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     {
203 203
         $value = $this->getKey($name);
204 204
 
205
-        if(is_array($value)) {
205
+        if (is_array($value)) {
206 206
             return $value;
207 207
         }
208 208
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         $value = $this->getKey($name);
215 215
 
216
-        if(is_string($value)) {
216
+        if (is_string($value)) {
217 217
             $value = strtolower($value);
218 218
         }
219 219
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     {
232 232
         $value = $this->getKey($name);
233 233
 
234
-        if(is_numeric($value)) {
234
+        if (is_numeric($value)) {
235 235
             return (float)$value;
236 236
         }
237 237
 
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
     {
289 289
         $value = $this->getString($name);
290 290
 
291
-        if(empty($value)) {
291
+        if (empty($value)) {
292 292
             return null;
293 293
         }
294 294
 
295
-        if(is_numeric($value)) {
295
+        if (is_numeric($value)) {
296 296
             $date = new DateTime();
297 297
             $date->setTimestamp((int)$value);
298 298
             return $date;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     {
375 375
         $date = $this->getDateTime($name);
376 376
 
377
-        if($date !== null)
377
+        if ($date !== null)
378 378
         {
379 379
             return $date->getTimestamp();
380 380
         }
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param int $tabSize The amount of spaces per tab.
62 62
      * @return string
63 63
      */
64
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
64
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
65 65
     {
66 66
         return ConvertHelper_String::tabs2spaces($string, $tabSize);
67 67
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     * @param int $tabSize The amount of spaces per tab in the source string.
74 74
     * @return string
75 75
     */
76
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
76
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
77 77
     {
78 78
         return ConvertHelper_String::spaces2tabs($string, $tabSize);
79 79
     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     * @deprecated Use the Highlighter class directly instead.
147 147
     * @see Highlighter::xml()
148 148
     */
149
-    public static function highlight_xml(string $xml, bool $formatSource=false) : string
149
+    public static function highlight_xml(string $xml, bool $formatSource = false) : string
150 150
     {
151 151
         return Highlighter::xml($xml, $formatSource);
152 152
     }
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
      * @param bool $html
213 213
      * @return string
214 214
      */
215
-    public static function var_dump($var, bool $html=true) : string
215
+    public static function var_dump($var, bool $html = true) : string
216 216
     {
217 217
         $info = parseVariable($var);
218 218
         
219
-        if($html) {
219
+        if ($html) {
220 220
             return $info->toHTML();
221 221
         }
222 222
         
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
     * @param bool $html Whether to style the dump as HTML.
232 232
     * @return string
233 233
     */
234
-    public static function print_r($var, bool $return=false, bool $html=true) : string
234
+    public static function print_r($var, bool $return = false, bool $html = true) : string
235 235
     {
236 236
         $result = parseVariable($var)->enableType()->toString();
237 237
         
238
-        if($html) 
238
+        if ($html) 
239 239
         {
240 240
             $result = 
241 241
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             '</pre>';
244 244
         }
245 245
         
246
-        if(!$return) 
246
+        if (!$return) 
247 247
         {
248 248
             echo $result;
249 249
         }
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
         $output = '';
426 426
         $split = str_split($unicodeChar);
427 427
         
428
-        foreach($split as $octet) 
428
+        foreach ($split as $octet) 
429 429
         {
430 430
             $ordInt = ord($octet);
431 431
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
432 432
             $ordHex = base_convert((string)$ordInt, 10, 16);
433
-            $output .= '\x' . $ordHex;
433
+            $output .= '\x'.$ordHex;
434 434
         }
435 435
         
436 436
         return $output;
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     * 
659 659
     * @see JSHelper::buildRegexStatement()
660 660
     */
661
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string
661
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) : string
662 662
     {
663 663
         return JSHelper::buildRegexStatement($regex, $statementType);
664 664
     }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     * @throws JSONConverterException
680 680
     * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
681 681
     */
682
-    public static function var2json($variable, int $options=0, int $depth=512) : string
682
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
683 683
     {
684 684
         return JSONConverter::var2json($variable, $options, $depth);
685 685
     }
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
     {
737 737
         $boms = FileHelper::createUnicodeHandling()->getUTFBOMs();
738 738
 
739
-        foreach($boms as $bomChars)
739
+        foreach ($boms as $bomChars)
740 740
         {
741 741
             $length = mb_strlen($bomChars);
742 742
             $text = mb_substr($string, 0, $length);
743 743
 
744
-            if($text===$bomChars)
744
+            if ($text === $bomChars)
745 745
             {
746 746
                 return mb_substr($string, $length);
747 747
             }
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
     * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE
814 814
     * @see ConvertHelper_TextComparer::OPTION_PRECISION
815 815
     */
816
-    public static function matchString(string $source, string $target, array $options=array()) : float
816
+    public static function matchString(string $source, string $target, array $options = array()) : float
817 817
     {
818 818
         return (new ConvertHelper_TextComparer())
819 819
             ->setOptions($options)
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
     * @see ConvertHelper::INTERVAL_HOURS
892 892
     * @see ConvertHelper::INTERVAL_DAYS
893 893
     */
894
-    public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int
894
+    public static function interval2total(DateInterval $interval, string $unit = self::INTERVAL_SECONDS) : int
895 895
     {
896 896
         return ConvertHelper_DateInterval::toTotal($interval, $unit);
897 897
     }
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
     * @param bool $short
904 904
     * @return string|NULL
905 905
     */
906
-    public static function date2dayName(DateTime $date, bool $short=false) : ?string
906
+    public static function date2dayName(DateTime $date, bool $short = false) : ?string
907 907
     {
908 908
         return ConvertHelper_Date::toDayName($date, $short);
909 909
     }
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
     * @param bool $short
924 924
     * @return string[]
925 925
     */
926
-    public static function getDayNames(bool $short=false) : array
926
+    public static function getDayNames(bool $short = false) : array
927 927
     {
928 928
         return ConvertHelper_Date::getDayNames($short);
929 929
     }
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
     * @param bool $caseInsensitive
1088 1088
     * @return ConvertHelper_StringMatch[]
1089 1089
     */
1090
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1090
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array
1091 1091
     {
1092 1092
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1093 1093
     }
@@ -1137,17 +1137,17 @@  discard block
 block discarded – undo
1137 1137
     */
1138 1138
     public static function isInteger($value) : bool
1139 1139
     {
1140
-        if(is_int($value)) {
1140
+        if (is_int($value)) {
1141 1141
             return true;
1142 1142
         }
1143 1143
         
1144 1144
         // booleans get converted to numbers, so they would
1145 1145
         // actually match the regex.
1146
-        if(is_bool($value)) {
1146
+        if (is_bool($value)) {
1147 1147
             return false;
1148 1148
         }
1149 1149
         
1150
-        if(is_string($value) && $value !== '') {
1150
+        if (is_string($value) && $value !== '') {
1151 1151
             return preg_match('/\A-?\d+\z/', $value) === 1;
1152 1152
         }
1153 1153
         
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
      * @param bool $keepKeys
1214 1214
      * @return array<number|string,mixed>
1215 1215
      */
1216
-    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys=false) : array
1216
+    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys = false) : array
1217 1217
     {
1218 1218
         return ConvertHelper_Array::removeValues($sourceArray, $values, $keepKeys);
1219 1219
     }
Please login to merge, or discard this patch.
src/Highlighter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public static function json($subject) : string
114 114
     {
115
-        if(!is_string($subject))
115
+        if (!is_string($subject))
116 116
         {
117 117
             $subject = JSONConverter::var2json($subject, JSON_PRETTY_PRINT);
118 118
         }
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
     * @param bool $formatSource Whether to format the source with indentation to make it readable.
130 130
     * @return string
131 131
     */
132
-    public static function xml(string $xml, bool $formatSource=false) : string
132
+    public static function xml(string $xml, bool $formatSource = false) : string
133 133
     {
134
-        if($formatSource)
134
+        if ($formatSource)
135 135
         {
136 136
             $dom = new DOMDocument();
137 137
             $dom->preserveWhiteSpace = false;
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
     * @param bool $formatSource
153 153
     * @return string
154 154
     */
155
-    public static function html(string $html, bool $formatSource=false) : string
155
+    public static function html(string $html, bool $formatSource = false) : string
156 156
     {
157
-        if($formatSource)
157
+        if ($formatSource)
158 158
         {
159 159
             $dom = new DOMDocument();
160 160
             $dom->preserveWhiteSpace = false;
Please login to merge, or discard this patch.
src/ConvertHelper/JSONConverter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @throws JSONConverterException
42 42
      * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
43 43
      */
44
-    public static function var2json($variable, int $options=0, int $depth=512) : string
44
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
45 45
     {
46 46
         try
47 47
         {
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
      * @return mixed|NULL
70 70
      * @throws JSONConverterException
71 71
      */
72
-    public static function json2var(string $json, bool $assoc=true)
72
+    public static function json2var(string $json, bool $assoc = true)
73 73
     {
74
-        if(empty($json)) {
74
+        if (empty($json)) {
75 75
             return null;
76 76
         }
77 77
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public static function json2array($json) : array
114 114
     {
115
-        if(is_array($json)) {
115
+        if (is_array($json)) {
116 116
             return $json;
117 117
         }
118 118
 
119 119
         $result = self::json2var($json);
120
-        if(is_array($result)) {
120
+        if (is_array($result)) {
121 121
             return $result;
122 122
         }
123 123
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param int $depth
166 166
      * @return string
167 167
      */
168
-    public static function var2jsonSilent($variable, int $options=0, int $depth=512) : string
168
+    public static function var2jsonSilent($variable, int $options = 0, int $depth = 512) : string
169 169
     {
170 170
         try
171 171
         {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      * @param bool $assoc
186 186
      * @return mixed|null
187 187
      */
188
-    public static function json2varSilent(string $json, bool $assoc=true)
188
+    public static function json2varSilent(string $json, bool $assoc = true)
189 189
     {
190 190
         try
191 191
         {
Please login to merge, or discard this patch.
src/FileHelper/JSONFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
     private function convertEncoding(string $contents) : string
124 124
     {
125
-        if(!empty($this->targetEncoding))
125
+        if (!empty($this->targetEncoding))
126 126
         {
127 127
             return (string)mb_convert_encoding(
128 128
                 $contents,
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     {
145 145
         $options = 0;
146 146
 
147
-        if($pretty)
147
+        if ($pretty)
148 148
         {
149 149
             $options = JSON_PRETTY_PRINT;
150 150
         }
Please login to merge, or discard this patch.
src/JSHelper.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
         $quoteStyle = array_shift($params);
87 87
         $method = array_shift($params);
88 88
         
89
-        $call = $method . '(';
89
+        $call = $method.'(';
90 90
         
91 91
         $total = count($params);
92
-        if($total > 0) {
93
-            for($i=0; $i < $total; $i++) 
92
+        if ($total > 0) {
93
+            for ($i = 0; $i < $total; $i++) 
94 94
             {
95 95
                 $call .= self::phpVariable2JS($params[$i], $quoteStyle);
96
-                if($i < ($total-1)) {
96
+                if ($i < ($total - 1)) {
97 97
                     $call .= ',';
98 98
                 }
99 99
             }
100 100
         }
101 101
         
102
-        return $call . ');';
102
+        return $call.');';
103 103
     }
104 104
 
105 105
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public static function buildVariable(string $varName, $varValue) : string
127 127
     {
128
-        return $varName . "=" . self::phpVariable2JS($varValue) . ';';
128
+        return $varName."=".self::phpVariable2JS($varValue).';';
129 129
     }
130 130
 
131 131
     /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return string
139 139
      * @throws JSONConverterException
140 140
      */
141
-    public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string
141
+    public static function phpVariable2JS($variable, int $quoteStyle = self::QUOTE_STYLE_DOUBLE) : string
142 142
     {
143 143
         // after much profiling, this variant of the method offers
144 144
         // the best performance. Repeat scalar values are cached 
@@ -146,22 +146,22 @@  discard block
 block discarded – undo
146 146
         
147 147
         $type = gettype($variable);
148 148
         $hash = null;
149
-        if(is_scalar($variable) === true) 
149
+        if (is_scalar($variable) === true) 
150 150
         {
151 151
             $hash = $variable;
152 152
         
153
-            if($hash === true) 
153
+            if ($hash === true) 
154 154
             { 
155 155
                 $hash = 'true'; 
156 156
             } 
157
-            else if($hash === false) 
157
+            else if ($hash === false) 
158 158
             { 
159 159
                 $hash = 'false'; 
160 160
             }
161 161
             
162 162
             $hash .= '-'.$quoteStyle.'-'.$type;
163 163
             
164
-            if(isset(self::$variableCache[$hash])) {
164
+            if (isset(self::$variableCache[$hash])) {
165 165
                 return self::$variableCache[$hash];
166 166
             }
167 167
         }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
         $result = 'null';
170 170
 
171 171
         // one gettype call is better than a strict if-else.
172
-        switch($type) 
172
+        switch ($type) 
173 173
         {
174 174
             case 'double':
175 175
             case 'string':
176 176
                 $string = JSONConverter::var2json($variable);
177 177
                 
178
-                if($quoteStyle === self::QUOTE_STYLE_SINGLE)
178
+                if ($quoteStyle === self::QUOTE_STYLE_SINGLE)
179 179
                 {
180 180
                     $string = mb_substr($string, 1, -1);
181 181
                     $string = "'".str_replace("'", "\'", $string)."'";
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                 break;
186 186
                 
187 187
             case 'boolean':
188
-                if($variable === true) {
188
+                if ($variable === true) {
189 189
                     $result = 'true';
190 190
                 } else {
191 191
                     $result = 'false';
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         }
204 204
 
205 205
         // cache cacheable values
206
-        if($hash !== null) 
206
+        if ($hash !== null) 
207 207
         {
208 208
             self::$variableCache[$hash] = $result;
209 209
         }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     {
237 237
         self::$elementCounter++;
238 238
 
239
-        return self::$idPrefix . self::$elementCounter;
239
+        return self::$idPrefix.self::$elementCounter;
240 240
     }
241 241
     
242 242
    /**
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
      * @see JSHelper::JS_REGEX_OBJECT
310 310
      * @see JSHelper::JS_REGEX_JSON
311 311
      */
312
-    public static function buildRegexStatement(string $regex, string $statementType=self::JS_REGEX_OBJECT) : string
312
+    public static function buildRegexStatement(string $regex, string $statementType = self::JS_REGEX_OBJECT) : string
313 313
     {
314 314
         $regex = trim($regex);
315 315
 
316
-        if(empty($regex))
316
+        if (empty($regex))
317 317
         {
318 318
             throw new JSHelperException(
319 319
                 'Empty regex.',
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         array_shift($parts);
328 328
         
329 329
         $modifiers = array_pop($parts);
330
-        if($modifiers === $separator) {
330
+        if ($modifiers === $separator) {
331 331
             $modifiers = '';
332 332
         }
333 333
         
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
         // convert the anchors that are not supported in js regexes
348 348
         $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format);
349 349
         
350
-        if($statementType === self::JS_REGEX_JSON)
350
+        if ($statementType === self::JS_REGEX_JSON)
351 351
         {
352 352
             return ConvertHelper::var2json(array(
353 353
                 'format' => $format,
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
             ));
356 356
         }
357 357
         
358
-        if(!empty($modifiers)) {
358
+        if (!empty($modifiers)) {
359 359
             return sprintf(
360 360
                 'new RegExp(%s, %s)',
361 361
                 ConvertHelper::var2json($format),
Please login to merge, or discard this patch.