Passed
Push — master ( 8efc25...9adcd8 )
by Sebastian
02:27
created
src/Request.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
     public function getParam($name, $default = null)
91 91
     {
92 92
         $value = $default;
93
-        if(isset($_REQUEST[$name])) {
93
+        if (isset($_REQUEST[$name])) {
94 94
             $value = $_REQUEST[$name];
95 95
         }
96 96
         
97
-        if(isset($this->knownParams[$name])) {
97
+        if (isset($this->knownParams[$name])) {
98 98
             $value = $this->knownParams[$name]->validate($value);
99 99
         }
100 100
         
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
         
144 144
         $exclude = array_merge($exclude, $this->getExcludeParams());
145 145
         
146
-        foreach($exclude as $name) 
146
+        foreach ($exclude as $name) 
147 147
         {
148
-            if(isset($vars[$name])) 
148
+            if (isset($vars[$name])) 
149 149
             {
150 150
                 unset($vars[$name]);
151 151
             }
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
         // remove the HTML_QuickForm2 form variable if present, to 
157 157
         // avoid redirect loops when using the refresh URL in
158 158
         // a page in which a form has been submitted.
159
-        foreach($names as $name) 
159
+        foreach ($names as $name) 
160 160
         {
161
-            if(strstr($name, '_qf__')) 
161
+            if (strstr($name, '_qf__')) 
162 162
             {
163 163
                 unset($vars[$name]);
164 164
                 break;
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
187 187
      * @return string
188 188
      */
189
-    public function buildURL($params = array(), string $dispatcher='')
189
+    public function buildURL($params = array(), string $dispatcher = '')
190 190
     {
191
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
191
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
192 192
         
193 193
         // append any leftover parameters to the end of the URL
194 194
         if (!empty($params)) {
195
-            $url .= '?' . http_build_query($params, null, '&');
195
+            $url .= '?'.http_build_query($params, null, '&');
196 196
         }
197 197
         
198 198
         return $url;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function registerParam($name)
225 225
     {
226
-        if(!isset($this->knownParams[$name])) {
226
+        if (!isset($this->knownParams[$name])) {
227 227
             $param = new Request_Param($this, $name);
228 228
             $this->knownParams[$name] = $param;
229 229
         }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     */
241 241
     public function getRegisteredParam(string $name) : Request_Param
242 242
     {
243
-        if(isset($this->knownParams[$name])) {
243
+        if (isset($this->knownParams[$name])) {
244 244
             return $this->knownParams[$name];
245 245
         }
246 246
         
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
     {
301 301
         static $accept;
302 302
         
303
-        if(!isset($accept)) {
303
+        if (!isset($accept)) {
304 304
             $accept = new Request_AcceptHeaders();
305 305
         }
306 306
         
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     {
320 320
         $_REQUEST[$name] = $value;
321 321
         
322
-        if(isset($this->knownParams[$name])) {
322
+        if (isset($this->knownParams[$name])) {
323 323
             unset($this->knownParams[$name]);
324 324
         }
325 325
         
@@ -353,11 +353,11 @@  discard block
 block discarded – undo
353 353
     */
354 354
     public function removeParam(string $name) : Request
355 355
     {
356
-        if(isset($_REQUEST[$name])) {
356
+        if (isset($_REQUEST[$name])) {
357 357
             unset($_REQUEST[$name]);
358 358
         }
359 359
         
360
-        if(isset($this->knownParams[$name])) {
360
+        if (isset($this->knownParams[$name])) {
361 361
             unset($this->knownParams[$name]);
362 362
         }
363 363
         
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     */
373 373
     public function removeParams(array $names) : Request
374 374
     {
375
-        foreach($names as $name) {
375
+        foreach ($names as $name) {
376 376
             $this->removeParam($name);
377 377
         }
378 378
         
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
      * @param string $name
389 389
      * @return bool
390 390
      */
391
-    public function getBool($name, $default=false)
391
+    public function getBool($name, $default = false)
392 392
     {
393 393
         $value = $this->getParam($name, $default);
394
-        if(ConvertHelper::isBoolean($value)) {
394
+        if (ConvertHelper::isBoolean($value)) {
395 395
             return ConvertHelper::string2bool($value);
396 396
         }
397 397
         
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
     
401 401
     public function validate()
402 402
     {
403
-        foreach($this->knownParams as $param) {
403
+        foreach ($this->knownParams as $param) {
404 404
             $name = $param->getName();
405
-            if($param->isRequired() && !$this->hasParam($name)) {
405
+            if ($param->isRequired() && !$this->hasParam($name)) {
406 406
                 throw new Request_Exception(
407 407
                     'Missing request parameter '.$name,
408 408
                     sprintf(
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
      * @param mixed $default
425 425
      * @return string
426 426
      */
427
-    public function getFilteredParam($name, $default=null)
427
+    public function getFilteredParam($name, $default = null)
428 428
     {
429 429
         $val = $this->getParam($name, $default);
430
-        if(is_string($val)) {
430
+        if (is_string($val)) {
431 431
             $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
432 432
         }
433 433
         
@@ -446,24 +446,24 @@  discard block
 block discarded – undo
446 446
     * @see Request::getJSONAssoc()
447 447
     * @see Request::getJSONObject()
448 448
     */
449
-    public function getJSON(string $name, bool $assoc=true)
449
+    public function getJSON(string $name, bool $assoc = true)
450 450
     {
451 451
         $value = $this->getParam($name);
452 452
         
453
-        if(!empty($value) && is_string($value)) 
453
+        if (!empty($value) && is_string($value)) 
454 454
         {
455 455
             $data = json_decode($value, $assoc);
456 456
             
457
-            if($assoc && is_array($data)) {
457
+            if ($assoc && is_array($data)) {
458 458
                 return $data;
459 459
             }
460 460
             
461
-            if(is_object($data)) {
461
+            if (is_object($data)) {
462 462
                 return $data;
463 463
             }
464 464
         }
465 465
         
466
-        if($assoc) {
466
+        if ($assoc) {
467 467
             return array();
468 468
         }
469 469
         
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
     public function getJSONAssoc(string $name) : array
481 481
     {
482 482
         $result = $this->getJSON($name);
483
-        if(is_array($result)) {
483
+        if (is_array($result)) {
484 484
             return $result;
485 485
         }
486 486
         
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     public function getJSONObject(string $name) : object
498 498
     {
499 499
         $result = $this->getJSON($name, false);
500
-        if(is_object($result)) {
500
+        if (is_object($result)) {
501 501
             return $result;
502 502
         }
503 503
         
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
     * @param array|string $data
511 511
     * @param bool $exit Whether to exit the script afterwards.
512 512
     */
513
-    public static function sendJSON($data, bool $exit=true)
513
+    public static function sendJSON($data, bool $exit = true)
514 514
     {
515 515
         $payload = $data;
516
-        if(!is_string($payload)) {
516
+        if (!is_string($payload)) {
517 517
             $payload = json_encode($payload);
518 518
         }
519 519
         
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         
524 524
         echo $payload;
525 525
         
526
-        if($exit) 
526
+        if ($exit) 
527 527
         {
528 528
             exit;
529 529
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     * @param string $html
536 536
     * @param bool $exit Whether to exit the script afterwards.
537 537
     */
538
-    public static function sendHTML(string $html, bool $exit=true)
538
+    public static function sendHTML(string $html, bool $exit = true)
539 539
     {
540 540
         header('Cache-Control: no-cache, must-revalidate');
541 541
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
         
544 544
         echo $html;
545 545
         
546
-        if($exit)
546
+        if ($exit)
547 547
         {
548 548
             exit;
549 549
         }
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
560 560
     * @return Request_URLComparer
561 561
     */
562
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
562
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
563 563
     {
564 564
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
565 565
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/Request/AcceptHeaders.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $result = array();
48 48
         
49
-        foreach($this->headers as $header)
49
+        foreach ($this->headers as $header)
50 50
         {
51 51
             $result[] = $header['type'];
52 52
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         // we may be in a CLI environment where the headers
63 63
         // are not populated.
64
-        if(!isset($_SERVER['HTTP_ACCEPT'])) {
64
+        if (!isset($_SERVER['HTTP_ACCEPT'])) {
65 65
             return;
66 66
         }
67 67
         
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         
80 80
         $accept = array();
81 81
         
82
-        foreach($tokens as $i => $term)
82
+        foreach ($tokens as $i => $term)
83 83
         {
84 84
             $accept[] = $this->parseEntry($i, $term);
85 85
         }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             'type' => null
106 106
         );
107 107
         
108
-        if(strstr($mime, ';'))
108
+        if (strstr($mime, ';'))
109 109
         {
110 110
             $parts = explode(';', $mime);
111 111
             $mime = array_shift($parts);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             // like an URL query string if separated by ampersands;
115 115
             $entry['params'] = ConvertHelper::parseQueryString(implode('&', $parts));
116 116
                 
117
-            if(isset($entry['params']['q'])) 
117
+            if (isset($entry['params']['q'])) 
118 118
             {
119 119
                 $entry['quality'] = (double)$entry['params']['q'];
120 120
             } 
Please login to merge, or discard this patch.