Test Failed
Push — master ( 1f9a79...0fd1be )
by Sebastian
08:36
created
src/CSVHelper.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     
171 171
     public function isHeadersPosition($position)
172 172
     {
173
-        if($this->headersPosition === $position) {
173
+        if ($this->headersPosition === $position) {
174 174
             return true;
175 175
         }
176 176
         
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             self::HEADERS_TOP
198 198
         );
199 199
         
200
-        if(!in_array($position, $validPositions)) {
200
+        if (!in_array($position, $validPositions)) {
201 201
             throw new CSVHelper_Exception(
202 202
                 'Invalid headers position',
203 203
                 sprintf(
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     */
254 254
     public function getRow($index)
255 255
     {
256
-        if(isset($this->data[$index])) {
256
+        if (isset($this->data[$index])) {
257 257
             return $this->data[$index];
258 258
         }
259 259
         
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
     public function getColumn($index)
321 321
     {
322 322
         $data = array();
323
-        for($i=0; $i < $this->rowCount; $i++) {
323
+        for ($i = 0; $i < $this->rowCount; $i++) {
324 324
             $value = '';
325
-            if(isset($this->data[$i][$index])) {
325
+            if (isset($this->data[$i][$index])) {
326 326
                 $value = $this->data[$i][$index];
327 327
             }
328 328
             
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     */
340 340
     public function columnExists($index)
341 341
     {
342
-        if($index < $this->columnCount) {
342
+        if ($index < $this->columnCount) {
343 343
             return true;
344 344
         }
345 345
         
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     {
351 351
         $this->reset();
352 352
         
353
-        if(empty(trim($this->csv))) {
353
+        if (empty(trim($this->csv))) {
354 354
             $this->addError('Tried to parse an empty CSV string.');
355 355
             return;
356 356
         }
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
         
363 363
         $parser = self::createParser();
364 364
 
365
-        if(!$parser->parse($this->csv)) {
365
+        if (!$parser->parse($this->csv)) {
366 366
             $this->addError('The CSV string could not be parsed.');
367 367
             return;
368 368
         }
369 369
 
370 370
         $result = $parser->data;
371 371
 
372
-        switch($this->headersPosition)
372
+        switch ($this->headersPosition)
373 373
         {
374 374
             case self::HEADERS_TOP:
375 375
                 $this->headers = array_shift($result);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             case self::HEADERS_LEFT:
379 379
                 $keep = array();
380 380
                 $total = count($result);
381
-                for($i=0; $i < $total; $i++) {
381
+                for ($i = 0; $i < $total; $i++) {
382 382
                     $row = $result[$i];
383 383
                     $this->headers[] = array_shift($row);
384 384
                     $keep[] = $row;
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
         $this->data = $result;
392 392
         $this->rowCount = count($this->data);
393 393
         
394
-        for($i=0; $i < $this->rowCount; $i++) {
394
+        for ($i = 0; $i < $this->rowCount; $i++) {
395 395
             $amount = count($this->data[$i]);
396
-            if($amount > $this->columnCount) {
396
+            if ($amount > $this->columnCount) {
397 397
                 $this->columnCount = $amount;
398 398
             }
399 399
         }
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
             ',,' => ','
438 438
         );
439 439
         
440
-        foreach($search as $char => $separator) {
441
-            if(strstr($this->csv, $char)) {
440
+        foreach ($search as $char => $separator) {
441
+            if (strstr($this->csv, $char)) {
442 442
                 return $separator;
443 443
             }
444 444
         }
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
      * @param string $delimiter
453 453
      * @return Csv
454 454
      */
455
-    public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv
455
+    public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv
456 456
     {
457 457
         $csv = new Csv();
458 458
 
459
-        if($delimiter !== self::DELIMITER_AUTO) {
459
+        if ($delimiter !== self::DELIMITER_AUTO) {
460 460
             $csv->delimiter = $delimiter;
461 461
         }
462 462
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 
485 485
         $result = $parser->auto($path);
486 486
 
487
-        if(is_string($result)) {
487
+        if (is_string($result)) {
488 488
             return $parser->data;
489 489
         }
490 490
 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
         $parser = self::createParser();
518 518
         $result = $parser->parse($string);
519 519
 
520
-        if($result === true) {
520
+        if ($result === true) {
521 521
             return $parser->data;
522 522
         }
523 523
 
Please login to merge, or discard this patch.
src/BaseException.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
     * @param int|NULL $code
32 32
     * @param Throwable|NULL $previous
33 33
     */
34
-    public function __construct(string $message, ?string $details=null, $code=null, $previous=null)
34
+    public function __construct(string $message, ?string $details = null, $code = null, $previous = null)
35 35
     {
36
-        if(defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true')
36
+        if (defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true')
37 37
         {
38 38
             $message .= PHP_EOL.$details;
39 39
         }
40 40
 
41
-        if($code === null)
41
+        if ($code === null)
42 42
         {
43 43
              $code = 0;
44 44
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     */
63 63
     public function display() : void
64 64
     {
65
-        if(!headers_sent()) {
65
+        if (!headers_sent()) {
66 66
             header('Content-type:text/plain; charset=utf-8');
67 67
         }
68 68
         
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         {
90 90
             throw new BaseException('');
91 91
         }
92
-        catch(BaseException $e) 
92
+        catch (BaseException $e) 
93 93
         {
94 94
             echo self::createInfo($e)->toString();
95 95
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         {
105 105
             throw new BaseException('');
106 106
         }
107
-        catch(BaseException $e)
107
+        catch (BaseException $e)
108 108
         {
109 109
             echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">';
110 110
             echo self::createInfo($e)->toString();
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $value = $_REQUEST[$name] ?? $default;
93 93
 
94
-        if(isset($this->knownParams[$name])) {
94
+        if (isset($this->knownParams[$name])) {
95 95
             $value = $this->knownParams[$name]->validate($value);
96 96
         }
97 97
         
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
189 189
      * @return string
190 190
      */
191
-    public function buildURL(array $params = array(), string $dispatcher='') : string
191
+    public function buildURL(array $params = array(), string $dispatcher = '') : string
192 192
     {
193
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
193
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
194 194
         
195 195
         // append any leftover parameters to the end of the URL
196 196
         if (!empty($params)) {
197
-            $url .= '?' . http_build_query($params, '', '&amp;');
197
+            $url .= '?'.http_build_query($params, '', '&amp;');
198 198
         }
199 199
         
200 200
         return $url;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function registerParam(string $name) : RequestParam
227 227
     {
228
-        if(!isset($this->knownParams[$name])) {
228
+        if (!isset($this->knownParams[$name])) {
229 229
             $param = new RequestParam($this, $name);
230 230
             $this->knownParams[$name] = $param;
231 231
         }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     */
243 243
     public function getRegisteredParam(string $name) : RequestParam
244 244
     {
245
-        if(isset($this->knownParams[$name])) {
245
+        if (isset($this->knownParams[$name])) {
246 246
             return $this->knownParams[$name];
247 247
         }
248 248
         
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     {
303 303
         static $accept;
304 304
         
305
-        if(!isset($accept)) {
305
+        if (!isset($accept)) {
306 306
             $accept = new Request_AcceptHeaders();
307 307
         }
308 308
         
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     {
322 322
         $_REQUEST[$name] = $value;
323 323
         
324
-        if(isset($this->knownParams[$name])) {
324
+        if (isset($this->knownParams[$name])) {
325 325
             unset($this->knownParams[$name]);
326 326
         }
327 327
         
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
     */
352 352
     public function removeParam(string $name) : Request
353 353
     {
354
-        if(isset($_REQUEST[$name])) {
354
+        if (isset($_REQUEST[$name])) {
355 355
             unset($_REQUEST[$name]);
356 356
         }
357 357
         
358
-        if(isset($this->knownParams[$name])) {
358
+        if (isset($this->knownParams[$name])) {
359 359
             unset($this->knownParams[$name]);
360 360
         }
361 361
         
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     */
371 371
     public function removeParams(array $names) : Request
372 372
     {
373
-        foreach($names as $name) {
373
+        foreach ($names as $name) {
374 374
             $this->removeParam($name);
375 375
         }
376 376
         
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
      * @return bool
389 389
      * @throws ConvertHelper_Exception
390 390
      */
391
-    public function getBool(string $name, bool $default=false) : bool
391
+    public function getBool(string $name, bool $default = false) : bool
392 392
     {
393 393
         $value = $this->getParam($name, $default);
394 394
 
395
-        if(ConvertHelper::isBoolean($value)) {
395
+        if (ConvertHelper::isBoolean($value)) {
396 396
             return ConvertHelper::string2bool($value);
397 397
         }
398 398
         
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
     
402 402
     public function validate() : void
403 403
     {
404
-        foreach($this->knownParams as $param) 
404
+        foreach ($this->knownParams as $param) 
405 405
         {
406 406
             $name = $param->getName();
407 407
             
408
-            if($param->isRequired() && !$this->hasParam($name)) 
408
+            if ($param->isRequired() && !$this->hasParam($name)) 
409 409
             {
410 410
                 throw new Request_Exception(
411 411
                     'Missing request parameter '.$name,
@@ -427,26 +427,26 @@  discard block
 block discarded – undo
427 427
      * @param mixed $default
428 428
      * @return mixed
429 429
      */
430
-    public function getFilteredParam(string $name, $default=null)
430
+    public function getFilteredParam(string $name, $default = null)
431 431
     {
432 432
         $val = $this->getParam($name, $default);
433 433
 
434
-        if(is_string($val))
434
+        if (is_string($val))
435 435
         {
436 436
             return htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
437 437
         }
438 438
 
439
-        if(is_bool($val))
439
+        if (is_bool($val))
440 440
         {
441 441
             return ConvertHelper::boolStrict2string($val);
442 442
         }
443 443
 
444
-        if(is_numeric($val))
444
+        if (is_numeric($val))
445 445
         {
446 446
             return (string)$val;
447 447
         }
448 448
 
449
-        if(is_null($val))
449
+        if (is_null($val))
450 450
         {
451 451
             return '';
452 452
         }
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
      * @see Request::getJSONObject()
467 467
      * @see Request::getJSONAssoc()
468 468
      */
469
-    public function getJSON(string $name, bool $assoc=true)
469
+    public function getJSON(string $name, bool $assoc = true)
470 470
     {
471 471
         $value = $this->getParam($name);
472 472
         
473
-        if(!empty($value) && is_string($value)) 
473
+        if (!empty($value) && is_string($value)) 
474 474
         {
475 475
             try
476 476
             {
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
                 return array();
482 482
             }
483 483
             
484
-            if($assoc && is_array($data)) {
484
+            if ($assoc && is_array($data)) {
485 485
                 return $data;
486 486
             }
487 487
             
488
-            if(is_object($data)) {
488
+            if (is_object($data)) {
489 489
                 return $data;
490 490
             }
491 491
         }
492 492
         
493
-        if($assoc) {
493
+        if ($assoc) {
494 494
             return array();
495 495
         }
496 496
         
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     public function getJSONAssoc(string $name) : array
508 508
     {
509 509
         $result = $this->getJSON($name);
510
-        if(is_array($result)) {
510
+        if (is_array($result)) {
511 511
             return $result;
512 512
         }
513 513
         
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
     public function getJSONObject(string $name) : object
525 525
     {
526 526
         $result = $this->getJSON($name, false);
527
-        if(is_object($result)) {
527
+        if (is_object($result)) {
528 528
             return $result;
529 529
         }
530 530
         
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     {
542 542
         $payload = $data;
543 543
 
544
-        if(!is_string($payload)) {
544
+        if (!is_string($payload)) {
545 545
             $payload = json_encode($payload, JSON_THROW_ON_ERROR);
546 546
         }
547 547
         
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present)
599 599
     * @return Request_URLComparer
600 600
     */
601
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
601
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
602 602
     {
603 603
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
604 604
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.