Passed
Push — master ( 9adcd8...42367a )
by Sebastian
02:21
created
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()
46 46
     {
47
-        if(isset(self::$sizes)) {
47
+        if (isset(self::$sizes)) {
48 48
             return;
49 49
         }
50 50
         
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         
65 65
         self::addSize('b', 1, 1, t('B'), t('Byte'), t('Bytes'));
66 66
         
67
-        if(class_exists('AppLocalize\Localization')) 
67
+        if (class_exists('AppLocalize\Localization')) 
68 68
         {
69 69
             \AppLocalize\Localization::onLocaleChanged(array(self::class, 'handle_localeChanged'));
70 70
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         
133 133
         $name = strtolower($name);
134 134
         
135
-        if(isset(self::$sizes[$name])) {
135
+        if (isset(self::$sizes[$name])) {
136 136
             return self::$sizes[$name];
137 137
         }
138 138
         
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
         
175 175
         $result = array();
176 176
         
177
-        foreach(self::$sizes as $size)
177
+        foreach (self::$sizes as $size)
178 178
         {
179
-            if($size->getBase() === $base) {
179
+            if ($size->getBase() === $base) {
180 180
                 $result[] = $size;
181 181
             }
182 182
         }
Please login to merge, or discard this patch.
src/ConvertHelper/SizeNotation.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     * @return string
100 100
     * @see ConvertHelper::bytes2readable()
101 101
     */
102
-    public function toString(int $precision=1) : string
102
+    public function toString(int $precision = 1) : string
103 103
     {
104 104
         return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase());
105 105
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     */
111 111
     public function getBase() : int
112 112
     {
113
-        if($this->isValid()) {
113
+        if ($this->isValid()) {
114 114
             return $this->sizeDefinition->getBase(); 
115 115
         }
116 116
         
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     */
127 127
     public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size
128 128
     {
129
-        if($this->isValid()) {
129
+        if ($this->isValid()) {
130 130
             return $this->sizeDefinition;
131 131
         }
132 132
         
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
     
176 176
     protected function parseSize() : void
177 177
     {
178
-        if(!$this->detectParts()) {
178
+        if (!$this->detectParts()) {
179 179
             return;
180 180
         }
181 181
         
182 182
         // we detected units in the string: all good.
183
-        if($this->units !== null)
183
+        if ($this->units !== null)
184 184
         {
185 185
             return;
186 186
         }
187 187
         
188 188
         // just a numeric value: we assume this means we're dealing with bytes.
189
-        if(is_numeric($this->number)) 
189
+        if (is_numeric($this->number)) 
190 190
         {
191 191
             $this->units = 'b';
192 192
             return;
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
         
213 213
         $number = $this->sizeString;
214 214
         
215
-        foreach($units as $unit)
215
+        foreach ($units as $unit)
216 216
         {
217
-            if(stristr($number, $unit))
217
+            if (stristr($number, $unit))
218 218
             {
219 219
                 // there are more than 1 unit defined in the string
220
-                if($this->units !== null)
220
+                if ($this->units !== null)
221 221
                 {
222 222
                     $this->setError(
223 223
                         t(
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
     {
274 274
         $this->parseSize();
275 275
         
276
-        if(!$this->valid) {
276
+        if (!$this->valid) {
277 277
             return;
278 278
         }
279 279
         
280 280
         $int = intval($this->number);
281 281
         
282 282
         // negative values
283
-        if($int < 0) 
283
+        if ($int < 0) 
284 284
         {
285 285
             $this->setError(
286 286
                 t('Negative values cannot be used as size.'),
Please login to merge, or discard this patch.
src/URLInfo/Parser.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         
60 60
         $this->parse();
61 61
         
62
-        if(!$this->detectType()) {
62
+        if (!$this->detectType()) {
63 63
             $this->validate();
64 64
         }
65 65
     }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
             'phoneLink'
94 94
         );
95 95
         
96
-        foreach($types as $type)
96
+        foreach ($types as $type)
97 97
         {
98 98
             $method = 'detectType_'.$type;
99 99
             
100
-            if($this->$method() === true) 
100
+            if ($this->$method() === true) 
101 101
             {
102 102
                 $this->isValid = true;
103 103
                 return true;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
             'hostIsPresent'
116 116
         );
117 117
         
118
-        foreach($validations as $validation) 
118
+        foreach ($validations as $validation) 
119 119
         {
120 120
             $method = 'validate_'.$validation;
121 121
             
122
-            if($this->$method() !== true) {
122
+            if ($this->$method() !== true) {
123 123
                 return;
124 124
             }
125 125
         }
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
         // every link needs a host. This case can happen for ex, if
133 133
         // the link starts with a typo with only one slash, like:
134 134
         // "http:/hostname"
135
-        if(isset($this->info['host'])) {
135
+        if (isset($this->info['host'])) {
136 136
             return true;
137 137
         }
138 138
         
139 139
         $this->setError(
140 140
             URLInfo::ERROR_MISSING_HOST,
141
-            t('Cannot determine the link\'s host name.') . ' ' .
141
+            t('Cannot determine the link\'s host name.').' '.
142 142
             t('This usually happens when there\'s a typo somewhere.')
143 143
         );
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     
148 148
     protected function validate_schemeIsSet() : bool
149 149
     {
150
-        if(isset($this->info['scheme'])) {
150
+        if (isset($this->info['scheme'])) {
151 151
             return true;
152 152
         }
153 153
         
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
     
165 165
     protected function validate_schemeIsKnown() : bool
166 166
     {
167
-        if(in_array($this->info['scheme'], $this->knownSchemes)) {
167
+        if (in_array($this->info['scheme'], $this->knownSchemes)) {
168 168
             return true;
169 169
         }
170 170
         
171 171
         $this->setError(
172 172
             URLInfo::ERROR_INVALID_SCHEME,
173
-            t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' .
173
+            t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '.
174 174
             t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes))
175 175
         );
176 176
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
     */
185 185
     protected function filterParsed()
186 186
     {
187
-        foreach($this->info as $key => $val)
187
+        foreach ($this->info as $key => $val)
188 188
         {
189
-            if(is_string($val)) {
189
+            if (is_string($val)) {
190 190
                 $this->info[$key] = trim($val);
191 191
             }
192 192
         }
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
         $this->info['params'] = array();
195 195
         $this->info['type'] = URLInfo::TYPE_URL;
196 196
         
197
-        if(isset($this->info['host'])) {
197
+        if (isset($this->info['host'])) {
198 198
             $this->info['host'] = str_replace(' ', '', $this->info['host']);
199 199
         }
200 200
         
201
-        if(isset($this->info['path'])) {
201
+        if (isset($this->info['path'])) {
202 202
             $this->info['path'] = str_replace(' ', '', $this->info['path']);
203 203
         }
204 204
         
205
-        if(isset($this->info['query']) && !empty($this->info['query']))
205
+        if (isset($this->info['query']) && !empty($this->info['query']))
206 206
         {
207 207
             $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']);
208 208
             ksort($this->info['params']);
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
     
212 212
     protected function detectType_email() : bool
213 213
     {
214
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
214
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
215 215
             $this->info['type'] = URLInfo::TYPE_EMAIL;
216 216
             return true;
217 217
         }
218 218
         
219
-        if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
219
+        if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
220 220
         {
221 221
             $this->info['scheme'] = 'mailto';
222 222
             $this->info['type'] = URLInfo::TYPE_EMAIL;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     
229 229
     protected function detectType_fragmentLink() : bool
230 230
     {
231
-        if(isset($this->info['fragment']) && !isset($this->info['scheme'])) {
231
+        if (isset($this->info['fragment']) && !isset($this->info['scheme'])) {
232 232
             $this->info['type'] = URLInfo::TYPE_FRAGMENT;
233 233
             return true;
234 234
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     
239 239
     protected function detectType_phoneLink() : bool
240 240
     {
241
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
241
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
242 242
             $this->info['type'] = URLInfo::TYPE_PHONE;
243 243
             return true;
244 244
         }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
     public function getErrorMessage() : string
265 265
     {
266
-        if(isset($this->error)) {
266
+        if (isset($this->error)) {
267 267
             return $this->error['message'];
268 268
         }
269 269
         
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     
273 273
     public function getErrorCode() : int
274 274
     {
275
-        if(isset($this->error)) {
275
+        if (isset($this->error)) {
276 276
             return $this->error['code'];
277 277
         }
278 278
         
Please login to merge, or discard this patch.
src/URLInfo.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     {
199 199
         $port = $this->getInfoKey('port');
200 200
         
201
-        if(!empty($port)) {
201
+        if (!empty($port)) {
202 202
             return (int)$port;
203 203
         }
204 204
         
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
     
279 279
     protected function getInfoKey(string $name) : string
280 280
     {
281
-        if(isset($this->info[$name])) {
281
+        if (isset($this->info[$name])) {
282 282
             return (string)$this->info[$name];
283 283
         }
284 284
         
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 
288 288
     public function getNormalized() : string
289 289
     {
290
-        if(!$this->isValid()) {
290
+        if (!$this->isValid()) {
291 291
             return '';
292 292
         }
293 293
         
294
-        if(!isset($this->normalizer)) {
294
+        if (!isset($this->normalizer)) {
295 295
             $this->normalizer = new URLInfo_Normalizer($this);
296 296
         }
297 297
         
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     */
320 320
     public function getHighlighted() : string
321 321
     {
322
-        if(!$this->isValid()) {
322
+        if (!$this->isValid()) {
323 323
             return '';
324 324
         }
325 325
         
@@ -361,14 +361,14 @@  discard block
 block discarded – undo
361 361
     */
362 362
     public function getParams() : array
363 363
     {
364
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
364
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
365 365
             return $this->info['params'];
366 366
         }
367 367
         
368 368
         $keep = array();
369
-        foreach($this->info['params'] as $name => $value) 
369
+        foreach ($this->info['params'] as $name => $value) 
370 370
         {
371
-            if(!isset($this->excludedParams[$name])) {
371
+            if (!isset($this->excludedParams[$name])) {
372 372
                 $keep[$name] = $value;
373 373
             }
374 374
         }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
     */
395 395
     public function getParam(string $name) : string
396 396
     {
397
-        if(isset($this->info['params'][$name])) {
397
+        if (isset($this->info['params'][$name])) {
398 398
             return $this->info['params'][$name];
399 399
         }
400 400
         
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     */
414 414
     public function excludeParam(string $name, string $reason) : URLInfo
415 415
     {
416
-        if(!isset($this->excludedParams[$name]))
416
+        if (!isset($this->excludedParams[$name]))
417 417
         {
418 418
             $this->excludedParams[$name] = $reason;
419 419
             $this->setParamExclusion();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     
440 440
     public function getTypeLabel() : string
441 441
     {
442
-        if(!isset(self::$typeLabels))
442
+        if (!isset(self::$typeLabels))
443 443
         {
444 444
             self::$typeLabels = array(
445 445
                 self::TYPE_EMAIL => t('Email'),
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         
452 452
         $type = $this->getType();
453 453
         
454
-        if(!isset(self::$typeLabels[$type]))
454
+        if (!isset(self::$typeLabels[$type]))
455 455
         {
456 456
             throw new BaseException(
457 457
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
     * @param bool $highlight
472 472
     * @return URLInfo
473 473
     */
474
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
474
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
475 475
     {
476 476
         $this->highlightExcluded = $highlight;
477 477
         return $this;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
      * @see URLInfo::isParamExclusionEnabled()
520 520
      * @see URLInfo::setHighlightExcluded()
521 521
      */
522
-    public function setParamExclusion(bool $enabled=true) : URLInfo
522
+    public function setParamExclusion(bool $enabled = true) : URLInfo
523 523
     {
524 524
         $this->paramExclusion = $enabled;
525 525
         return $this;
@@ -545,13 +545,13 @@  discard block
 block discarded – undo
545 545
     */
546 546
     public function containsExcludedParams() : bool
547 547
     {
548
-        if(empty($this->excludedParams)) {
548
+        if (empty($this->excludedParams)) {
549 549
             return false;
550 550
         }
551 551
         
552 552
         $names = array_keys($this->info['params']);
553
-        foreach($names as $name) {
554
-            if(isset($this->excludedParams[$name])) {
553
+        foreach ($names as $name) {
554
+            if (isset($this->excludedParams[$name])) {
555 555
                 return true;
556 556
             }
557 557
         }
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
     public function offsetSet($offset, $value) 
569 569
     {
570
-        if(in_array($offset, $this->infoKeys)) {
570
+        if (in_array($offset, $this->infoKeys)) {
571 571
             $this->info[$offset] = $value;
572 572
         }
573 573
     }
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
     
585 585
     public function offsetGet($offset) 
586 586
     {
587
-        if($offset === 'port') {
587
+        if ($offset === 'port') {
588 588
             return $this->getPort();
589 589
         }
590 590
         
591
-        if(in_array($offset, $this->infoKeys)) {
591
+        if (in_array($offset, $this->infoKeys)) {
592 592
             return $this->getInfoKey($offset);
593 593
         }
594 594
         
Please login to merge, or discard this patch.
src/URLInfo/Highlighter.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             'fragment'
78 78
         );
79 79
         
80
-        foreach($parts as $part) 
80
+        foreach ($parts as $part) 
81 81
         {
82 82
             $method = 'render_'.$part;
83 83
             $result[] = (string)$this->$method();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     
89 89
     protected function render_scheme() : string
90 90
     {
91
-        if(!$this->info->hasScheme()) {
91
+        if (!$this->info->hasScheme()) {
92 92
             return '';
93 93
         }
94 94
         
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     
104 104
     protected function render_username() : string
105 105
     {
106
-        if(!$this->info->hasUsername()) {
106
+        if (!$this->info->hasUsername()) {
107 107
             return '';
108 108
         }
109 109
         
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     
120 120
     protected function render_host() : string
121 121
     {
122
-        if(!$this->info->hasHost()) {
122
+        if (!$this->info->hasHost()) {
123 123
             return '';
124 124
         }
125 125
         
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     
132 132
     protected function render_port() : string
133 133
     {
134
-        if(!$this->info->hasPort()) {
134
+        if (!$this->info->hasPort()) {
135 135
             return '';
136 136
         }
137 137
         
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
        
145 145
     protected function render_path() : string
146 146
     {
147
-        if(!$this->info->hasPath()) {
147
+        if (!$this->info->hasPath()) {
148 148
             return '';
149 149
         }
150 150
         
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $params = $this->info->getParams();
164 164
         
165
-        if(empty($params)) {
165
+        if (empty($params)) {
166 166
             return '';
167 167
         }
168 168
         
169 169
         $tokens = array();
170 170
         $excluded = array();
171 171
         
172
-        if($this->info->isParamExclusionEnabled())
172
+        if ($this->info->isParamExclusionEnabled())
173 173
         {
174 174
             $excluded = $this->info->getExcludedParams();
175 175
         }
176 176
         
177
-        foreach($params as $param => $value)
177
+        foreach ($params as $param => $value)
178 178
         {
179 179
             $parts = sprintf(
180 180
                 '<span class="link-param-name">%s</span>'.
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
             $tag = '';
193 193
             
194 194
             // is parameter exclusion enabled, and is this an excluded parameter?
195
-            if(isset($excluded[$param]))            
195
+            if (isset($excluded[$param]))            
196 196
             {
197 197
                 // display the excluded parameter, but highlight it
198
-                if($this->info->isHighlightExcludeEnabled())
198
+                if ($this->info->isHighlightExcludeEnabled())
199 199
                 {
200 200
                     $tooltip = $excluded[$param];
201 201
                     
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      
229 229
     protected function render_fragment() : string
230 230
     {
231
-        if(!$this->info->hasFragment()) {
231
+        if (!$this->info->hasFragment()) {
232 232
             return '';
233 233
         }
234 234
         
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $cssFolder = realpath(__DIR__.'/../../css');
245 245
         
246
-        if($cssFolder === false) {
246
+        if ($cssFolder === false) {
247 247
             throw new BaseException(
248 248
                 'Cannot find package CSS folder.',
249 249
                 null,
Please login to merge, or discard this patch.
src/URLInfo/Normalizer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,16 +56,16 @@
 block discarded – undo
56 56
     {
57 57
         $normalized = $this->info->getScheme().'://'.$this->info->getHost();
58 58
         
59
-        if($this->info->hasPath()) {
59
+        if ($this->info->hasPath()) {
60 60
             $normalized .= $this->info->getPath();
61 61
         }
62 62
         
63 63
         $params = $this->info->getParams();
64
-        if(!empty($params)) {
64
+        if (!empty($params)) {
65 65
             $normalized .= '?'.http_build_query($params);
66 66
         }
67 67
         
68
-        if($this->info->hasFragment()) {
68
+        if ($this->info->hasFragment()) {
69 69
             $normalized .= '#'.$this->info->getFragment();
70 70
         }
71 71
         
Please login to merge, or discard this patch.
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, '&amp;');
195
+            $url .= '?'.http_build_query($params, null, '&amp;');
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.
src/FileHelper.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         
109 109
         $contents = file_get_contents($file);
110 110
         
111
-        if($contents === false) 
111
+        if ($contents === false) 
112 112
         {
113 113
             throw new FileHelper_Exception(
114 114
                 'Cannot load serialized content from file.',
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         
123 123
         $result = @unserialize($contents);
124 124
         
125
-        if($result !== false) {
125
+        if ($result !== false) {
126 126
             return $result;
127 127
         }
128 128
         
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     
139 139
     public static function deleteTree($rootFolder)
140 140
     {
141
-        if(!file_exists($rootFolder)) {
141
+        if (!file_exists($rootFolder)) {
142 142
             return true;
143 143
         }
144 144
         
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     */
180 180
     public static function createFolder($path)
181 181
     {
182
-        if(is_dir($path) || mkdir($path, 0777, true)) {
182
+        if (is_dir($path) || mkdir($path, 0777, true)) {
183 183
             return;
184 184
         }
185 185
         
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
 
215 215
             if ($item->isDir()) 
216 216
             {
217
-                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target . '/' . $baseName);
217
+                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target.'/'.$baseName);
218 218
             } 
219
-            else if($item->isFile()) 
219
+            else if ($item->isFile()) 
220 220
             {
221
-                self::copyFile($itemPath, $target . '/' . $baseName);
221
+                self::copyFile($itemPath, $target.'/'.$baseName);
222 222
             }
223 223
         }
224 224
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND);
245 245
         
246
-        if(!is_readable($sourcePath))
246
+        if (!is_readable($sourcePath))
247 247
         {
248 248
             throw new FileHelper_Exception(
249 249
                 sprintf('Source file [%s] to copy is not readable.', basename($sourcePath)),
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
         
258 258
         $targetFolder = dirname($targetPath);
259 259
         
260
-        if(!file_exists($targetFolder))
260
+        if (!file_exists($targetFolder))
261 261
         {
262 262
             self::createFolder($targetFolder);
263 263
         }
264
-        else if(!is_writable($targetFolder)) 
264
+        else if (!is_writable($targetFolder)) 
265 265
         {
266 266
             throw new FileHelper_Exception(
267 267
                 sprintf('Target folder [%s] is not writable.', basename($targetFolder)),
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
             );
274 274
         }
275 275
         
276
-        if(copy($sourcePath, $targetPath)) {
276
+        if (copy($sourcePath, $targetPath)) {
277 277
             return;
278 278
         }
279 279
         
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
     */
301 301
     public static function deleteFile(string $filePath) : void
302 302
     {
303
-        if(!file_exists($filePath)) {
303
+        if (!file_exists($filePath)) {
304 304
             return;
305 305
         }
306 306
         
307
-        if(unlink($filePath)) {
307
+        if (unlink($filePath)) {
308 308
             return;
309 309
         }
310 310
         
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
     * @return \parseCSV
329 329
     * @todo Move this to the CSV helper.
330 330
     */
331
-    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : \parseCSV
331
+    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : \parseCSV
332 332
     {
333
-        if($delimiter==='') { $delimiter = ';'; }
334
-        if($enclosure==='') { $enclosure = '"'; }
333
+        if ($delimiter === '') { $delimiter = ';'; }
334
+        if ($enclosure === '') { $enclosure = '"'; }
335 335
         
336 336
         $parser = new \parseCSV(null, null, null, array());
337 337
 
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
     * @see parseCSVFile()
360 360
     * @see FileHelper::ERROR_PARSING_CSV
361 361
     */
362
-    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
362
+    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
363 363
     {
364 364
         $parser = self::createCSVParser($delimiter, $enclosure, $escape, $heading);
365 365
         $result = $parser->parse_string(/** @scrutinizer ignore-type */ $csv);
366
-        if(is_array($result)) {
366
+        if (is_array($result)) {
367 367
             return $result;
368 368
         }
369 369
         
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
392 392
      * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
393 393
      */
394
-    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
394
+    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
395 395
     {
396 396
         $content = self::readContents($filePath);
397 397
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     public static function detectMimeType(string $fileName) : ?string
409 409
     {
410 410
         $ext = self::getExtension($fileName);
411
-        if(empty($ext)) {
411
+        if (empty($ext)) {
412 412
             return null;
413 413
         }
414 414
 
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
430 430
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
431 431
      */
432
-    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment=true)
432
+    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment = true)
433 433
     {
434 434
         self::requireFileExists($filePath);
435 435
         
436
-        if(empty($fileName)) {
436
+        if (empty($fileName)) {
437 437
             $fileName = basename($filePath);
438 438
         }
439 439
 
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
         
452 452
         header("Cache-Control: public", true);
453 453
         header("Content-Description: File Transfer", true);
454
-        header("Content-Type: " . $mime, true);
454
+        header("Content-Type: ".$mime, true);
455 455
 
456 456
         $disposition = 'inline';
457
-        if($asAttachment) {
457
+        if ($asAttachment) {
458 458
             $disposition = 'attachment';
459 459
         }
460 460
         
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public static function downloadFile($url)
482 482
     {
483
-        if(!function_exists('curl_init')) 
483
+        if (!function_exists('curl_init')) 
484 484
         {
485 485
             throw new FileHelper_Exception(
486 486
                 'The cURL extension is not installed.',
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         }
491 491
 
492 492
         $ch = curl_init();
493
-        if($ch === false) 
493
+        if ($ch === false) 
494 494
         {
495 495
             throw new FileHelper_Exception(
496 496
                 'Could not initialize a new cURL instance.',
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         
512 512
         $output = curl_exec($ch);
513 513
 
514
-        if($output === false) {
514
+        if ($output === false) {
515 515
             throw new FileHelper_Exception(
516 516
                 'Unable to open URL',
517 517
                 sprintf(
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
         curl_close($ch);
527 527
 
528
-        if(is_string($output)) 
528
+        if (is_string($output)) 
529 529
         {
530 530
             return $output;
531 531
         }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     */
548 548
     public static function isPHPFile($pathOrDirIterator)
549 549
     {
550
-    	if(self::getExtension($pathOrDirIterator) == 'php') {
550
+    	if (self::getExtension($pathOrDirIterator) == 'php') {
551 551
     		return true;
552 552
     	}
553 553
     	
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
     */
565 565
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
566 566
     {
567
-        if($pathOrDirIterator instanceof \DirectoryIterator) {
567
+        if ($pathOrDirIterator instanceof \DirectoryIterator) {
568 568
             $filename = $pathOrDirIterator->getFilename();
569 569
         } else {
570 570
             $filename = basename($pathOrDirIterator);
571 571
         }
572 572
          
573 573
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
574
-        if($lowercase) {
574
+        if ($lowercase) {
575 575
         	$ext = mb_strtolower($ext);
576 576
         }
577 577
         
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
     public static function getFilename($pathOrDirIterator, $extension = true)
594 594
     {
595 595
         $path = $pathOrDirIterator;
596
-    	if($pathOrDirIterator instanceof \DirectoryIterator) {
596
+    	if ($pathOrDirIterator instanceof \DirectoryIterator) {
597 597
     		$path = $pathOrDirIterator->getFilename();
598 598
     	}
599 599
     	
600 600
     	$path = self::normalizePath($path);
601 601
     	
602
-    	if(!$extension) {
602
+    	if (!$extension) {
603 603
     	    return pathinfo($path, PATHINFO_FILENAME);
604 604
     	}
605 605
     	
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
     * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
618 618
     * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
619 619
     */ 
620
-    public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null)
620
+    public static function parseJSONFile(string $file, $targetEncoding = null, $sourceEncoding = null)
621 621
     {
622 622
         self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE);
623 623
         
624 624
         $content = file_get_contents($file);
625
-        if(!$content) {
625
+        if (!$content) {
626 626
             throw new FileHelper_Exception(
627 627
                 'Cannot get file contents',
628 628
                 sprintf(
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
             );
634 634
         }
635 635
         
636
-        if(isset($targetEncoding)) {
636
+        if (isset($targetEncoding)) {
637 637
             $content = mb_convert_encoding($content, $targetEncoding, $sourceEncoding);
638 638
         }
639 639
         
640 640
         $json = json_decode($content, true);
641
-        if($json === false || $json === NULL) {
641
+        if ($json === false || $json === NULL) {
642 642
             throw new FileHelper_Exception(
643 643
                 'Cannot decode json data',
644 644
                 sprintf(
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
         
679 679
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
680 680
         
681
-        while(strstr($name, '  ')) {
681
+        while (strstr($name, '  ')) {
682 682
             $name = str_replace('  ', ' ', $name);
683 683
         }
684 684
 
685 685
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
686 686
         
687
-        while(strstr($name, '..')) {
687
+        while (strstr($name, '..')) {
688 688
             $name = str_replace('..', '.', $name);
689 689
         }
690 690
         
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
     * @return array An indexed array with files.
717 717
     * @see FileHelper::createFileFinder()
718 718
     */
719
-    public static function findHTMLFiles(string $targetFolder, array $options=array()) : array
719
+    public static function findHTMLFiles(string $targetFolder, array $options = array()) : array
720 720
     {
721 721
         return self::findFiles($targetFolder, array('html'), $options);
722 722
     }
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     * @return array An indexed array of PHP files.
734 734
     * @see FileHelper::createFileFinder()
735 735
     */
736
-    public static function findPHPFiles(string $targetFolder, array $options=array()) : array
736
+    public static function findPHPFiles(string $targetFolder, array $options = array()) : array
737 737
     {
738 738
         return self::findFiles($targetFolder, array('php'), $options);
739 739
     }
@@ -753,20 +753,20 @@  discard block
 block discarded – undo
753 753
     * @return array
754 754
     * @see FileHelper::createFileFinder()
755 755
     */
756
-    public static function findFiles(string $targetFolder, array $extensions=array(), array $options=array(), array $files=array()) : array
756
+    public static function findFiles(string $targetFolder, array $extensions = array(), array $options = array(), array $files = array()) : array
757 757
     {
758 758
         $finder = self::createFileFinder($targetFolder);
759 759
 
760
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
760
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
761 761
         {
762 762
             $finder->setPathmodeRelative();
763 763
         } 
764
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
764
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
765 765
         {
766 766
             $finder->setPathmodeAbsolute();
767 767
         }
768 768
         
769
-        if(isset($options['strip-extension'])) 
769
+        if (isset($options['strip-extension'])) 
770 770
         {
771 771
             $finder->stripExtensions();
772 772
         }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     public static function detectUTFBom(string $filename) : ?string
811 811
     {
812 812
         $fp = fopen($filename, 'r');
813
-        if($fp === false) 
813
+        if ($fp === false) 
814 814
         {
815 815
             throw new FileHelper_Exception(
816 816
                 'Cannot open file for reading',
@@ -825,10 +825,10 @@  discard block
 block discarded – undo
825 825
 
826 826
         $boms = self::getUTFBOMs();
827 827
         
828
-        foreach($boms as $bom => $value) 
828
+        foreach ($boms as $bom => $value) 
829 829
         {
830 830
             $length = mb_strlen($value);
831
-            if(mb_substr($text, 0, $length) == $value) {
831
+            if (mb_substr($text, 0, $length) == $value) {
832 832
                 return $bom;
833 833
             }
834 834
         }
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
     */
848 848
     public static function getUTFBOMs()
849 849
     {
850
-        if(!isset(self::$utfBoms)) {
850
+        if (!isset(self::$utfBoms)) {
851 851
             self::$utfBoms = array(
852
-                'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
853
-                'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
854
-                'UTF16-BE' => chr(0xFE) . chr(0xFF),
855
-                'UTF16-LE' => chr(0xFF) . chr(0xFE),
856
-                'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
852
+                'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
853
+                'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
854
+                'UTF16-BE' => chr(0xFE).chr(0xFF),
855
+                'UTF16-LE' => chr(0xFF).chr(0xFE),
856
+                'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
857 857
             );
858 858
         }
859 859
         
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
         $encodings = self::getKnownUnicodeEncodings();
875 875
 
876 876
         $keep = array();
877
-        foreach($encodings as $string) 
877
+        foreach ($encodings as $string) 
878 878
         {
879 879
             $withHyphen = str_replace('UTF', 'UTF-', $string);
880 880
             
@@ -921,16 +921,16 @@  discard block
 block discarded – undo
921 921
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
922 922
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
923 923
     */
924
-    public static function saveAsJSON($data, string $file, bool $pretty=false)
924
+    public static function saveAsJSON($data, string $file, bool $pretty = false)
925 925
     {
926 926
         $options = null;
927
-        if($pretty) {
927
+        if ($pretty) {
928 928
             $options = JSON_PRETTY_PRINT;
929 929
         }
930 930
         
931 931
         $json = json_encode($data, $options);
932 932
         
933
-        if($json===false) 
933
+        if ($json === false) 
934 934
         {
935 935
             $errorCode = json_last_error();
936 936
             
@@ -956,12 +956,12 @@  discard block
 block discarded – undo
956 956
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
957 957
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
958 958
     */
959
-    public static function saveFile(string $filePath, string $content='') : void
959
+    public static function saveFile(string $filePath, string $content = '') : void
960 960
     {
961 961
         // target file already exists
962
-        if(file_exists($filePath))
962
+        if (file_exists($filePath))
963 963
         {
964
-            if(!is_writable($filePath))
964
+            if (!is_writable($filePath))
965 965
             {
966 966
                 throw new FileHelper_Exception(
967 967
                     sprintf('Cannot save file: target file [%s] exists, but is not writable.', basename($filePath)),
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
             // create the folder as needed
982 982
             self::createFolder($targetFolder);
983 983
             
984
-            if(!is_writable($targetFolder)) 
984
+            if (!is_writable($targetFolder)) 
985 985
             {
986 986
                 throw new FileHelper_Exception(
987 987
                     sprintf('Cannot save file: target folder [%s] is not writable.', basename($targetFolder)),
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
             }
995 995
         }
996 996
         
997
-        if(file_put_contents($filePath, $content) !== false) {
997
+        if (file_put_contents($filePath, $content) !== false) {
998 998
             return;
999 999
         }
1000 1000
         
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
     {
1033 1033
         static $checked = array();
1034 1034
         
1035
-        if(isset($checked[$command])) {
1035
+        if (isset($checked[$command])) {
1036 1036
             return $checked[$command];
1037 1037
         }
1038 1038
         
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
         
1046 1046
         $os = strtolower(PHP_OS_FAMILY);
1047 1047
         
1048
-        if(!isset($osCommands[$os])) 
1048
+        if (!isset($osCommands[$os])) 
1049 1049
         {
1050 1050
             throw new FileHelper_Exception(
1051 1051
                 'Unsupported OS for CLI commands',
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
             $pipes
1072 1072
         );
1073 1073
         
1074
-        if($process === false) {
1074
+        if ($process === false) {
1075 1075
             $checked[$command] = false;
1076 1076
             return false;
1077 1077
         }
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
     */
1103 1103
     public static function checkPHPFileSyntax($path)
1104 1104
     {
1105
-        if(!self::canMakePHPCalls()) {
1105
+        if (!self::canMakePHPCalls()) {
1106 1106
             return true;
1107 1107
         }
1108 1108
         
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
         // when the validation is successful, the first entry
1114 1114
         // in the array contains the success message. When it
1115 1115
         // is invalid, the first entry is always empty.
1116
-        if(!empty($output[0])) {
1116
+        if (!empty($output[0])) {
1117 1117
             return true;
1118 1118
         }
1119 1119
         
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
     public static function getModifiedDate($path)
1135 1135
     {
1136 1136
         $time = filemtime($path);
1137
-        if($time !== false) {
1137
+        if ($time !== false) {
1138 1138
             $date = new \DateTime();
1139 1139
             $date->setTimestamp($time);
1140 1140
             return $date;
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
     */
1164 1164
     public static function getSubfolders($targetFolder, $options = array())
1165 1165
     {
1166
-        if(!is_dir($targetFolder)) 
1166
+        if (!is_dir($targetFolder)) 
1167 1167
         {
1168 1168
             throw new FileHelper_Exception(
1169 1169
                 'Target folder does not exist',
@@ -1187,29 +1187,29 @@  discard block
 block discarded – undo
1187 1187
         
1188 1188
         $d = new \DirectoryIterator($targetFolder);
1189 1189
         
1190
-        foreach($d as $item) 
1190
+        foreach ($d as $item) 
1191 1191
         {
1192
-            if($item->isDir() && !$item->isDot()) 
1192
+            if ($item->isDir() && !$item->isDot()) 
1193 1193
             {
1194 1194
                 $name = $item->getFilename();
1195 1195
                 
1196
-                if(!$options['absolute-path']) {
1196
+                if (!$options['absolute-path']) {
1197 1197
                     $result[] = $name;
1198 1198
                 } else {
1199 1199
                     $result[] = $targetFolder.'/'.$name;
1200 1200
                 }
1201 1201
                 
1202
-                if(!$options['recursive']) 
1202
+                if (!$options['recursive']) 
1203 1203
                 {
1204 1204
                     continue;
1205 1205
                 }
1206 1206
                 
1207 1207
                 $subs = self::getSubfolders($targetFolder.'/'.$name, $options);
1208
-                foreach($subs as $sub) 
1208
+                foreach ($subs as $sub) 
1209 1209
                 {
1210 1210
                     $relative = $name.'/'.$sub;
1211 1211
                     
1212
-                    if(!$options['absolute-path']) {
1212
+                    if (!$options['absolute-path']) {
1213 1213
                         $result[] = $relative;
1214 1214
                     } else {
1215 1215
                         $result[] = $targetFolder.'/'.$relative;
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
     * @param int $depth The folder depth to reduce the path to
1278 1278
     * @return string
1279 1279
     */
1280
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
1280
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
1281 1281
     {
1282 1282
         $path = self::normalizePath($path);
1283 1283
         
@@ -1285,17 +1285,17 @@  discard block
 block discarded – undo
1285 1285
         $tokens = array_filter($tokens); // remove empty entries (trailing slash for example)
1286 1286
         $tokens = array_values($tokens); // re-index keys
1287 1287
         
1288
-        if(empty($tokens)) {
1288
+        if (empty($tokens)) {
1289 1289
             return '';
1290 1290
         }
1291 1291
         
1292 1292
         // remove the drive if present
1293
-        if(strstr($tokens[0], ':')) {
1293
+        if (strstr($tokens[0], ':')) {
1294 1294
             array_shift($tokens);
1295 1295
         }
1296 1296
         
1297 1297
         // path was only the drive
1298
-        if(count($tokens) == 0) {
1298
+        if (count($tokens) == 0) {
1299 1299
             return '';
1300 1300
         }
1301 1301
 
@@ -1304,8 +1304,8 @@  discard block
 block discarded – undo
1304 1304
         
1305 1305
         // reduce the path to the specified depth
1306 1306
         $length = count($tokens);
1307
-        if($length > $depth) {
1308
-            $tokens = array_slice($tokens, $length-$depth);
1307
+        if ($length > $depth) {
1308
+            $tokens = array_slice($tokens, $length - $depth);
1309 1309
         }
1310 1310
 
1311 1311
         // append the last element again
@@ -1353,14 +1353,14 @@  discard block
 block discarded – undo
1353 1353
     * 
1354 1354
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1355 1355
     */
1356
-    public static function requireFileExists(string $path, $errorCode=null) : string
1356
+    public static function requireFileExists(string $path, $errorCode = null) : string
1357 1357
     {
1358 1358
         $result = realpath($path);
1359
-        if($result !== false) {
1359
+        if ($result !== false) {
1360 1360
             return $result;
1361 1361
         }
1362 1362
         
1363
-        if($errorCode === null) {
1363
+        if ($errorCode === null) {
1364 1364
             $errorCode = self::ERROR_FILE_DOES_NOT_EXIST;
1365 1365
         }
1366 1366
         
@@ -1389,15 +1389,15 @@  discard block
 block discarded – undo
1389 1389
         
1390 1390
         $file = new \SplFileObject($path);
1391 1391
         
1392
-        if($file->eof()) {
1392
+        if ($file->eof()) {
1393 1393
             return '';
1394 1394
         }
1395 1395
         
1396
-        $targetLine = $lineNumber-1;
1396
+        $targetLine = $lineNumber - 1;
1397 1397
         
1398 1398
         $file->seek($targetLine);
1399 1399
         
1400
-        if($file->key() !== $targetLine) {
1400
+        if ($file->key() !== $targetLine) {
1401 1401
              return null;
1402 1402
         }
1403 1403
         
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
         $number = $spl->key();
1424 1424
         
1425 1425
         // if seeking to the end the cursor is still at 0, there are no lines. 
1426
-        if($number === 0) 
1426
+        if ($number === 0) 
1427 1427
         {
1428 1428
             // since it's a very small file, to get reliable results,
1429 1429
             // we read its contents and use that to determine what
@@ -1431,13 +1431,13 @@  discard block
 block discarded – undo
1431 1431
             // that this is not pactical to solve with the SplFileObject.
1432 1432
             $content = file_get_contents($path);
1433 1433
             
1434
-            if(empty($content)) {
1434
+            if (empty($content)) {
1435 1435
                 return 0;
1436 1436
             }
1437 1437
         }
1438 1438
         
1439 1439
         // return the line number we were able to reach + 1 (key is zero-based)
1440
-        return $number+1;
1440
+        return $number + 1;
1441 1441
     }
1442 1442
     
1443 1443
    /**
@@ -1484,13 +1484,13 @@  discard block
 block discarded – undo
1484 1484
     * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1485 1485
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1486 1486
     */
1487
-    public static function readLines(string $filePath, int $amount=0) : array
1487
+    public static function readLines(string $filePath, int $amount = 0) : array
1488 1488
     {
1489 1489
         self::requireFileExists($filePath);
1490 1490
         
1491 1491
         $fn = fopen($filePath, "r");
1492 1492
         
1493
-        if($fn === false) 
1493
+        if ($fn === false) 
1494 1494
         {
1495 1495
             throw new FileHelper_Exception(
1496 1496
                 'Could not open file for reading.',
@@ -1506,25 +1506,25 @@  discard block
 block discarded – undo
1506 1506
         $counter = 0;
1507 1507
         $first = true;
1508 1508
         
1509
-        while(!feof($fn)) 
1509
+        while (!feof($fn)) 
1510 1510
         {
1511 1511
             $counter++;
1512 1512
             
1513 1513
             $line = fgets($fn);
1514 1514
             
1515 1515
             // can happen with zero length files
1516
-            if($line === false) {
1516
+            if ($line === false) {
1517 1517
                 continue;
1518 1518
             }
1519 1519
             
1520 1520
             // the first line may contain a unicode BOM marker.
1521
-            if($first) {
1521
+            if ($first) {
1522 1522
                 $line = ConvertHelper::stripUTFBom($line);
1523 1523
             }
1524 1524
             
1525 1525
             $result[] = $line;
1526 1526
             
1527
-            if($amount > 0 && $counter == $amount) {
1527
+            if ($amount > 0 && $counter == $amount) {
1528 1528
                 break;
1529 1529
             }
1530 1530
         }
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
         
1551 1551
         $result = file_get_contents($filePath);
1552 1552
         
1553
-        if($result !== false) {
1553
+        if ($result !== false) {
1554 1554
             return $result;
1555 1555
         }
1556 1556
         
Please login to merge, or discard this patch.