Passed
Branch master (43d553)
by Sebastian
02:54
created
src/RequestHelper/Boundaries/Boundary.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $lines[] = '--'.$this->boundaries->getMimeBoundary();
92 92
         $lines[] = $this->renderContentDisposition();
93 93
         
94
-        if(!empty($this->contentType)) {
94
+        if (!empty($this->contentType)) {
95 95
             $lines[] = $this->renderContentType();
96 96
         }
97 97
         
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $result = 'Content-Disposition: form-data';
107 107
         
108
-        foreach($this->dispositionParams as $name => $value) 
108
+        foreach ($this->dispositionParams as $name => $value) 
109 109
         {
110
-            $result .= '; '.$name.'="' . $value . '"';
110
+            $result .= '; '.$name.'="'.$value.'"';
111 111
         }   
112 112
         
113 113
         return $result;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
     
116 116
     protected function renderContentType() : string
117 117
     {
118
-        $result = 'Content-Type: ' . $this->contentType; 
118
+        $result = 'Content-Type: '.$this->contentType; 
119 119
         
120
-        if(!empty($this->contentEncoding)) 
120
+        if (!empty($this->contentEncoding)) 
121 121
         {
122
-            $result .= '; charset=' . $this->contentEncoding;
122
+            $result .= '; charset='.$this->contentEncoding;
123 123
         }
124 124
         
125 125
         return $result;
Please login to merge, or discard this patch.
src/RequestHelper/Boundaries.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     */
140 140
     public function render() : string
141 141
     {
142
-        if(empty($this->boundaries)) 
142
+        if (empty($this->boundaries)) 
143 143
         {
144 144
             throw new RequestHelper_Exception(
145 145
                 'No mime boundaries added',
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
         
151 151
         $result = '';
152 152
         
153
-        foreach($this->boundaries as $boundary)
153
+        foreach ($this->boundaries as $boundary)
154 154
         {
155 155
             $result .= $boundary->render();
156 156
         }
157 157
         
158
-        $result .= "--" . $this->getMimeBoundary() . "--" . 
159
-        $this->getEOL() . $this->getEOL(); // always finish with two eol's!!
158
+        $result .= "--".$this->getMimeBoundary()."--". 
159
+        $this->getEOL().$this->getEOL(); // always finish with two eol's!!
160 160
         
161 161
         return $result;
162 162
     }
Please login to merge, or discard this patch.
src/URLInfo/Normalizer.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     * @param bool $enable Whether to turn it on or off.
40 40
     * @return URLInfo_Normalizer
41 41
     */
42
-    public function enableAuth(bool $enable=true) : URLInfo_Normalizer
42
+    public function enableAuth(bool $enable = true) : URLInfo_Normalizer
43 43
     {
44 44
         $this->auth = $enable;
45 45
         return $this;
@@ -86,48 +86,48 @@  discard block
 block discarded – undo
86 86
     
87 87
     protected function renderAuth(string $normalized) : string
88 88
     {
89
-        if(!$this->info->hasUsername() || !$this->auth) {
89
+        if (!$this->info->hasUsername() || !$this->auth) {
90 90
             return $normalized;
91 91
         }
92 92
          
93
-        return $normalized . urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
93
+        return $normalized.urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@';
94 94
     }
95 95
     
96 96
     protected function renderPort(string $normalized) : string
97 97
     {
98
-        if(!$this->info->hasPort()) {
98
+        if (!$this->info->hasPort()) {
99 99
             return $normalized;
100 100
         }
101 101
         
102
-        return $normalized . ':'.$this->info->getPort();
102
+        return $normalized.':'.$this->info->getPort();
103 103
     }
104 104
     
105 105
     protected function renderPath(string $normalized) : string
106 106
     {
107
-        if(!$this->info->hasPath()) {
107
+        if (!$this->info->hasPath()) {
108 108
             return $normalized; 
109 109
         }
110 110
         
111
-        return $normalized . $this->info->getPath();
111
+        return $normalized.$this->info->getPath();
112 112
     }
113 113
     
114 114
     protected function renderParams(string $normalized) : string
115 115
     {
116 116
         $params = $this->info->getParams();
117 117
         
118
-        if(empty($params)) {
118
+        if (empty($params)) {
119 119
             return $normalized;
120 120
         }
121 121
         
122
-        return $normalized . '?'.http_build_query($params);
122
+        return $normalized.'?'.http_build_query($params);
123 123
     }
124 124
     
125 125
     protected function renderFragment(string $normalized) : string
126 126
     {
127
-        if(!$this->info->hasFragment()) {
127
+        if (!$this->info->hasFragment()) {
128 128
             return $normalized;
129 129
         }
130 130
         
131
-        return $normalized . '#'.$this->info->getFragment();
131
+        return $normalized.'#'.$this->info->getFragment();
132 132
     }
133 133
 }
Please login to merge, or discard this patch.
src/URLInfo.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $port = $this->getInfoKey('port');
202 202
         
203
-        if(!empty($port)) {
203
+        if (!empty($port)) {
204 204
             return (int)$port;
205 205
         }
206 206
         
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     
281 281
     protected function getInfoKey(string $name) : string
282 282
     {
283
-        if(isset($this->info[$name])) {
283
+        if (isset($this->info[$name])) {
284 284
             return (string)$this->info[$name];
285 285
         }
286 286
         
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
         return $this->normalize(false);
310 310
     }
311 311
     
312
-    protected function normalize(bool $auth=true) : string
312
+    protected function normalize(bool $auth = true) : string
313 313
     {
314
-        if(!$this->isValid()) {
314
+        if (!$this->isValid()) {
315 315
             return '';
316 316
         }
317 317
         
318
-        if(!isset($this->normalizer)) {
318
+        if (!isset($this->normalizer)) {
319 319
             $this->normalizer = new URLInfo_Normalizer($this);
320 320
         }
321 321
         
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     */
346 346
     public function getHighlighted() : string
347 347
     {
348
-        if(!$this->isValid()) {
348
+        if (!$this->isValid()) {
349 349
             return '';
350 350
         }
351 351
         
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
     */
388 388
     public function getParams() : array
389 389
     {
390
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
390
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
391 391
             return $this->info['params'];
392 392
         }
393 393
         
394 394
         $keep = array();
395
-        foreach($this->info['params'] as $name => $value) 
395
+        foreach ($this->info['params'] as $name => $value) 
396 396
         {
397
-            if(!isset($this->excludedParams[$name])) {
397
+            if (!isset($this->excludedParams[$name])) {
398 398
                 $keep[$name] = $value;
399 399
             }
400 400
         }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     */
421 421
     public function getParam(string $name) : string
422 422
     {
423
-        if(isset($this->info['params'][$name])) {
423
+        if (isset($this->info['params'][$name])) {
424 424
             return $this->info['params'][$name];
425 425
         }
426 426
         
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     */
440 440
     public function excludeParam(string $name, string $reason) : URLInfo
441 441
     {
442
-        if(!isset($this->excludedParams[$name]))
442
+        if (!isset($this->excludedParams[$name]))
443 443
         {
444 444
             $this->excludedParams[$name] = $reason;
445 445
             $this->setParamExclusion();
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     
466 466
     public function getTypeLabel() : string
467 467
     {
468
-        if(!isset(self::$typeLabels))
468
+        if (!isset(self::$typeLabels))
469 469
         {
470 470
             self::$typeLabels = array(
471 471
                 self::TYPE_EMAIL => t('Email'),
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         
478 478
         $type = $this->getType();
479 479
         
480
-        if(!isset(self::$typeLabels[$type]))
480
+        if (!isset(self::$typeLabels[$type]))
481 481
         {
482 482
             throw new BaseException(
483 483
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     * @param bool $highlight
498 498
     * @return URLInfo
499 499
     */
500
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
500
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
501 501
     {
502 502
         $this->highlightExcluded = $highlight;
503 503
         return $this;
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      * @see URLInfo::isParamExclusionEnabled()
546 546
      * @see URLInfo::setHighlightExcluded()
547 547
      */
548
-    public function setParamExclusion(bool $enabled=true) : URLInfo
548
+    public function setParamExclusion(bool $enabled = true) : URLInfo
549 549
     {
550 550
         $this->paramExclusion = $enabled;
551 551
         return $this;
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
     */
572 572
     public function containsExcludedParams() : bool
573 573
     {
574
-        if(empty($this->excludedParams)) {
574
+        if (empty($this->excludedParams)) {
575 575
             return false;
576 576
         }
577 577
         
578 578
         $names = array_keys($this->info['params']);
579
-        foreach($names as $name) {
580
-            if(isset($this->excludedParams[$name])) {
579
+        foreach ($names as $name) {
580
+            if (isset($this->excludedParams[$name])) {
581 581
                 return true;
582 582
             }
583 583
         }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
     public function offsetSet($offset, $value) 
595 595
     {
596
-        if(in_array($offset, $this->infoKeys)) {
596
+        if (in_array($offset, $this->infoKeys)) {
597 597
             $this->info[$offset] = $value;
598 598
         }
599 599
     }
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
     
611 611
     public function offsetGet($offset) 
612 612
     {
613
-        if($offset === 'port') {
613
+        if ($offset === 'port') {
614 614
             return $this->getPort();
615 615
         }
616 616
         
617
-        if(in_array($offset, $this->infoKeys)) {
617
+        if (in_array($offset, $this->infoKeys)) {
618 618
             return $this->getInfoKey($offset);
619 619
         }
620 620
         
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
     * @return bool
647 647
     * @throws BaseException
648 648
     */
649
-    public function tryConnect(bool $verifySSL=true) : bool
649
+    public function tryConnect(bool $verifySSL = true) : bool
650 650
     {
651 651
         requireCURL();
652 652
         
653 653
         $ch = curl_init();
654
-        if(!is_resource($ch))
654
+        if (!is_resource($ch))
655 655
         {
656 656
             throw new BaseException(
657 657
                 'Could not initialize a new cURL instance.',
@@ -667,13 +667,13 @@  discard block
 block discarded – undo
667 667
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
668 668
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
669 669
         
670
-        if(!$verifySSL) 
670
+        if (!$verifySSL) 
671 671
         {
672 672
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
673 673
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
674 674
         }
675 675
         
676
-        if($this->hasUsername()) 
676
+        if ($this->hasUsername()) 
677 677
         {
678 678
             curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername());
679 679
             curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword());
Please login to merge, or discard this patch.
src/RequestHelper.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         // CURL will complain about an empty response when the 
211 211
         // server sends a 100-continue code. That should not be
212 212
         // regarded as an error.
213
-        if($output === false && $this->response->getCode() !== 100)
213
+        if ($output === false && $this->response->getCode() !== 100)
214 214
         {
215 215
             $this->response->setError(
216 216
                 curl_errno($ch),
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     protected function createCURL(URLInfo $url)
244 244
     {
245 245
         $ch = curl_init();
246
-        if(!is_resource($ch))
246
+        if (!is_resource($ch))
247 247
         {
248 248
             throw new RequestHelper_Exception(
249 249
                 'Could not initialize a new cURL instance.',
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         }
254 254
 
255 255
         $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength());
256
-        $this->setHeader('Content-Type', 'multipart/form-data; charset=UTF-8; boundary=' . $this->mimeBoundary);
256
+        $this->setHeader('Content-Type', 'multipart/form-data; charset=UTF-8; boundary='.$this->mimeBoundary);
257 257
         
258 258
         //curl_setopt($ch, CURLOPT_VERBOSE, true);
259 259
         curl_setopt($ch, CURLOPT_POST, true);
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
265 265
         curl_setopt($ch, CURLOPT_HTTPHEADER, $this->renderHeaders());
266 266
         
267
-        if($this->verifySSL)
267
+        if ($this->verifySSL)
268 268
         {
269 269
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
270 270
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
271 271
         }
272 272
         
273
-        if($url->hasUsername())
273
+        if ($url->hasUsername())
274 274
         {
275 275
             curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername());
276 276
             curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword());
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     {
291 291
         $result = array();
292 292
         
293
-        foreach($this->headers as $name => $value) {
293
+        foreach ($this->headers as $name => $value) {
294 294
             $result[] = $name.': '.$value;
295 295
         }
296 296
         
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     {
308 308
         $response = $this->getResponse();
309 309
         
310
-        if($response !== null) {
310
+        if ($response !== null) {
311 311
             return $response->getHeaders();
312 312
         }
313 313
 
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         
107 107
         $contents = file_get_contents($file);
108 108
         
109
-        if($contents === false) 
109
+        if ($contents === false) 
110 110
         {
111 111
             throw new FileHelper_Exception(
112 112
                 'Cannot load serialized content from file.',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         
121 121
         $result = @unserialize($contents);
122 122
         
123
-        if($result !== false) {
123
+        if ($result !== false) {
124 124
             return $result;
125 125
         }
126 126
         
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     
137 137
     public static function deleteTree($rootFolder)
138 138
     {
139
-        if(!file_exists($rootFolder)) {
139
+        if (!file_exists($rootFolder)) {
140 140
             return true;
141 141
         }
142 142
         
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     */
178 178
     public static function createFolder($path)
179 179
     {
180
-        if(is_dir($path) || mkdir($path, 0777, true)) {
180
+        if (is_dir($path) || mkdir($path, 0777, true)) {
181 181
             return;
182 182
         }
183 183
         
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 
213 213
             if ($item->isDir()) 
214 214
             {
215
-                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target . '/' . $baseName);
215
+                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target.'/'.$baseName);
216 216
             } 
217
-            else if($item->isFile()) 
217
+            else if ($item->isFile()) 
218 218
             {
219
-                self::copyFile($itemPath, $target . '/' . $baseName);
219
+                self::copyFile($itemPath, $target.'/'.$baseName);
220 220
             }
221 221
         }
222 222
     }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     {
242 242
         self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND);
243 243
         
244
-        if(!is_readable($sourcePath))
244
+        if (!is_readable($sourcePath))
245 245
         {
246 246
             throw new FileHelper_Exception(
247 247
                 sprintf('Source file [%s] to copy is not readable.', basename($sourcePath)),
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
         
256 256
         $targetFolder = dirname($targetPath);
257 257
         
258
-        if(!file_exists($targetFolder))
258
+        if (!file_exists($targetFolder))
259 259
         {
260 260
             self::createFolder($targetFolder);
261 261
         }
262
-        else if(!is_writable($targetFolder)) 
262
+        else if (!is_writable($targetFolder)) 
263 263
         {
264 264
             throw new FileHelper_Exception(
265 265
                 sprintf('Target folder [%s] is not writable.', basename($targetFolder)),
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             );
272 272
         }
273 273
         
274
-        if(copy($sourcePath, $targetPath)) {
274
+        if (copy($sourcePath, $targetPath)) {
275 275
             return;
276 276
         }
277 277
         
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
     */
299 299
     public static function deleteFile(string $filePath) : void
300 300
     {
301
-        if(!file_exists($filePath)) {
301
+        if (!file_exists($filePath)) {
302 302
             return;
303 303
         }
304 304
         
305
-        if(unlink($filePath)) {
305
+        if (unlink($filePath)) {
306 306
             return;
307 307
         }
308 308
         
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
     * @return \parseCSV
327 327
     * @todo Move this to the CSV helper.
328 328
     */
329
-    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : \parseCSV
329
+    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : \parseCSV
330 330
     {
331
-        if($delimiter==='') { $delimiter = ';'; }
332
-        if($enclosure==='') { $enclosure = '"'; }
331
+        if ($delimiter === '') { $delimiter = ';'; }
332
+        if ($enclosure === '') { $enclosure = '"'; }
333 333
         
334 334
         $parser = new \parseCSV(null, null, null, array());
335 335
 
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
     * @see parseCSVFile()
358 358
     * @see FileHelper::ERROR_PARSING_CSV
359 359
     */
360
-    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
360
+    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
361 361
     {
362 362
         $parser = self::createCSVParser($delimiter, $enclosure, $escape, $heading);
363 363
         $result = $parser->parse_string(/** @scrutinizer ignore-type */ $csv);
364
-        if(is_array($result)) {
364
+        if (is_array($result)) {
365 365
             return $result;
366 366
         }
367 367
         
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
391 391
      * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
392 392
      */
393
-    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
393
+    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
394 394
     {
395 395
         $content = self::readContents($filePath);
396 396
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     public static function detectMimeType(string $fileName) : ?string
408 408
     {
409 409
         $ext = self::getExtension($fileName);
410
-        if(empty($ext)) {
410
+        if (empty($ext)) {
411 411
             return null;
412 412
         }
413 413
 
@@ -428,11 +428,11 @@  discard block
 block discarded – undo
428 428
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
429 429
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
430 430
      */
431
-    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment=true)
431
+    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment = true)
432 432
     {
433 433
         self::requireFileExists($filePath);
434 434
         
435
-        if(empty($fileName)) {
435
+        if (empty($fileName)) {
436 436
             $fileName = basename($filePath);
437 437
         }
438 438
 
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
         
451 451
         header("Cache-Control: public", true);
452 452
         header("Content-Description: File Transfer", true);
453
-        header("Content-Type: " . $mime, true);
453
+        header("Content-Type: ".$mime, true);
454 454
 
455 455
         $disposition = 'inline';
456
-        if($asAttachment) {
456
+        if ($asAttachment) {
457 457
             $disposition = 'attachment';
458 458
         }
459 459
         
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
         requireCURL();
482 482
         
483 483
         $ch = curl_init();
484
-        if(!is_resource($ch)) 
484
+        if (!is_resource($ch)) 
485 485
         {
486 486
             throw new FileHelper_Exception(
487 487
                 'Could not initialize a new cURL instance.',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
         
503 503
         $output = curl_exec($ch);
504 504
 
505
-        if($output === false) {
505
+        if ($output === false) {
506 506
             throw new FileHelper_Exception(
507 507
                 'Unable to open URL',
508 508
                 sprintf(
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
         curl_close($ch);
518 518
 
519
-        if(is_string($output)) 
519
+        if (is_string($output)) 
520 520
         {
521 521
             return $output;
522 522
         }
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     */
539 539
     public static function isPHPFile($pathOrDirIterator)
540 540
     {
541
-    	if(self::getExtension($pathOrDirIterator) == 'php') {
541
+    	if (self::getExtension($pathOrDirIterator) == 'php') {
542 542
     		return true;
543 543
     	}
544 544
     	
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
     */
556 556
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
557 557
     {
558
-        if($pathOrDirIterator instanceof \DirectoryIterator) {
558
+        if ($pathOrDirIterator instanceof \DirectoryIterator) {
559 559
             $filename = $pathOrDirIterator->getFilename();
560 560
         } else {
561 561
             $filename = basename($pathOrDirIterator);
562 562
         }
563 563
          
564 564
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
565
-        if($lowercase) {
565
+        if ($lowercase) {
566 566
         	$ext = mb_strtolower($ext);
567 567
         }
568 568
         
@@ -584,13 +584,13 @@  discard block
 block discarded – undo
584 584
     public static function getFilename($pathOrDirIterator, $extension = true)
585 585
     {
586 586
         $path = $pathOrDirIterator;
587
-    	if($pathOrDirIterator instanceof \DirectoryIterator) {
587
+    	if ($pathOrDirIterator instanceof \DirectoryIterator) {
588 588
     		$path = $pathOrDirIterator->getFilename();
589 589
     	}
590 590
     	
591 591
     	$path = self::normalizePath($path);
592 592
     	
593
-    	if(!$extension) {
593
+    	if (!$extension) {
594 594
     	    return pathinfo($path, PATHINFO_FILENAME);
595 595
     	}
596 596
     	
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
     * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
609 609
     * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
610 610
     */ 
611
-    public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null)
611
+    public static function parseJSONFile(string $file, $targetEncoding = null, $sourceEncoding = null)
612 612
     {
613 613
         self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE);
614 614
         
615 615
         $content = file_get_contents($file);
616
-        if(!$content) {
616
+        if (!$content) {
617 617
             throw new FileHelper_Exception(
618 618
                 'Cannot get file contents',
619 619
                 sprintf(
@@ -624,12 +624,12 @@  discard block
 block discarded – undo
624 624
             );
625 625
         }
626 626
         
627
-        if(isset($targetEncoding)) {
627
+        if (isset($targetEncoding)) {
628 628
             $content = mb_convert_encoding($content, $targetEncoding, $sourceEncoding);
629 629
         }
630 630
         
631 631
         $json = json_decode($content, true);
632
-        if($json === false || $json === NULL) {
632
+        if ($json === false || $json === NULL) {
633 633
             throw new FileHelper_Exception(
634 634
                 'Cannot decode json data',
635 635
                 sprintf(
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
         
670 670
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
671 671
         
672
-        while(strstr($name, '  ')) {
672
+        while (strstr($name, '  ')) {
673 673
             $name = str_replace('  ', ' ', $name);
674 674
         }
675 675
 
676 676
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
677 677
         
678
-        while(strstr($name, '..')) {
678
+        while (strstr($name, '..')) {
679 679
             $name = str_replace('..', '.', $name);
680 680
         }
681 681
         
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
     * @return array An indexed array with files.
708 708
     * @see FileHelper::createFileFinder()
709 709
     */
710
-    public static function findHTMLFiles(string $targetFolder, array $options=array()) : array
710
+    public static function findHTMLFiles(string $targetFolder, array $options = array()) : array
711 711
     {
712 712
         return self::findFiles($targetFolder, array('html'), $options);
713 713
     }
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
     * @return array An indexed array of PHP files.
725 725
     * @see FileHelper::createFileFinder()
726 726
     */
727
-    public static function findPHPFiles(string $targetFolder, array $options=array()) : array
727
+    public static function findPHPFiles(string $targetFolder, array $options = array()) : array
728 728
     {
729 729
         return self::findFiles($targetFolder, array('php'), $options);
730 730
     }
@@ -744,22 +744,22 @@  discard block
 block discarded – undo
744 744
     * @return array
745 745
     * @see FileHelper::createFileFinder()
746 746
     */
747
-    public static function findFiles(string $targetFolder, array $extensions=array(), array $options=array(), array $files=array()) : array
747
+    public static function findFiles(string $targetFolder, array $extensions = array(), array $options = array(), array $files = array()) : array
748 748
     {
749 749
         $finder = self::createFileFinder($targetFolder);
750 750
 
751 751
         $finder->setPathmodeStrip();
752 752
         
753
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
753
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
754 754
         {
755 755
             $finder->setPathmodeRelative();
756 756
         } 
757
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
757
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
758 758
         {
759 759
             $finder->setPathmodeAbsolute();
760 760
         }
761 761
         
762
-        if(isset($options['strip-extension'])) 
762
+        if (isset($options['strip-extension'])) 
763 763
         {
764 764
             $finder->stripExtensions();
765 765
         }
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     public static function detectUTFBom(string $filename) : ?string
804 804
     {
805 805
         $fp = fopen($filename, 'r');
806
-        if($fp === false) 
806
+        if ($fp === false) 
807 807
         {
808 808
             throw new FileHelper_Exception(
809 809
                 'Cannot open file for reading',
@@ -818,10 +818,10 @@  discard block
 block discarded – undo
818 818
 
819 819
         $boms = self::getUTFBOMs();
820 820
         
821
-        foreach($boms as $bom => $value) 
821
+        foreach ($boms as $bom => $value) 
822 822
         {
823 823
             $length = mb_strlen($value);
824
-            if(mb_substr($text, 0, $length) == $value) {
824
+            if (mb_substr($text, 0, $length) == $value) {
825 825
                 return $bom;
826 826
             }
827 827
         }
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
     */
841 841
     public static function getUTFBOMs()
842 842
     {
843
-        if(!isset(self::$utfBoms)) {
843
+        if (!isset(self::$utfBoms)) {
844 844
             self::$utfBoms = array(
845
-                'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
846
-                'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
847
-                'UTF16-BE' => chr(0xFE) . chr(0xFF),
848
-                'UTF16-LE' => chr(0xFF) . chr(0xFE),
849
-                'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
845
+                'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
846
+                'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
847
+                'UTF16-BE' => chr(0xFE).chr(0xFF),
848
+                'UTF16-LE' => chr(0xFF).chr(0xFE),
849
+                'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
850 850
             );
851 851
         }
852 852
         
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
         $encodings = self::getKnownUnicodeEncodings();
868 868
 
869 869
         $keep = array();
870
-        foreach($encodings as $string) 
870
+        foreach ($encodings as $string) 
871 871
         {
872 872
             $withHyphen = str_replace('UTF', 'UTF-', $string);
873 873
             
@@ -914,16 +914,16 @@  discard block
 block discarded – undo
914 914
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
915 915
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
916 916
     */
917
-    public static function saveAsJSON($data, string $file, bool $pretty=false)
917
+    public static function saveAsJSON($data, string $file, bool $pretty = false)
918 918
     {
919 919
         $options = null;
920
-        if($pretty) {
920
+        if ($pretty) {
921 921
             $options = JSON_PRETTY_PRINT;
922 922
         }
923 923
         
924 924
         $json = json_encode($data, $options);
925 925
         
926
-        if($json===false) 
926
+        if ($json === false) 
927 927
         {
928 928
             $errorCode = json_last_error();
929 929
             
@@ -949,12 +949,12 @@  discard block
 block discarded – undo
949 949
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
950 950
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
951 951
     */
952
-    public static function saveFile(string $filePath, string $content='') : void
952
+    public static function saveFile(string $filePath, string $content = '') : void
953 953
     {
954 954
         // target file already exists
955
-        if(file_exists($filePath))
955
+        if (file_exists($filePath))
956 956
         {
957
-            if(!is_writable($filePath))
957
+            if (!is_writable($filePath))
958 958
             {
959 959
                 throw new FileHelper_Exception(
960 960
                     sprintf('Cannot save file: target file [%s] exists, but is not writable.', basename($filePath)),
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
             // create the folder as needed
975 975
             self::createFolder($targetFolder);
976 976
             
977
-            if(!is_writable($targetFolder)) 
977
+            if (!is_writable($targetFolder)) 
978 978
             {
979 979
                 throw new FileHelper_Exception(
980 980
                     sprintf('Cannot save file: target folder [%s] is not writable.', basename($targetFolder)),
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
             }
988 988
         }
989 989
         
990
-        if(file_put_contents($filePath, $content) !== false) {
990
+        if (file_put_contents($filePath, $content) !== false) {
991 991
             return;
992 992
         }
993 993
         
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
     {
1026 1026
         static $checked = array();
1027 1027
         
1028
-        if(isset($checked[$command])) {
1028
+        if (isset($checked[$command])) {
1029 1029
             return $checked[$command];
1030 1030
         }
1031 1031
         
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
         
1039 1039
         $os = strtolower(PHP_OS_FAMILY);
1040 1040
         
1041
-        if(!isset($osCommands[$os])) 
1041
+        if (!isset($osCommands[$os])) 
1042 1042
         {
1043 1043
             throw new FileHelper_Exception(
1044 1044
                 'Unsupported OS for CLI commands',
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
             $pipes
1065 1065
         );
1066 1066
         
1067
-        if($process === false) {
1067
+        if ($process === false) {
1068 1068
             $checked[$command] = false;
1069 1069
             return false;
1070 1070
         }
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
     */
1096 1096
     public static function checkPHPFileSyntax($path)
1097 1097
     {
1098
-        if(!self::canMakePHPCalls()) {
1098
+        if (!self::canMakePHPCalls()) {
1099 1099
             return true;
1100 1100
         }
1101 1101
         
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
         // when the validation is successful, the first entry
1107 1107
         // in the array contains the success message. When it
1108 1108
         // is invalid, the first entry is always empty.
1109
-        if(!empty($output[0])) {
1109
+        if (!empty($output[0])) {
1110 1110
             return true;
1111 1111
         }
1112 1112
         
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
     public static function getModifiedDate($path)
1128 1128
     {
1129 1129
         $time = filemtime($path);
1130
-        if($time !== false) {
1130
+        if ($time !== false) {
1131 1131
             $date = new \DateTime();
1132 1132
             $date->setTimestamp($time);
1133 1133
             return $date;
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
     */
1157 1157
     public static function getSubfolders($targetFolder, $options = array())
1158 1158
     {
1159
-        if(!is_dir($targetFolder)) 
1159
+        if (!is_dir($targetFolder)) 
1160 1160
         {
1161 1161
             throw new FileHelper_Exception(
1162 1162
                 'Target folder does not exist',
@@ -1180,29 +1180,29 @@  discard block
 block discarded – undo
1180 1180
         
1181 1181
         $d = new \DirectoryIterator($targetFolder);
1182 1182
         
1183
-        foreach($d as $item) 
1183
+        foreach ($d as $item) 
1184 1184
         {
1185
-            if($item->isDir() && !$item->isDot()) 
1185
+            if ($item->isDir() && !$item->isDot()) 
1186 1186
             {
1187 1187
                 $name = $item->getFilename();
1188 1188
                 
1189
-                if(!$options['absolute-path']) {
1189
+                if (!$options['absolute-path']) {
1190 1190
                     $result[] = $name;
1191 1191
                 } else {
1192 1192
                     $result[] = $targetFolder.'/'.$name;
1193 1193
                 }
1194 1194
                 
1195
-                if(!$options['recursive']) 
1195
+                if (!$options['recursive']) 
1196 1196
                 {
1197 1197
                     continue;
1198 1198
                 }
1199 1199
                 
1200 1200
                 $subs = self::getSubfolders($targetFolder.'/'.$name, $options);
1201
-                foreach($subs as $sub) 
1201
+                foreach ($subs as $sub) 
1202 1202
                 {
1203 1203
                     $relative = $name.'/'.$sub;
1204 1204
                     
1205
-                    if(!$options['absolute-path']) {
1205
+                    if (!$options['absolute-path']) {
1206 1206
                         $result[] = $relative;
1207 1207
                     } else {
1208 1208
                         $result[] = $targetFolder.'/'.$relative;
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
         $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
1253 1253
         $size = floatval(preg_replace('/[^0-9\.]/', '', $size)); // Remove the non-numeric characters from the size.
1254 1254
         
1255
-        if($unit) 
1255
+        if ($unit) 
1256 1256
         {
1257 1257
             // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
1258 1258
             return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
     * @param int $depth The folder depth to reduce the path to
1272 1272
     * @return string
1273 1273
     */
1274
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
1274
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
1275 1275
     {
1276 1276
         $path = self::normalizePath($path);
1277 1277
         
@@ -1279,17 +1279,17 @@  discard block
 block discarded – undo
1279 1279
         $tokens = array_filter($tokens); // remove empty entries (trailing slash for example)
1280 1280
         $tokens = array_values($tokens); // re-index keys
1281 1281
         
1282
-        if(empty($tokens)) {
1282
+        if (empty($tokens)) {
1283 1283
             return '';
1284 1284
         }
1285 1285
         
1286 1286
         // remove the drive if present
1287
-        if(strstr($tokens[0], ':')) {
1287
+        if (strstr($tokens[0], ':')) {
1288 1288
             array_shift($tokens);
1289 1289
         }
1290 1290
         
1291 1291
         // path was only the drive
1292
-        if(count($tokens) == 0) {
1292
+        if (count($tokens) == 0) {
1293 1293
             return '';
1294 1294
         }
1295 1295
 
@@ -1298,8 +1298,8 @@  discard block
 block discarded – undo
1298 1298
         
1299 1299
         // reduce the path to the specified depth
1300 1300
         $length = count($tokens);
1301
-        if($length > $depth) {
1302
-            $tokens = array_slice($tokens, $length-$depth);
1301
+        if ($length > $depth) {
1302
+            $tokens = array_slice($tokens, $length - $depth);
1303 1303
         }
1304 1304
 
1305 1305
         // append the last element again
@@ -1347,14 +1347,14 @@  discard block
 block discarded – undo
1347 1347
     * 
1348 1348
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1349 1349
     */
1350
-    public static function requireFileExists(string $path, $errorCode=null) : string
1350
+    public static function requireFileExists(string $path, $errorCode = null) : string
1351 1351
     {
1352 1352
         $result = realpath($path);
1353
-        if($result !== false) {
1353
+        if ($result !== false) {
1354 1354
             return $result;
1355 1355
         }
1356 1356
         
1357
-        if($errorCode === null) {
1357
+        if ($errorCode === null) {
1358 1358
             $errorCode = self::ERROR_FILE_DOES_NOT_EXIST;
1359 1359
         }
1360 1360
         
@@ -1383,15 +1383,15 @@  discard block
 block discarded – undo
1383 1383
         
1384 1384
         $file = new \SplFileObject($path);
1385 1385
         
1386
-        if($file->eof()) {
1386
+        if ($file->eof()) {
1387 1387
             return '';
1388 1388
         }
1389 1389
         
1390
-        $targetLine = $lineNumber-1;
1390
+        $targetLine = $lineNumber - 1;
1391 1391
         
1392 1392
         $file->seek($targetLine);
1393 1393
         
1394
-        if($file->key() !== $targetLine) {
1394
+        if ($file->key() !== $targetLine) {
1395 1395
              return null;
1396 1396
         }
1397 1397
         
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
         $number = $spl->key();
1418 1418
         
1419 1419
         // if seeking to the end the cursor is still at 0, there are no lines. 
1420
-        if($number === 0) 
1420
+        if ($number === 0) 
1421 1421
         {
1422 1422
             // since it's a very small file, to get reliable results,
1423 1423
             // we read its contents and use that to determine what
@@ -1425,13 +1425,13 @@  discard block
 block discarded – undo
1425 1425
             // that this is not pactical to solve with the SplFileObject.
1426 1426
             $content = file_get_contents($path);
1427 1427
             
1428
-            if(empty($content)) {
1428
+            if (empty($content)) {
1429 1429
                 return 0;
1430 1430
             }
1431 1431
         }
1432 1432
         
1433 1433
         // return the line number we were able to reach + 1 (key is zero-based)
1434
-        return $number+1;
1434
+        return $number + 1;
1435 1435
     }
1436 1436
     
1437 1437
    /**
@@ -1478,13 +1478,13 @@  discard block
 block discarded – undo
1478 1478
     * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1479 1479
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1480 1480
     */
1481
-    public static function readLines(string $filePath, int $amount=0) : array
1481
+    public static function readLines(string $filePath, int $amount = 0) : array
1482 1482
     {
1483 1483
         self::requireFileExists($filePath);
1484 1484
         
1485 1485
         $fn = fopen($filePath, "r");
1486 1486
         
1487
-        if($fn === false) 
1487
+        if ($fn === false) 
1488 1488
         {
1489 1489
             throw new FileHelper_Exception(
1490 1490
                 'Could not open file for reading.',
@@ -1500,19 +1500,19 @@  discard block
 block discarded – undo
1500 1500
         $counter = 0;
1501 1501
         $first = true;
1502 1502
         
1503
-        while(!feof($fn)) 
1503
+        while (!feof($fn)) 
1504 1504
         {
1505 1505
             $counter++;
1506 1506
             
1507 1507
             $line = fgets($fn);
1508 1508
             
1509 1509
             // can happen with zero length files
1510
-            if($line === false) {
1510
+            if ($line === false) {
1511 1511
                 continue;
1512 1512
             }
1513 1513
             
1514 1514
             // the first line may contain a unicode BOM marker.
1515
-            if($first) 
1515
+            if ($first) 
1516 1516
             {
1517 1517
                 $line = ConvertHelper::stripUTFBom($line);
1518 1518
                 $first = false;
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
             
1521 1521
             $result[] = $line;
1522 1522
             
1523
-            if($amount > 0 && $counter == $amount) {
1523
+            if ($amount > 0 && $counter == $amount) {
1524 1524
                 break;
1525 1525
             }
1526 1526
         }
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
         
1547 1547
         $result = file_get_contents($filePath);
1548 1548
         
1549
-        if($result !== false) {
1549
+        if ($result !== false) {
1550 1550
             return $result;
1551 1551
         }
1552 1552
         
Please login to merge, or discard this patch.
src/NumberInfo.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function setValue($value) : NumberInfo
86 86
     {
87
-        if($value instanceof NumberInfo) {
87
+        if ($value instanceof NumberInfo) {
88 88
             $value = $value->getValue();
89 89
         }
90 90
         
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     
118 118
     public function isPositive() : bool
119 119
     {
120
-        if(!$this->isEmpty()) {
120
+        if (!$this->isEmpty()) {
121 121
             $number = $this->getNumber();
122 122
             return $number > 0;
123 123
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function hasValue() : bool
150 150
     {
151
-        if(!$this->isEmpty() && !$this->isZero()) {
151
+        if (!$this->isEmpty() && !$this->isZero()) {
152 152
             return true;
153 153
         }
154 154
         
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function getUnits()
223 223
     {
224
-        if(!$this->hasUnits()) {
224
+        if (!$this->hasUnits()) {
225 225
             return 'px';
226 226
         }
227 227
         
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function toAttribute() : string
257 257
     {
258
-        if($this->isEmpty()) {
258
+        if ($this->isEmpty()) {
259 259
             return '';
260 260
         }
261 261
         
262
-        if($this->isZero()) {
262
+        if ($this->isZero()) {
263 263
             return '0';
264 264
         }
265 265
         
266
-        if($this->isPercent()) {
266
+        if ($this->isPercent()) {
267 267
             return $this->getNumber().$this->getUnits();
268 268
         }
269 269
         
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function toCSS() : string
278 278
     {
279
-        if($this->isEmpty()) {
279
+        if ($this->isEmpty()) {
280 280
             return '';
281 281
         }
282 282
         
283
-        if($this->isZero()) {
283
+        if ($this->isZero()) {
284 284
             return '0';
285 285
         }
286 286
         
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     
290 290
     public function __toString()
291 291
     {
292
-        if($this->isEmpty()) {
292
+        if ($this->isEmpty()) {
293 293
             return '';
294 294
         }
295 295
         
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     public function isBiggerThan($number)
308 308
     {
309 309
         $number = parseNumber($number);
310
-        if($number->getUnits() != $this->getUnits()) {
310
+        if ($number->getUnits() != $this->getUnits()) {
311 311
             return false;
312 312
         }
313 313
         
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     public function isSmallerThan($number)
326 326
     {
327 327
         $number = parseNumber($number);
328
-        if($number->getUnits() != $this->getUnits()) {
328
+        if ($number->getUnits() != $this->getUnits()) {
329 329
             return false;
330 330
         }
331 331
         
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     public function isBiggerEqual($number)
336 336
     {
337 337
         $number = parseNumber($number);
338
-        if($number->getUnits() != $this->getUnits()) {
338
+        if ($number->getUnits() != $this->getUnits()) {
339 339
             return false;
340 340
         }
341 341
         
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
      */
353 353
     public function add($value)
354 354
     {
355
-        if($this->isEmpty()) {
355
+        if ($this->isEmpty()) {
356 356
             $this->setValue($value);
357 357
             return $this;
358 358
         }
359 359
         
360 360
         $number = parseNumber($value);
361 361
         
362
-        if($number->getUnits() == $this->getUnits() || !$number->hasUnits())
362
+        if ($number->getUnits() == $this->getUnits() || !$number->hasUnits())
363 363
         {
364 364
             $new = $this->getNumber() + $number->getNumber();
365 365
             $this->setValue($new.$this->getUnits());
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
      */
379 379
     public function subtract($value)
380 380
     {
381
-        if($this->isEmpty()) {
381
+        if ($this->isEmpty()) {
382 382
             $this->setValue($value);
383 383
             return $this;
384 384
         }
385 385
         
386 386
         $number = parseNumber($value);
387 387
         
388
-        if($number->getUnits() == $this->getUnits() || !$number->hasUnits())
388
+        if ($number->getUnits() == $this->getUnits() || !$number->hasUnits())
389 389
         {
390 390
             $new = $this->getNumber() - $number->getNumber();
391 391
             $this->setValue($new.$this->getUnits());
@@ -412,25 +412,25 @@  discard block
 block discarded – undo
412 412
     
413 413
     protected function percentOperation($operation, $percent)
414 414
     {
415
-        if($this->isZeroOrEmpty()) {
415
+        if ($this->isZeroOrEmpty()) {
416 416
             return $this;
417 417
         }
418 418
         
419 419
         $percent = parseNumber($percent);
420
-        if($percent->hasUnits() && !$percent->isPercent()) {
420
+        if ($percent->hasUnits() && !$percent->isPercent()) {
421 421
             return $this;
422 422
         }
423 423
         
424 424
         $number = $this->getNumber();
425 425
         $value = $number * $percent->getNumber() / 100;
426 426
         
427
-        if($operation == '-') {
427
+        if ($operation == '-') {
428 428
             $number = $number - $value;
429 429
         } else {
430 430
             $number = $number + $value;
431 431
         }
432 432
         
433
-        if($this->isUnitInteger()) {
433
+        if ($this->isUnitInteger()) {
434 434
             $number = intval($number);
435 435
         }
436 436
         
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
         
482 482
         $key = $this->createValueKey($value);
483 483
 
484
-        if(array_key_exists($key, $cache)) {
484
+        if (array_key_exists($key, $cache)) {
485 485
             return $cache[$key];
486 486
         }
487 487
         
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
             'number' => null
492 492
         );
493 493
         
494
-        if($key === '_EMPTY_') 
494
+        if ($key === '_EMPTY_') 
495 495
         {
496 496
             $cache[$key]['empty'] = true;
497 497
             return $cache[$key];
498 498
         }
499 499
         
500
-        if($value === 0 || $value === '0') 
500
+        if ($value === 0 || $value === '0') 
501 501
         {
502 502
             $cache[$key]['number'] = 0;
503 503
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -506,20 +506,20 @@  discard block
 block discarded – undo
506 506
         
507 507
         $test = trim((string)$value);
508 508
         
509
-        if($test === '') 
509
+        if ($test === '') 
510 510
         {
511 511
             $cache[$key]['empty'] = true;
512 512
             return $cache[$key];
513 513
         }
514 514
         
515 515
         // replace comma notation (which is only possible if it's a string)
516
-        if(is_string($value))
516
+        if (is_string($value))
517 517
         {
518 518
             $test = $this->preProcess($test, $cache, $value);
519 519
         }
520 520
         
521 521
         // convert to a number if it's numeric
522
-        if(is_numeric($test)) 
522
+        if (is_numeric($test)) 
523 523
         {
524 524
             $cache[$key]['number'] = (float)$test * 1;
525 525
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -545,19 +545,19 @@  discard block
 block discarded – undo
545 545
         $empty = false;
546 546
         
547 547
         $found = $this->findUnits($test);
548
-        if($found !== null) 
548
+        if ($found !== null) 
549 549
         {
550 550
             $number = $found['number'];
551 551
             $units = $found['units'];
552 552
         }
553 553
         
554 554
         // the filters have to restore the value
555
-        if($this->postProcess)
555
+        if ($this->postProcess)
556 556
         {
557 557
             $number = $this->postProcess($number, $test);
558 558
         }
559 559
         // empty number
560
-        else if($number === '' || $number === null || is_bool($number))
560
+        else if ($number === '' || $number === null || is_bool($number))
561 561
         {
562 562
             $number = null;
563 563
             $empty = true;
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             $number = trim($number);
569 569
             
570 570
             // may be an arbitrary string in some cases
571
-            if(!is_numeric($number))
571
+            if (!is_numeric($number))
572 572
             {
573 573
                 $number = null;
574 574
                 $empty = true;
@@ -600,17 +600,17 @@  discard block
 block discarded – undo
600 600
         $vlength = strlen($value);
601 601
         $names = array_keys($this->knownUnits);
602 602
         
603
-        foreach($names as $unit)
603
+        foreach ($names as $unit)
604 604
         {
605 605
             $ulength = strlen($unit);
606
-            $start = $vlength-$ulength;
607
-            if($start < 0) {
606
+            $start = $vlength - $ulength;
607
+            if ($start < 0) {
608 608
                 continue;
609 609
             }
610 610
             
611 611
             $search = substr($value, $start, $ulength);
612 612
             
613
-            if($search==$unit) 
613
+            if ($search == $unit) 
614 614
             {
615 615
                 return array(
616 616
                     'units' => $unit,
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
     */
631 631
     private function createValueKey($value) : string
632 632
     {
633
-        if(!is_string($value) && !is_numeric($value))
633
+        if (!is_string($value) && !is_numeric($value))
634 634
         {
635 635
             return '_EMPTY_';
636 636
         }
@@ -696,12 +696,12 @@  discard block
 block discarded – undo
696 696
     protected function filterInfo(array $info) : array
697 697
     {
698 698
         $useUnits = 'px';
699
-        if($info['units'] !== null) {
699
+        if ($info['units'] !== null) {
700 700
             $useUnits = $info['units'];
701 701
         }
702 702
         
703 703
         // the units are non-decimal: convert decimal values
704
-        if($useUnits !== null && $this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
704
+        if ($useUnits !== null && $this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
705 705
         {
706 706
             $info['number'] = intval($info['number']);
707 707
         }
Please login to merge, or discard this patch.
src/Traits/Classable.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     
30 30
     public function addClass(string $name)
31 31
     {
32
-        if(!in_array($name, $this->classes)) {
32
+        if (!in_array($name, $this->classes)) {
33 33
             $this->classes[] = $name;
34 34
         }
35 35
         
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     
39 39
     public function addClasses(array $names)
40 40
     {
41
-        foreach($names as $name) {
41
+        foreach ($names as $name) {
42 42
             $this->addClass($name);
43 43
         }
44 44
         
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $idx = array_search($name, $this->classes);
56 56
         
57
-        if($idx !== false) {
57
+        if ($idx !== false) {
58 58
             unset($this->classes[$idx]);
59 59
             sort($this->classes);
60 60
         }
Please login to merge, or discard this patch.
src/ConvertHelper/StorageSizeEnum.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     */
45 45
     protected static function init() : void
46 46
     {
47
-        if(!empty(self::$sizes)) {
47
+        if (!empty(self::$sizes)) {
48 48
             return;
49 49
         }
50 50
         
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         
63 63
         self::addSize('b', 1, 1, t('B'), t('Byte'), t('Bytes'));
64 64
         
65
-        if(class_exists('AppLocalize\Localization')) 
65
+        if (class_exists('AppLocalize\Localization')) 
66 66
         {
67 67
             \AppLocalize\Localization::onLocaleChanged(array(self::class, 'handle_localeChanged'));
68 68
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         
132 132
         $name = strtolower($name);
133 133
         
134
-        if(isset(self::$sizes[$name])) {
134
+        if (isset(self::$sizes[$name])) {
135 135
             return self::$sizes[$name];
136 136
         }
137 137
         
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
         
174 174
         $result = array();
175 175
         
176
-        foreach(self::$sizes as $size)
176
+        foreach (self::$sizes as $size)
177 177
         {
178
-            if($size->getBase() === $base) {
178
+            if ($size->getBase() === $base) {
179 179
                 $result[] = $size;
180 180
             }
181 181
         }
Please login to merge, or discard this patch.