Passed
Push — master ( b691b7...9fda08 )
by Sebastian
02:50
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, '', '&');
195
+            $url .= '?'.http_build_query($params, '', '&');
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,11 +400,11 @@  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
         {
405 405
             $name = $param->getName();
406 406
             
407
-            if($param->isRequired() && !$this->hasParam($name)) 
407
+            if ($param->isRequired() && !$this->hasParam($name)) 
408 408
             {
409 409
                 throw new Request_Exception(
410 410
                     'Missing request parameter '.$name,
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
      * @param mixed $default
427 427
      * @return string
428 428
      */
429
-    public function getFilteredParam($name, $default=null)
429
+    public function getFilteredParam($name, $default = null)
430 430
     {
431 431
         $val = $this->getParam($name, $default);
432
-        if(is_string($val)) {
432
+        if (is_string($val)) {
433 433
             $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
434 434
         }
435 435
         
@@ -448,24 +448,24 @@  discard block
 block discarded – undo
448 448
     * @see Request::getJSONAssoc()
449 449
     * @see Request::getJSONObject()
450 450
     */
451
-    public function getJSON(string $name, bool $assoc=true)
451
+    public function getJSON(string $name, bool $assoc = true)
452 452
     {
453 453
         $value = $this->getParam($name);
454 454
         
455
-        if(!empty($value) && is_string($value)) 
455
+        if (!empty($value) && is_string($value)) 
456 456
         {
457 457
             $data = json_decode($value, $assoc);
458 458
             
459
-            if($assoc && is_array($data)) {
459
+            if ($assoc && is_array($data)) {
460 460
                 return $data;
461 461
             }
462 462
             
463
-            if(is_object($data)) {
463
+            if (is_object($data)) {
464 464
                 return $data;
465 465
             }
466 466
         }
467 467
         
468
-        if($assoc) {
468
+        if ($assoc) {
469 469
             return array();
470 470
         }
471 471
         
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function getJSONAssoc(string $name) : array
483 483
     {
484 484
         $result = $this->getJSON($name);
485
-        if(is_array($result)) {
485
+        if (is_array($result)) {
486 486
             return $result;
487 487
         }
488 488
         
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     public function getJSONObject(string $name) : object
500 500
     {
501 501
         $result = $this->getJSON($name, false);
502
-        if(is_object($result)) {
502
+        if (is_object($result)) {
503 503
             return $result;
504 504
         }
505 505
         
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
     * @param array|string $data
513 513
     * @param bool $exit Whether to exit the script afterwards.
514 514
     */
515
-    public static function sendJSON($data, bool $exit=true)
515
+    public static function sendJSON($data, bool $exit = true)
516 516
     {
517 517
         $payload = $data;
518
-        if(!is_string($payload)) {
518
+        if (!is_string($payload)) {
519 519
             $payload = json_encode($payload);
520 520
         }
521 521
         
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         
526 526
         echo $payload;
527 527
         
528
-        if($exit) 
528
+        if ($exit) 
529 529
         {
530 530
             exit;
531 531
         }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     * @param string $html
538 538
     * @param bool $exit Whether to exit the script afterwards.
539 539
     */
540
-    public static function sendHTML(string $html, bool $exit=true)
540
+    public static function sendHTML(string $html, bool $exit = true)
541 541
     {
542 542
         header('Cache-Control: no-cache, must-revalidate');
543 543
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
         
546 546
         echo $html;
547 547
         
548
-        if($exit)
548
+        if ($exit)
549 549
         {
550 550
             exit;
551 551
         }
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
562 562
     * @return Request_URLComparer
563 563
     */
564
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
564
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
565 565
     {
566 566
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
567 567
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/ConvertHelper/DateInterval.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         
58 58
         $interval = $d2->diff($d1);
59 59
         
60
-        if(!$interval instanceof \DateInterval) 
60
+        if (!$interval instanceof \DateInterval) 
61 61
         {
62 62
             throw new ConvertHelper_Exception(
63 63
                 'Cannot create interval',
Please login to merge, or discard this patch.
src/ConvertHelper/DurationConverter.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
     const SECONDS_PER_MONTH_APPROX = 2505600; // imprecise - for 29 days, only for approximations. 
33 33
     const SECONDS_PER_YEAR = 31536000;
34 34
     
35
-   /**
36
-    * @var int
37
-    */
35
+    /**
36
+     * @var int
37
+     */
38 38
     protected $dateFrom;
39 39
     
40
-   /**
41
-    * @var int
42
-    */
40
+    /**
41
+     * @var int
42
+     */
43 43
     protected $dateTo;
44 44
     
45
-   /**
46
-    * @var bool
47
-    */
45
+    /**
46
+     * @var bool
47
+     */
48 48
     protected $future = false;
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $interval = '';
54 54
     
55
-   /**
56
-    * @var int
57
-    */
55
+    /**
56
+     * @var int
57
+     */
58 58
     protected $difference = 0;
59 59
     
60
-   /**
61
-    * @var int
62
-    */
60
+    /**
61
+     * @var int
62
+     */
63 63
     protected $dateDiff = 0;
64 64
     
65
-   /**
66
-    * @var array|NULL
67
-    */
65
+    /**
66
+     * @var array|NULL
67
+     */
68 68
     protected static $texts = null;
69 69
     
70 70
     public function __construct()
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
         self::$texts = null;
85 85
     }
86 86
     
87
-   /**
88
-    * Sets the origin date to calculate from.
89
-    * 
90
-    * NOTE: if this is further in the future than
91
-    * the to: date, it will be considered as a 
92
-    * calculation for something to come, i.e. 
93
-    * "In two days".
94
-    *  
95
-    * @param \DateTime $date
96
-    * @return ConvertHelper_DurationConverter
97
-    */
87
+    /**
88
+     * Sets the origin date to calculate from.
89
+     * 
90
+     * NOTE: if this is further in the future than
91
+     * the to: date, it will be considered as a 
92
+     * calculation for something to come, i.e. 
93
+     * "In two days".
94
+     *  
95
+     * @param \DateTime $date
96
+     * @return ConvertHelper_DurationConverter
97
+     */
98 98
     public function setDateFrom(\DateTime $date) : ConvertHelper_DurationConverter
99 99
     {
100 100
         $this->dateFrom = ConvertHelper::date2timestamp($date);
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
         return $this;
103 103
     }
104 104
     
105
-   /**
106
-    * Sets the date to calculate to. Defaults to 
107
-    * the current time if not set.
108
-    * 
109
-    * @param \DateTime $date
110
-    * @return ConvertHelper_DurationConverter
111
-    */
105
+    /**
106
+     * Sets the date to calculate to. Defaults to 
107
+     * the current time if not set.
108
+     * 
109
+     * @param \DateTime $date
110
+     * @return ConvertHelper_DurationConverter
111
+     */
112 112
     public function setDateTo(\DateTime $date) : ConvertHelper_DurationConverter
113 113
     {
114 114
         $this->dateTo = ConvertHelper::date2timestamp($date);
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
         return $this;
117 117
     }
118 118
     
119
-   /**
120
-    * Converts the specified dates to a human readable string.
121
-    * 
122
-    * @throws ConvertHelper_Exception
123
-    * @return string
124
-    * 
125
-    * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET
126
-    */
119
+    /**
120
+     * Converts the specified dates to a human readable string.
121
+     * 
122
+     * @throws ConvertHelper_Exception
123
+     * @return string
124
+     * 
125
+     * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET
126
+     */
127 127
     public function convert() : string
128 128
     {
129 129
         $this->initTexts();
Please login to merge, or discard this patch.
src/ConvertHelper/StorageSizeEnum.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
31 31
     
32 32
     const BASE_2 = 1024;
33 33
     
34
-   /**
35
-    * @var ConvertHelper_StorageSizeEnum_Size[]
36
-    */
34
+    /**
35
+     * @var ConvertHelper_StorageSizeEnum_Size[]
36
+     */
37 37
     protected static $sizes = array();
38 38
     
39
-   /**
40
-    * Initializes the supported unit notations, and
41
-    * how they are supposed to be calculated.
42
-    *
43
-    * @see ConvertHelper_SizeNotation::parseSize()
44
-    */
39
+    /**
40
+     * Initializes the supported unit notations, and
41
+     * how they are supposed to be calculated.
42
+     *
43
+     * @see ConvertHelper_SizeNotation::parseSize()
44
+     */
45 45
     protected static function init() : void
46 46
     {
47 47
         if(!empty(self::$sizes)) {
@@ -68,28 +68,28 @@  discard block
 block discarded – undo
68 68
         }
69 69
     }
70 70
     
71
-   /**
72
-    * Called whenever the application locale is changed,
73
-    * to reset the size definitions so the labels get 
74
-    * translated to the new locale.
75
-    */
71
+    /**
72
+     * Called whenever the application locale is changed,
73
+     * to reset the size definitions so the labels get 
74
+     * translated to the new locale.
75
+     */
76 76
     public static function handle_localeChanged() : void
77 77
     {
78 78
         self::$sizes = array();
79 79
     }
80 80
     
81
-   /**
82
-    * Adds a storage size to the internal collection.
83
-    * 
84
-    * @param string $name The lowercase size name, e.g. "kb", "mib"
85
-    * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details.
86
-    * @param int $exponent The multiplier of the base to get the byte value
87
-    * @param string $suffix The localized short suffix, e.g. "KB", "MiB"
88
-    * @param string $singular The localized singular label of the size, e.g. "Kilobyte".
89
-    * @param string $plural The localized plural label of the size, e.g. "Kilobytes".
90
-    * 
91
-    * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
92
-    */
81
+    /**
82
+     * Adds a storage size to the internal collection.
83
+     * 
84
+     * @param string $name The lowercase size name, e.g. "kb", "mib"
85
+     * @param int $base This defines how many bytes there are in a kilobyte, to differentiate with the two common way to calculate sizes: base 10 or base 2. See the Wikipedia link for more details.
86
+     * @param int $exponent The multiplier of the base to get the byte value
87
+     * @param string $suffix The localized short suffix, e.g. "KB", "MiB"
88
+     * @param string $singular The localized singular label of the size, e.g. "Kilobyte".
89
+     * @param string $plural The localized plural label of the size, e.g. "Kilobytes".
90
+     * 
91
+     * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
92
+     */
93 93
     protected static function addSize(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) : void
94 94
     {
95 95
         self::$sizes[$name] = new ConvertHelper_StorageSizeEnum_Size(
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
         );
103 103
     }
104 104
     
105
-   /**
106
-    * Retrieves all known sizes.
107
-    * 
108
-    * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
109
-    */
105
+    /**
106
+     * Retrieves all known sizes.
107
+     * 
108
+     * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
109
+     */
110 110
     public static function getSizes() : array
111 111
     {
112 112
         self::init();
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
         return self::$sizes;
115 115
     }
116 116
     
117
-   /**
118
-    * Retrieves a size definition instance by its name.
119
-    * 
120
-    * @param string $name Case insensitive. For example "kb", "MiB"...
121
-    * @throws ConvertHelper_Exception
122
-    * @return ConvertHelper_StorageSizeEnum_Size
123
-    * 
124
-    * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME
125
-    */
117
+    /**
118
+     * Retrieves a size definition instance by its name.
119
+     * 
120
+     * @param string $name Case insensitive. For example "kb", "MiB"...
121
+     * @throws ConvertHelper_Exception
122
+     * @return ConvertHelper_StorageSizeEnum_Size
123
+     * 
124
+     * @see ConvertHelper_StorageSizeEnum::ERROR_UNKNOWN_UNIT_NAME
125
+     */
126 126
     public static function getSizeByName(string $name) : ConvertHelper_StorageSizeEnum_Size
127 127
     {
128 128
         self::init();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         );
145 145
     }
146 146
     
147
-   /**
148
-    * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase).
149
-    * @return array
150
-    */
147
+    /**
148
+     * Retrieves a list of all size names, e.g. "mb", "kib" (lowercase).
149
+     * @return array
150
+     */
151 151
     public static function getSizeNames() : array
152 152
     {
153 153
         self::init();
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
         return array_keys(self::$sizes);
156 156
     }
157 157
    
158
-   /**
159
-    * Retrieves all available storage sizes for the specified
160
-    * base value.
161
-    * 
162
-    * @param int $base
163
-    * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
164
-    * 
165
-    * @see ConvertHelper_StorageSizeEnum::BASE_10
166
-    * @see ConvertHelper_StorageSizeEnum::BASE_2
167
-    */
158
+    /**
159
+     * Retrieves all available storage sizes for the specified
160
+     * base value.
161
+     * 
162
+     * @param int $base
163
+     * @return \AppUtils\ConvertHelper_StorageSizeEnum_Size[]
164
+     * 
165
+     * @see ConvertHelper_StorageSizeEnum::BASE_10
166
+     * @see ConvertHelper_StorageSizeEnum::BASE_2
167
+     */
168 168
     public static function getSizesByBase(int $base) : array
169 169
     {
170 170
         self::init();
Please login to merge, or discard this patch.