Passed
Push — master ( ba00c7...bfa3fc )
by Sebastian
08:42
created
src/FileHelper/FileFinder.php 3 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @see \AppUtils\FileHelper\FileFinder
8 8
  */
9 9
 
10
-declare(strict_types = 1);
10
+declare(strict_types=1);
11 11
 
12 12
 namespace AppUtils\FileHelper;
13 13
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param bool $enabled
91 91
      * @return FileFinder
92 92
      */
93
-    public function makeRecursive(bool $enabled=true) : FileFinder
93
+    public function makeRecursive(bool $enabled = true) : FileFinder
94 94
     {
95 95
         return $this->setOption('recursive', $enabled);
96 96
     }
@@ -295,22 +295,22 @@  discard block
 block discarded – undo
295 295
         return $this->getAll();
296 296
     }
297 297
     
298
-    protected function find(string $path, bool $isRoot=false) : void
298
+    protected function find(string $path, bool $isRoot = false) : void
299 299
     {
300
-        if($isRoot) {
300
+        if ($isRoot) {
301 301
             $this->found = array();
302 302
         }
303 303
         
304 304
         $recursive = $this->getBoolOption('recursive');
305 305
         
306 306
         $d = new DirectoryIterator($path);
307
-        foreach($d as $item)
307
+        foreach ($d as $item)
308 308
         {
309 309
             $pathname = $item->getPathname();
310 310
             
311
-            if($item->isDir())
311
+            if ($item->isDir())
312 312
             {
313
-                if($recursive && !$item->isDot()) {
313
+                if ($recursive && !$item->isDot()) {
314 314
                     $this->find($pathname);
315 315
                 }
316 316
                 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             
320 320
             $file = $this->filterFile($pathname);
321 321
             
322
-            if($file !== null) 
322
+            if ($file !== null) 
323 323
             {
324 324
                 $this->found[] = $file;
325 325
             }
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
         
333 333
         $extension = FileHelper::getExtension($path);
334 334
         
335
-        if(!$this->filterExclusion($extension)) {
335
+        if (!$this->filterExclusion($extension)) {
336 336
             return null;
337 337
         }
338 338
         
339 339
         $path = $this->filterPath($path);
340 340
         
341
-        if($this->getOption('strip-extensions') === true)
341
+        if ($this->getOption('strip-extensions') === true)
342 342
         {
343 343
             $path = str_replace('.'.$extension, '', $path);
344 344
         }
345 345
         
346
-        if($path === '') {
346
+        if ($path === '') {
347 347
             return null;
348 348
         }
349 349
         
350 350
         $replace = $this->getOption('slash-replacement');
351
-        if(!empty($replace)) {
351
+        if (!empty($replace)) {
352 352
             $path = str_replace('/', $replace, $path);
353 353
         }
354 354
         
@@ -367,13 +367,13 @@  discard block
 block discarded – undo
367 367
         $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS);
368 368
         $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS);
369 369
         
370
-        if(!empty($include))
370
+        if (!empty($include))
371 371
         {
372
-            if(!in_array($extension, $include, true)) {
372
+            if (!in_array($extension, $include, true)) {
373 373
                 return false;
374 374
             }
375 375
         }
376
-        else if(!empty($exclude) && in_array($extension, $exclude, true))
376
+        else if (!empty($exclude) && in_array($extension, $exclude, true))
377 377
         {
378 378
             return false;
379 379
         }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     */
390 390
     protected function filterPath(string $path) : string
391 391
     {
392
-        switch($this->getStringOption(self::OPTION_PATHMODE))
392
+        switch ($this->getStringOption(self::OPTION_PATHMODE))
393 393
         {
394 394
             case self::PATH_MODE_STRIP:
395 395
                 return basename($path);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -372,8 +372,7 @@
 block discarded – undo
372 372
             if(!in_array($extension, $include, true)) {
373 373
                 return false;
374 374
             }
375
-        }
376
-        else if(!empty($exclude) && in_array($extension, $exclude, true))
375
+        } else if(!empty($exclude) && in_array($extension, $exclude, true))
377 376
         {
378 377
             return false;
379 378
         }
Please login to merge, or discard this patch.
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
 
45 45
     protected FolderInfo $path;
46 46
     
47
-   /**
48
-    * @var string[]
49
-    */
47
+    /**
48
+     * @var string[]
49
+     */
50 50
     protected array $found = array();
51 51
     
52
-   /**
53
-    * The path must exist when the class is instantiated: its
54
-    * real path will be determined to work with.
55
-    * 
56
-    * @param string|PathInfoInterface|SplFileInfo $path The absolute path to the target folder.
57
-    *
58
-    * @throws FileHelper_Exception
59
-    * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
60
-    */
52
+    /**
53
+     * The path must exist when the class is instantiated: its
54
+     * real path will be determined to work with.
55
+     * 
56
+     * @param string|PathInfoInterface|SplFileInfo $path The absolute path to the target folder.
57
+     *
58
+     * @throws FileHelper_Exception
59
+     * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
60
+     */
61 61
     public function __construct($path)
62 62
     {
63 63
         $this->path = AbstractPathInfo::resolveType($path)->requireExists()->requireIsFolder();
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
         );
76 76
     }
77 77
     
78
-   /**
79
-    * Enables extension stripping, to return file names without extension.
80
-    * 
81
-    * @return FileFinder
82
-    */
78
+    /**
79
+     * Enables extension stripping, to return file names without extension.
80
+     * 
81
+     * @return FileFinder
82
+     */
83 83
     public function stripExtensions() : FileFinder
84 84
     {
85 85
         return $this->setOption('strip-extensions', true);
@@ -96,46 +96,46 @@  discard block
 block discarded – undo
96 96
         return $this->setOption('recursive', $enabled);
97 97
     }
98 98
     
99
-   /**
100
-    * Retrieves all extensions that were added to
101
-    * the list of included extensions.
102
-    * 
103
-    * @return string[]
104
-    */
99
+    /**
100
+     * Retrieves all extensions that were added to
101
+     * the list of included extensions.
102
+     * 
103
+     * @return string[]
104
+     */
105 105
     public function getIncludeExtensions() : array
106 106
     {
107 107
         return $this->getArrayOption(self::OPTION_INCLUDE_EXTENSIONS);
108 108
     }
109 109
     
110
-   /**
111
-    * Includes a single extension in the file search: only
112
-    * files with this extension will be used in the results.
113
-    * 
114
-    * NOTE: Included extensions take precedence before excluded
115
-    * extensions. If any excluded extensions are specified, they
116
-    * will be ignored.
117
-    * 
118
-    * @param string $extension Extension name, without dot (`php` for example).
119
-    * @return FileFinder
120
-    * @see FileFinder::includeExtensions()
121
-    */
110
+    /**
111
+     * Includes a single extension in the file search: only
112
+     * files with this extension will be used in the results.
113
+     * 
114
+     * NOTE: Included extensions take precedence before excluded
115
+     * extensions. If any excluded extensions are specified, they
116
+     * will be ignored.
117
+     * 
118
+     * @param string $extension Extension name, without dot (`php` for example).
119
+     * @return FileFinder
120
+     * @see FileFinder::includeExtensions()
121
+     */
122 122
     public function includeExtension(string $extension) : FileFinder
123 123
     {
124 124
         return $this->includeExtensions(array($extension));
125 125
     }
126 126
     
127
-   /**
128
-    * Includes several extensions in the file search: only
129
-    * files with these extensions wil be used in the results.
130
-    * 
131
-    * NOTE: Included extensions take precedence before excluded
132
-    * extensions. If any excluded extensions are specified, they
133
-    * will be ignored.
134
-    * 
135
-    * @param string[] $extensions Extension names, without dot (`php` for example).
136
-    * @return FileFinder
137
-    * @see FileFinder::includeExtension()
138
-    */
127
+    /**
128
+     * Includes several extensions in the file search: only
129
+     * files with these extensions wil be used in the results.
130
+     * 
131
+     * NOTE: Included extensions take precedence before excluded
132
+     * extensions. If any excluded extensions are specified, they
133
+     * will be ignored.
134
+     * 
135
+     * @param string[] $extensions Extension names, without dot (`php` for example).
136
+     * @return FileFinder
137
+     * @see FileFinder::includeExtension()
138
+     */
139 139
     public function includeExtensions(array $extensions) : FileFinder
140 140
     {
141 141
         $items = $this->getIncludeExtensions();
@@ -146,37 +146,37 @@  discard block
 block discarded – undo
146 146
         return $this;
147 147
     }
148 148
 
149
-   /**
150
-    * Retrieves a list of all extensions currently set as 
151
-    * excluded from the search.
152
-    * 
153
-    * @return string[]
154
-    */
149
+    /**
150
+     * Retrieves a list of all extensions currently set as 
151
+     * excluded from the search.
152
+     * 
153
+     * @return string[]
154
+     */
155 155
     public function getExcludeExtensions() : array
156 156
     {
157 157
         return $this->getArrayOption(self::OPTION_EXCLUDE_EXTENSIONS);
158 158
     }
159 159
     
160
-   /**
161
-    * Excludes a single extension from the search.
162
-    * 
163
-    * @param string $extension Extension name, without dot (`php` for example).
164
-    * @return FileFinder
165
-    * @see FileFinder::excludeExtensions()
166
-    */
160
+    /**
161
+     * Excludes a single extension from the search.
162
+     * 
163
+     * @param string $extension Extension name, without dot (`php` for example).
164
+     * @return FileFinder
165
+     * @see FileFinder::excludeExtensions()
166
+     */
167 167
     public function excludeExtension(string $extension) : FileFinder
168 168
     {
169 169
         return $this->excludeExtensions(array($extension));
170 170
     }
171 171
 
172
-   /**
173
-    * Add several extensions to the list of extensions to
174
-    * exclude from the file search.
175
-    *  
176
-    * @param string[] $extensions Extension names, without dot (`php` for example).
177
-    * @return FileFinder
178
-    * @see FileFinder::excludeExtension()
179
-    */
172
+    /**
173
+     * Add several extensions to the list of extensions to
174
+     * exclude from the file search.
175
+     *  
176
+     * @param string[] $extensions Extension names, without dot (`php` for example).
177
+     * @return FileFinder
178
+     * @see FileFinder::excludeExtension()
179
+     */
180 180
     public function excludeExtensions(array $extensions) : FileFinder
181 181
     {
182 182
         $items = $this->getExcludeExtensions();
@@ -187,52 +187,52 @@  discard block
 block discarded – undo
187 187
         return $this;
188 188
     }
189 189
     
190
-   /**
191
-    * In this mode, the entire path to the file will be stripped,
192
-    * leaving only the file name in the files list.
193
-    * 
194
-    * @return FileFinder
195
-    */
190
+    /**
191
+     * In this mode, the entire path to the file will be stripped,
192
+     * leaving only the file name in the files list.
193
+     * 
194
+     * @return FileFinder
195
+     */
196 196
     public function setPathmodeStrip() : FileFinder
197 197
     {
198 198
         return $this->setPathmode(self::PATH_MODE_STRIP);
199 199
     }
200 200
     
201
-   /**
202
-    * In this mode, only the path relative to the source folder
203
-    * will be included in the files list.
204
-    * 
205
-    * @return FileFinder
206
-    */
201
+    /**
202
+     * In this mode, only the path relative to the source folder
203
+     * will be included in the files list.
204
+     * 
205
+     * @return FileFinder
206
+     */
207 207
     public function setPathmodeRelative() : FileFinder
208 208
     {
209 209
         return $this->setPathmode(self::PATH_MODE_RELATIVE);
210 210
     }
211 211
     
212
-   /**
213
-    * In this mode, the full, absolute paths to the files will
214
-    * be included in the files list.
215
-    * 
216
-    * @return FileFinder
217
-    */
212
+    /**
213
+     * In this mode, the full, absolute paths to the files will
214
+     * be included in the files list.
215
+     * 
216
+     * @return FileFinder
217
+     */
218 218
     public function setPathmodeAbsolute() : FileFinder
219 219
     {
220 220
         return $this->setPathmode(self::PATH_MODE_ABSOLUTE);
221 221
     }
222 222
     
223
-   /**
224
-    * This sets a character or string to replace the slashes
225
-    * in the paths with. 
226
-    * 
227
-    * This is used for example in the `getPHPClassNames()` 
228
-    * method, to return files from subfolders as class names
229
-    * using the "_" character:
230
-    * 
231
-    * Subfolder/To/File.php => Subfolder_To_File.php
232
-    * 
233
-    * @param string $character
234
-    * @return FileFinder
235
-    */
223
+    /**
224
+     * This sets a character or string to replace the slashes
225
+     * in the paths with. 
226
+     * 
227
+     * This is used for example in the `getPHPClassNames()` 
228
+     * method, to return files from subfolders as class names
229
+     * using the "_" character:
230
+     * 
231
+     * Subfolder/To/File.php => Subfolder_To_File.php
232
+     * 
233
+     * @param string $character
234
+     * @return FileFinder
235
+     */
236 236
     public function setSlashReplacement(string $character) : FileFinder
237 237
     {
238 238
         return $this->setOption('slash-replacement', $character);
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
         return $this->setOption(self::OPTION_PATHMODE, $mode);
256 256
     }
257 257
     
258
-   /**
259
-    * Retrieves a list of all matching file names/paths,
260
-    * depending on the selected options.
261
-    * 
262
-    * @return string[]
263
-    */
258
+    /**
259
+     * Retrieves a list of all matching file names/paths,
260
+     * depending on the selected options.
261
+     * 
262
+     * @return string[]
263
+     */
264 264
     public function getAll() : array
265 265
     {
266 266
         $this->find((string)$this->path, true);
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
         return $this->found;
269 269
     }
270 270
     
271
-   /**
272
-    * Retrieves only PHP files. Can be combined with other
273
-    * options like enabling recursion into sub-folders.
274
-    * 
275
-    * @return string[]
276
-    */
271
+    /**
272
+     * Retrieves only PHP files. Can be combined with other
273
+     * options like enabling recursion into sub-folders.
274
+     * 
275
+     * @return string[]
276
+     */
277 277
     public function getPHPFiles() : array
278 278
     {
279 279
         $this->includeExtensions(array('php'));
280 280
         return $this->getAll();
281 281
     }
282 282
     
283
-   /**
284
-    * Generates PHP class names from file paths: it replaces
285
-    * slashes with underscores, and removes file extensions.
286
-    * 
287
-    * @return string[] An array of PHP file names without extension.
288
-    */
283
+    /**
284
+     * Generates PHP class names from file paths: it replaces
285
+     * slashes with underscores, and removes file extensions.
286
+     * 
287
+     * @return string[] An array of PHP file names without extension.
288
+     */
289 289
     public function getPHPClassNames() : array
290 290
     {
291 291
         $this->includeExtensions(array('php'));
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
         return $path;
357 357
     }
358 358
     
359
-   /**
360
-    * Checks whether the specified extension is allowed 
361
-    * with the current settings.
362
-    * 
363
-    * @param string $extension
364
-    * @return bool
365
-    */
359
+    /**
360
+     * Checks whether the specified extension is allowed 
361
+     * with the current settings.
362
+     * 
363
+     * @param string $extension
364
+     * @return bool
365
+     */
366 366
     protected function filterExclusion(string $extension) : bool
367 367
     {
368 368
         $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS);
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
         return true;
383 383
     }
384 384
     
385
-   /**
386
-    * Adjusts the path according to the selected path mode.
387
-    * 
388
-    * @param string $path
389
-    * @return string
390
-    */
385
+    /**
386
+     * Adjusts the path according to the selected path mode.
387
+     * 
388
+     * @param string $path
389
+     * @return string
390
+     */
391 391
     protected function filterPath(string $path) : string
392 392
     {
393 393
         switch($this->getStringOption(self::OPTION_PATHMODE))
Please login to merge, or discard this patch.
src/Request/RequestParam.php 2 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
         return $this->applyValidations($value);
178 178
     }
179 179
     
180
-   /**
181
-    * Runs the value through all validations that were added.
182
-    * 
183
-    * @param mixed $value
184
-    * @return mixed
185
-    */
180
+    /**
181
+     * Runs the value through all validations that were added.
182
+     * 
183
+     * @param mixed $value
184
+     * @return mixed
185
+     */
186 186
     protected function applyValidations($value, bool $subval=false)
187 187
     {
188 188
         // go through all enqueued validations in turn, each time
@@ -195,17 +195,17 @@  discard block
 block discarded – undo
195 195
         return $value;
196 196
     }
197 197
     
198
-   /**
199
-    * Validates the specified value using the validation type. Returns
200
-    * the validated value. 
201
-    * 
202
-    * @param mixed $value
203
-    * @param string $type
204
-    * @param array<string,mixed> $params
205
-    * @param bool $subval Whether this is a subvalue in a list
206
-    * @throws Request_Exception
207
-    * @return mixed
208
-    */
198
+    /**
199
+     * Validates the specified value using the validation type. Returns
200
+     * the validated value. 
201
+     * 
202
+     * @param mixed $value
203
+     * @param string $type
204
+     * @param array<string,mixed> $params
205
+     * @param bool $subval Whether this is a subvalue in a list
206
+     * @throws Request_Exception
207
+     * @return mixed
208
+     */
209 209
     protected function validateType($value, string $type, array $params, bool $subval)
210 210
     {
211 211
         $class = Request_Param_Validator::class.'_'.ucfirst($type);
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
         return $this->setValidation(self::VALIDATION_TYPE_URL);
271 271
     }
272 272
     
273
-   /**
274
-    * Sets the variable to contain a comma-separated list of integer IDs.
275
-    * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
276
-    * <code>145</code>.
277
-    * 
278
-    * @return $this
279
-    */
273
+    /**
274
+     * Sets the variable to contain a comma-separated list of integer IDs.
275
+     * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
276
+     * <code>145</code>.
277
+     * 
278
+     * @return $this
279
+     */
280 280
     public function setIDList() : self
281 281
     {
282 282
         $this->valueType = self::VALUE_TYPE_LIST;
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
         return $this;
287 287
     }
288 288
     
289
-   /**
290
-    * Sets the variable to be an alias, as defined by the
291
-    * {@link RegexHelper::REGEX_ALIAS} regular expression.
292
-    * 
293
-    * @return $this
294
-    * @see RegexHelper::REGEX_ALIAS
295
-    */
289
+    /**
290
+     * Sets the variable to be an alias, as defined by the
291
+     * {@link RegexHelper::REGEX_ALIAS} regular expression.
292
+     * 
293
+     * @return $this
294
+     * @see RegexHelper::REGEX_ALIAS
295
+     */
296 296
     public function setAlias() : self
297 297
     {
298 298
         return $this->setRegex(RegexHelper::REGEX_ALIAS);
@@ -333,12 +333,12 @@  discard block
 block discarded – undo
333 333
         return $this->setValidation(self::VALIDATION_TYPE_ALPHA);
334 334
     }
335 335
     
336
-   /**
337
-    * Sets the parameter value as a string containing lowercase
338
-    * and/or uppercase letters, as well as numbers.
339
-    * 
340
-    * @return $this
341
-    */
336
+    /**
337
+     * Sets the parameter value as a string containing lowercase
338
+     * and/or uppercase letters, as well as numbers.
339
+     * 
340
+     * @return $this
341
+     */
342 342
     public function setAlnum() : self
343 343
     {
344 344
         return $this->setValidation(self::VALIDATION_TYPE_ALNUM);   
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
         );
397 397
     }
398 398
     
399
-   /**
400
-    * Whether the parameter is a list of values.
401
-    * 
402
-    * @return bool
403
-    */
399
+    /**
400
+     * Whether the parameter is a list of values.
401
+     * 
402
+     * @return bool
403
+     */
404 404
     public function isList() : bool
405 405
     {
406 406
         return $this->valueType === self::VALUE_TYPE_LIST;
@@ -442,28 +442,28 @@  discard block
 block discarded – undo
442 442
         return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false));
443 443
     }
444 444
     
445
-   /**
446
-    * The parameter is a string boolean representation. This means
447
-    * it can be any of the following: "yes", "true", "no", "false".
448
-    * The value is automatically converted to a boolean when retrieving
449
-    * the parameter.
450
-    * 
451
-    * @return $this
452
-    */
445
+    /**
446
+     * The parameter is a string boolean representation. This means
447
+     * it can be any of the following: "yes", "true", "no", "false".
448
+     * The value is automatically converted to a boolean when retrieving
449
+     * the parameter.
450
+     * 
451
+     * @return $this
452
+     */
453 453
     public function setBoolean() : self
454 454
     {
455 455
         return $this->addClassFilter('Boolean');
456 456
     }
457 457
     
458
-   /**
459
-    * Validates the request parameter as an MD5 string,
460
-    * so that only values resembling md5 values are accepted.
461
-    * 
462
-    * NOTE: This can only guarantee the format, not whether
463
-    * it is an actual valid hash of something.
464
-    * 
465
-    * @return $this
466
-    */
458
+    /**
459
+     * Validates the request parameter as an MD5 string,
460
+     * so that only values resembling md5 values are accepted.
461
+     * 
462
+     * NOTE: This can only guarantee the format, not whether
463
+     * it is an actual valid hash of something.
464
+     * 
465
+     * @return $this
466
+     */
467 467
     public function setMD5() : self
468 468
     {
469 469
         return $this->setRegex(RegexHelper::REGEX_MD5);
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
         return $this;
504 504
     }
505 505
     
506
-   /**
507
-    * Retrieves the value of the request parameter,
508
-    * applying all filters (if any) and validation
509
-    * (if any).
510
-    * 
511
-    * @param mixed $default
512
-    * @return mixed
513
-    */
506
+    /**
507
+     * Retrieves the value of the request parameter,
508
+     * applying all filters (if any) and validation
509
+     * (if any).
510
+     * 
511
+     * @param mixed $default
512
+     * @return mixed
513
+     */
514 514
     public function get($default=null)
515 515
     {
516 516
         $value = $this->request->getParam($this->paramName);
@@ -523,17 +523,17 @@  discard block
 block discarded – undo
523 523
 
524 524
     // region: Filtering
525 525
 
526
-   /**
527
-    * Filters the specified value by going through all available
528
-    * filters, if any. If none have been set, the value is simply
529
-    * passed through.
530
-    *
531
-    * @param mixed $value
532
-    * @return mixed
533
-    *
534
-    * @see RequestParam::applyFilter_callback()
535
-    * @see RequestParam::applyFilter_class()
536
-    */
526
+    /**
527
+     * Filters the specified value by going through all available
528
+     * filters, if any. If none have been set, the value is simply
529
+     * passed through.
530
+     *
531
+     * @param mixed $value
532
+     * @return mixed
533
+     *
534
+     * @see RequestParam::applyFilter_callback()
535
+     * @see RequestParam::applyFilter_class()
536
+     */
537 537
     protected function filter($value)
538 538
     {
539 539
         foreach ($this->filters as $filter)
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
         return $this;
623 623
     }
624 624
     
625
-   /**
626
-    * Adds a filter that trims whitespace from the request
627
-    * parameter using the PHP <code>trim</code> function.
628
-    * 
629
-    * @return $this
630
-    */
625
+    /**
626
+     * Adds a filter that trims whitespace from the request
627
+     * parameter using the PHP <code>trim</code> function.
628
+     * 
629
+     * @return $this
630
+     */
631 631
     public function addFilterTrim() : self
632 632
     {
633 633
         // to guarantee we only work with strings
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
         return $this->addCallbackFilter('trim');
637 637
     }
638 638
 
639
-   /**
640
-    * Converts the value to a string, even if it is not
641
-    * a string value. Complex types like arrays and objects
642
-    * are converted to an empty string.
643
-    * 
644
-    * @return $this
645
-    */
639
+    /**
640
+     * Converts the value to a string, even if it is not
641
+     * a string value. Complex types like arrays and objects
642
+     * are converted to an empty string.
643
+     * 
644
+     * @return $this
645
+     */
646 646
     public function addStringFilter() : self
647 647
     {
648 648
         return $this->addClassFilter('String');
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
         return $this->addCallbackFilter('strip_tags', array($allowedTags));
695 695
     }
696 696
     
697
-   /**
698
-    * Adds a filter that strips all whitespace from the
699
-    * request parameter, from spaces to tabs and newlines.
700
-    * 
701
-    * @return $this
702
-    */
697
+    /**
698
+     * Adds a filter that strips all whitespace from the
699
+     * request parameter, from spaces to tabs and newlines.
700
+     * 
701
+     * @return $this
702
+     */
703 703
     public function addStripWhitespaceFilter() : self
704 704
     {
705 705
         // to ensure we only work with strings.
@@ -708,14 +708,14 @@  discard block
 block discarded – undo
708 708
         return $this->addClassFilter('StripWhitespace');
709 709
     }   
710 710
     
711
-   /**
712
-    * Adds a filter that transforms comma separated values
713
-    * into an array of values.
714
-    * 
715
-    * @param bool $trimEntries Trim whitespace from each entry?
716
-    * @param bool $stripEmptyEntries Remove empty entries from the array?
717
-    * @return $this
718
-    */
711
+    /**
712
+     * Adds a filter that transforms comma separated values
713
+     * into an array of values.
714
+     * 
715
+     * @param bool $trimEntries Trim whitespace from each entry?
716
+     * @param bool $stripEmptyEntries Remove empty entries from the array?
717
+     * @return $this
718
+     */
719 719
     public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self
720 720
     {
721 721
         $this->setArray();
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
         );
747 747
     }
748 748
     
749
-   /**
750
-    * Adds a filter that encodes all HTML special characters
751
-    * using the PHP <code>htmlspecialchars</code> function.
752
-    * 
753
-    * @return $this
754
-    */
749
+    /**
750
+     * Adds a filter that encodes all HTML special characters
751
+     * using the PHP <code>htmlspecialchars</code> function.
752
+     * 
753
+     * @return $this
754
+     */
755 755
     public function addHTMLSpecialcharsFilter() : self
756 756
     {
757 757
         return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8'));
@@ -764,14 +764,14 @@  discard block
 block discarded – undo
764 764
         return $this->paramName;
765 765
     }
766 766
     
767
-   /**
768
-    * Marks this request parameter as required. To use this feature,
769
-    * you have to call the request's {@link Request::validate()}
770
-    * method.
771
-    * 
772
-    * @return RequestParam
773
-    * @see Request::validate()
774
-    */
767
+    /**
768
+     * Marks this request parameter as required. To use this feature,
769
+     * you have to call the request's {@link Request::validate()}
770
+     * method.
771
+     * 
772
+     * @return RequestParam
773
+     * @see Request::validate()
774
+     */
775 775
     public function makeRequired() : RequestParam
776 776
     {
777 777
         $this->required = true;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @return $this
125 125
      * @throws Request_Exception
126 126
      */
127
-    public function setCallback(callable $callback, array $args=array()) : self
127
+    public function setCallback(callable $callback, array $args = array()) : self
128 128
     {
129 129
         return $this->setValidation(
130 130
             self::VALIDATION_TYPE_CALLBACK, 
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
         // first off, apply filtering
150 150
         $value = $this->filter($value);
151 151
         
152
-        if($this->valueType === self::VALUE_TYPE_LIST)
152
+        if ($this->valueType === self::VALUE_TYPE_LIST)
153 153
         {
154
-            if(!is_array($value))
154
+            if (!is_array($value))
155 155
             {
156 156
                 $value = explode(',', $value);
157 157
             }
158 158
             
159 159
             $keep = array();
160 160
             
161
-            foreach($value as $subval)
161
+            foreach ($value as $subval)
162 162
             {
163 163
                 $subval = $this->filter($subval);
164 164
                 
165 165
                 $subval = $this->applyValidations($subval, true);
166 166
 
167
-                if($subval !== null) {
167
+                if ($subval !== null) {
168 168
                     $keep[] = $subval;
169 169
                 }
170 170
             }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
     * @param mixed $value
184 184
     * @return mixed
185 185
     */
186
-    protected function applyValidations($value, bool $subval=false)
186
+    protected function applyValidations($value, bool $subval = false)
187 187
     {
188 188
         // go through all enqueued validations in turn, each time
189 189
         // replacing the value with the adjusted, validated value.
190
-        foreach($this->validations as $validateDef)
190
+        foreach ($this->validations as $validateDef)
191 191
         {
192 192
             $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval);
193 193
         }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     {
211 211
         $class = Request_Param_Validator::class.'_'.ucfirst($type);
212 212
         
213
-        if(!class_exists($class))
213
+        if (!class_exists($class))
214 214
         {
215 215
             throw new Request_Exception(
216 216
                 'Unknown validation type.',
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     {
362 362
         $args = func_get_args(); // cannot be used as function parameter in some PHP versions
363 363
         
364
-        if(is_array($args[0])) 
364
+        if (is_array($args[0])) 
365 365
         {
366 366
             $args = $args[0];
367 367
         }
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
     * @param mixed $default
512 512
     * @return mixed
513 513
     */
514
-    public function get($default=null)
514
+    public function get($default = null)
515 515
     {
516 516
         $value = $this->request->getParam($this->paramName);
517
-        if($value !== null && $value !== '') {
517
+        if ($value !== null && $value !== '') {
518 518
             return $value;
519 519
         }
520 520
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     {
539 539
         foreach ($this->filters as $filter)
540 540
         {
541
-            $method = 'applyFilter_' . $filter['type'];
541
+            $method = 'applyFilter_'.$filter['type'];
542 542
             $value = $this->$method($value, $filter['params']);
543 543
         }
544 544
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         
558 558
         $filter = new $class($this);
559 559
 
560
-        if($filter instanceof Request_Param_Filter)
560
+        if ($filter instanceof Request_Param_Filter)
561 561
         {
562 562
             $filter->setOptions($config['params']);
563 563
             return $filter->filter($value);
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
     * @param bool $stripEmptyEntries Remove empty entries from the array?
717 717
     * @return $this
718 718
     */
719
-    public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self
719
+    public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : self
720 720
     {
721 721
         $this->setArray();
722 722
         
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      * @return $this
736 736
      * @throws Request_Exception
737 737
      */
738
-    protected function addClassFilter(string $name, array $params=array()) : self
738
+    protected function addClassFilter(string $name, array $params = array()) : self
739 739
     {
740 740
         return $this->addFilter(
741 741
             self::FILTER_TYPE_CLASS,
Please login to merge, or discard this patch.
src/Request.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
         $this->init();
57 57
     }
58 58
     
59
-   /**
60
-    * Can be extended in a subclass, to avoid
61
-    * redefining the constructor.
62
-    *
63
-    * @return void
64
-    */
59
+    /**
60
+     * Can be extended in a subclass, to avoid
61
+     * redefining the constructor.
62
+     *
63
+     * @return void
64
+     */
65 65
     protected function init() : void
66 66
     {
67 67
         
@@ -126,30 +126,30 @@  discard block
 block discarded – undo
126 126
         return $this->buildURL($params, $dispatcher);
127 127
     }
128 128
     
129
-   /**
130
-    * Retrieves the name of the current dispatcher script / page.
131
-    * This is made to be extended and implemented in a subclass.
132
-    * 
133
-    * @return string
134
-    */
129
+    /**
130
+     * Retrieves the name of the current dispatcher script / page.
131
+     * This is made to be extended and implemented in a subclass.
132
+     * 
133
+     * @return string
134
+     */
135 135
     public function getDispatcher() : string
136 136
     {
137 137
         return '';
138 138
     }
139 139
     
140
-   /**
141
-    * Filters and retrieves the current request variables 
142
-    * to be used to build a URL to refresh the current page.
143
-    * 
144
-    * For further customization options, use the 
145
-    * {@see Request::createRefreshParams()} method.
146
-    * 
147
-    * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
-    * @param string[] $exclude Names of parameters to exclude from the result.
149
-    * @return array<string,mixed>
150
-    * 
151
-    * @see Request::createRefreshParams()
152
-    */
140
+    /**
141
+     * Filters and retrieves the current request variables 
142
+     * to be used to build a URL to refresh the current page.
143
+     * 
144
+     * For further customization options, use the 
145
+     * {@see Request::createRefreshParams()} method.
146
+     * 
147
+     * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
+     * @param string[] $exclude Names of parameters to exclude from the result.
149
+     * @return array<string,mixed>
150
+     * 
151
+     * @see Request::createRefreshParams()
152
+     */
153 153
     public function getRefreshParams(array $params = array(), array $exclude = array()) : array
154 154
     {
155 155
         return $this->createRefreshParams()
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
             ->getParams();
159 159
     }
160 160
     
161
-   /**
162
-    * Creates an instance of the helper that can be used to
163
-    * retrieve the request's parameters collection, with the
164
-    * possibility to exclude and override some by rules.
165
-    * 
166
-    * @return Request_RefreshParams
167
-    */
161
+    /**
162
+     * Creates an instance of the helper that can be used to
163
+     * retrieve the request's parameters collection, with the
164
+     * possibility to exclude and override some by rules.
165
+     * 
166
+     * @return Request_RefreshParams
167
+     */
168 168
     public function createRefreshParams() : Request_RefreshParams
169 169
     {
170 170
         return new Request_RefreshParams();
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
         return $url;
201 201
     }
202 202
     
203
-   /**
204
-    * Retrieves the base URL of the application.
205
-    * @return string
206
-    */
203
+    /**
204
+     * Retrieves the base URL of the application.
205
+     * @return string
206
+     */
207 207
     public function getBaseURL() : string
208 208
     {
209 209
         return $this->baseURL;
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
         return $this->knownParams[$name];
234 234
     }
235 235
     
236
-   /**
237
-    * Retrieves a previously registered parameter instance.
238
-    * 
239
-    * @param string $name
240
-    * @return RequestParam
241
-    *@throws Request_Exception
242
-    */
236
+    /**
237
+     * Retrieves a previously registered parameter instance.
238
+     * 
239
+     * @param string $name
240
+     * @return RequestParam
241
+     *@throws Request_Exception
242
+     */
243 243
     public function getRegisteredParam(string $name) : RequestParam
244 244
     {
245 245
         if(isset($this->knownParams[$name])) {
@@ -256,48 +256,48 @@  discard block
 block discarded – undo
256 256
         );
257 257
     }
258 258
     
259
-   /**
260
-    * Checks whether a parameter with the specified name 
261
-    * has been registered.
262
-    * 
263
-    * @param string $name
264
-    * @return bool
265
-    */
259
+    /**
260
+     * Checks whether a parameter with the specified name 
261
+     * has been registered.
262
+     * 
263
+     * @param string $name
264
+     * @return bool
265
+     */
266 266
     public function hasRegisteredParam(string $name) : bool
267 267
     {
268 268
         return isset($this->knownParams[$name]);
269 269
     }
270 270
     
271
-   /**
272
-    * Retrieves an indexed array with accept mime types
273
-    * that the client sent, in the order of preference
274
-    * the client specified.
275
-    *
276
-    * Example:
277
-    *
278
-    * array(
279
-    *     'text/html',
280
-    *     'application/xhtml+xml',
281
-    *     'image/webp'
282
-    *     ...
283
-    * )
284
-    * 
285
-    * @return string[]
286
-    * @see Request::parseAcceptHeaders()
287
-    */
271
+    /**
272
+     * Retrieves an indexed array with accept mime types
273
+     * that the client sent, in the order of preference
274
+     * the client specified.
275
+     *
276
+     * Example:
277
+     *
278
+     * array(
279
+     *     'text/html',
280
+     *     'application/xhtml+xml',
281
+     *     'image/webp'
282
+     *     ...
283
+     * )
284
+     * 
285
+     * @return string[]
286
+     * @see Request::parseAcceptHeaders()
287
+     */
288 288
     public static function getAcceptHeaders() : array
289 289
     {
290 290
         return self::parseAcceptHeaders()->getMimeStrings();
291 291
     }
292 292
     
293
-   /**
294
-    * Returns an instance of the "accept" headers parser,
295
-    * to access information on the browser's accepted
296
-    * mime types.
297
-    *  
298
-    * @return Request_AcceptHeaders
299
-    * @see Request::getAcceptHeaders()
300
-    */
293
+    /**
294
+     * Returns an instance of the "accept" headers parser,
295
+     * to access information on the browser's accepted
296
+     * mime types.
297
+     *  
298
+     * @return Request_AcceptHeaders
299
+     * @see Request::getAcceptHeaders()
300
+     */
301 301
     public static function parseAcceptHeaders() : Request_AcceptHeaders
302 302
     {
303 303
         static $accept;
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
         return $this->getParam($name) !== null;
342 342
     }
343 343
     
344
-   /**
345
-    * Removes a single parameter from the request.
346
-    * If the parameter has been registered, also
347
-    * removes the registration info.
348
-    * 
349
-    * @param string $name
350
-    * @return Request
351
-    */
344
+    /**
345
+     * Removes a single parameter from the request.
346
+     * If the parameter has been registered, also
347
+     * removes the registration info.
348
+     * 
349
+     * @param string $name
350
+     * @return Request
351
+     */
352 352
     public function removeParam(string $name) : Request
353 353
     {
354 354
         if(isset($_REQUEST[$name])) {
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
         return $this;
363 363
     }
364 364
     
365
-   /**
366
-    * Removes several parameters from the request.
367
-    * 
368
-    * @param string[] $names
369
-    * @return Request
370
-    */
365
+    /**
366
+     * Removes several parameters from the request.
367
+     * 
368
+     * @param string[] $names
369
+     * @return Request
370
+     */
371 371
     public function removeParams(array $names) : Request
372 372
     {
373 373
         foreach($names as $name) {
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
         exit;
564 564
     }
565 565
     
566
-   /**
567
-    * Sends HTML to the browser with the correct headers.
568
-    * 
569
-    * @param string $html
570
-    */
566
+    /**
567
+     * Sends HTML to the browser with the correct headers.
568
+     * 
569
+     * @param string $html
570
+     */
571 571
     public static function sendHTML(string $html) : void
572 572
     {
573 573
         header('Cache-Control: no-cache, must-revalidate');
@@ -588,16 +588,16 @@  discard block
 block discarded – undo
588 588
         exit;
589 589
     }
590 590
     
591
-   /**
592
-    * Creates a new instance of the URL comparer, which can check 
593
-    * whether the specified URLs match, regardless of the order in 
594
-    * which the query parameters are, if any.
595
-    * 
596
-    * @param string $sourceURL
597
-    * @param string $targetURL
598
-    * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present)
599
-    * @return Request_URLComparer
600
-    */
591
+    /**
592
+     * Creates a new instance of the URL comparer, which can check 
593
+     * whether the specified URLs match, regardless of the order in 
594
+     * which the query parameters are, if any.
595
+     * 
596
+     * @param string $sourceURL
597
+     * @param string $targetURL
598
+     * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present)
599
+     * @return Request_URLComparer
600
+     */
601 601
     public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
602 602
     {
603 603
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
@@ -606,10 +606,10 @@  discard block
 block discarded – undo
606 606
         return $comparer;
607 607
     }
608 608
     
609
-   /**
610
-    * Retrieves the full URL that was used to access the current page.
611
-    * @return string
612
-    */
609
+    /**
610
+     * Retrieves the full URL that was used to access the current page.
611
+     * @return string
612
+     */
613 613
     public function getCurrentURL() : string
614 614
     {
615 615
         return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $value = $_REQUEST[$name] ?? $default;
95 95
 
96
-        if(isset($this->knownParams[$name])) {
96
+        if (isset($this->knownParams[$name])) {
97 97
             $value = $this->knownParams[$name]->validate($value);
98 98
         }
99 99
         
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
191 191
      * @return string
192 192
      */
193
-    public function buildURL(array $params = array(), string $dispatcher='') : string
193
+    public function buildURL(array $params = array(), string $dispatcher = '') : string
194 194
     {
195
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
195
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
196 196
         
197 197
         // append any leftover parameters to the end of the URL
198 198
         if (!empty($params)) {
199
-            $url .= '?' . http_build_query($params, '', '&amp;');
199
+            $url .= '?'.http_build_query($params, '', '&amp;');
200 200
         }
201 201
         
202 202
         return $url;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function registerParam(string $name) : RequestParam
229 229
     {
230
-        if(!isset($this->knownParams[$name])) {
230
+        if (!isset($this->knownParams[$name])) {
231 231
             $param = new RequestParam($this, $name);
232 232
             $this->knownParams[$name] = $param;
233 233
         }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     */
245 245
     public function getRegisteredParam(string $name) : RequestParam
246 246
     {
247
-        if(isset($this->knownParams[$name])) {
247
+        if (isset($this->knownParams[$name])) {
248 248
             return $this->knownParams[$name];
249 249
         }
250 250
         
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     {
305 305
         static $accept;
306 306
         
307
-        if(!isset($accept)) {
307
+        if (!isset($accept)) {
308 308
             $accept = new Request_AcceptHeaders();
309 309
         }
310 310
         
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     {
324 324
         $_REQUEST[$name] = $value;
325 325
         
326
-        if(isset($this->knownParams[$name])) {
326
+        if (isset($this->knownParams[$name])) {
327 327
             unset($this->knownParams[$name]);
328 328
         }
329 329
         
@@ -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
         
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
      * @return bool
391 391
      * @throws ConvertHelper_Exception
392 392
      */
393
-    public function getBool(string $name, bool $default=false) : bool
393
+    public function getBool(string $name, bool $default = false) : bool
394 394
     {
395 395
         $value = $this->getParam($name, $default);
396 396
 
397
-        if(ConvertHelper::isBoolean($value)) {
397
+        if (ConvertHelper::isBoolean($value)) {
398 398
             return ConvertHelper::string2bool($value);
399 399
         }
400 400
         
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
     
404 404
     public function validate() : void
405 405
     {
406
-        foreach($this->knownParams as $param) 
406
+        foreach ($this->knownParams as $param) 
407 407
         {
408 408
             $name = $param->getName();
409 409
             
410
-            if($param->isRequired() && !$this->hasParam($name)) 
410
+            if ($param->isRequired() && !$this->hasParam($name)) 
411 411
             {
412 412
                 throw new Request_Exception(
413 413
                     'Missing request parameter '.$name,
@@ -429,26 +429,26 @@  discard block
 block discarded – undo
429 429
      * @param mixed $default
430 430
      * @return mixed
431 431
      */
432
-    public function getFilteredParam(string $name, $default=null)
432
+    public function getFilteredParam(string $name, $default = null)
433 433
     {
434 434
         $val = $this->getParam($name, $default);
435 435
 
436
-        if(is_string($val))
436
+        if (is_string($val))
437 437
         {
438 438
             return htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
439 439
         }
440 440
 
441
-        if(is_bool($val))
441
+        if (is_bool($val))
442 442
         {
443 443
             return ConvertHelper::boolStrict2string($val);
444 444
         }
445 445
 
446
-        if(is_numeric($val))
446
+        if (is_numeric($val))
447 447
         {
448 448
             return (string)$val;
449 449
         }
450 450
 
451
-        if(is_null($val))
451
+        if (is_null($val))
452 452
         {
453 453
             return '';
454 454
         }
@@ -468,24 +468,24 @@  discard block
 block discarded – undo
468 468
      * @see Request::getJSONObject()
469 469
      * @see Request::getJSONAssoc()
470 470
      */
471
-    public function getJSON(string $name, bool $assoc=true)
471
+    public function getJSON(string $name, bool $assoc = true)
472 472
     {
473 473
         $value = $this->getParam($name);
474 474
         
475
-        if(!empty($value) && is_string($value)) 
475
+        if (!empty($value) && is_string($value)) 
476 476
         {
477 477
             $value = JSONConverter::json2varSilent($value, $assoc);
478 478
 
479
-            if($assoc && is_array($value)) {
479
+            if ($assoc && is_array($value)) {
480 480
                 return $value;
481 481
             }
482 482
             
483
-            if(is_object($value)) {
483
+            if (is_object($value)) {
484 484
                 return $value;
485 485
             }
486 486
         }
487 487
         
488
-        if($assoc) {
488
+        if ($assoc) {
489 489
             return array();
490 490
         }
491 491
         
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     public function getJSONAssoc(string $name) : array
503 503
     {
504 504
         $result = $this->getJSON($name);
505
-        if(is_array($result)) {
505
+        if (is_array($result)) {
506 506
             return $result;
507 507
         }
508 508
         
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
     public function getJSONObject(string $name) : object
520 520
     {
521 521
         $result = $this->getJSON($name, false);
522
-        if(is_object($result)) {
522
+        if (is_object($result)) {
523 523
             return $result;
524 524
         }
525 525
         
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     {
537 537
         $payload = $data;
538 538
 
539
-        if(!is_string($payload)) {
539
+        if (!is_string($payload)) {
540 540
             $payload = JSONConverter::var2json($payload);
541 541
         }
542 542
         
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present)
594 594
     * @return Request_URLComparer
595 595
     */
596
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
596
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
597 597
     {
598 598
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
599 599
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/FileHelper/FolderTree.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $info = FileHelper::getFolderInfo($rootFolder);
24 24
 
25
-        if(!$info->exists())
25
+        if (!$info->exists())
26 26
         {
27 27
             return true;
28 28
         }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
         foreach ($d as $item)
33 33
         {
34
-            if(self::processDeleteItem($item) === false)
34
+            if (self::processDeleteItem($item) === false)
35 35
             {
36 36
                 return false;
37 37
             }
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $target = FileHelper::createFolder($target);
102 102
 
103
-        $d =  FileHelper::getPathInfo($source)->requireIsFolder()->getIterator();
103
+        $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator();
104 104
 
105 105
         foreach ($d as $item)
106 106
         {
107
-            if($item->isDot())
107
+            if ($item->isDot())
108 108
             {
109 109
                 continue;
110 110
             }
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
         if ($item->isFolder())
127 127
         {
128
-            self::copy($item, $target . '/' . $item->getName());
128
+            self::copy($item, $target.'/'.$item->getName());
129 129
         }
130
-        else if($item->isFile())
130
+        else if ($item->isFile())
131 131
         {
132 132
             $item
133 133
                 ->requireIsFile()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@  discard block
 block discarded – undo
42 42
         {
43 43
             $info->delete();
44 44
             return true;
45
-        }
46
-        catch (FileHelper_Exception $e)
45
+        } catch (FileHelper_Exception $e)
47 46
         {
48 47
             // Ignore the exception, since we're returning false instead.
49 48
         }
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
             try
79 78
             {
80 79
                 FileHelper::deleteFile($item);
81
-            }
82
-            catch (FileHelper_Exception $e)
80
+            } catch (FileHelper_Exception $e)
83 81
             {
84 82
                 return false;
85 83
             }
@@ -125,8 +123,7 @@  discard block
 block discarded – undo
125 123
         if ($item->isFolder())
126 124
         {
127 125
             self::copy($item, $target . '/' . $item->getName());
128
-        }
129
-        else if($item->isFile())
126
+        } else if($item->isFile())
130 127
         {
131 128
             $item
132 129
                 ->requireIsFile()
Please login to merge, or discard this patch.
src/ConvertHelper/Bool.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function fromString($string) : bool
31 31
     {
32
-        if($string === '' || !is_scalar($string))
32
+        if ($string === '' || !is_scalar($string))
33 33
         {
34 34
             return false;
35 35
         }
36 36
 
37
-        if(is_bool($string))
37
+        if (is_bool($string))
38 38
         {
39 39
             return $string;
40 40
         }
41 41
 
42
-        if(is_string($string))
42
+        if (is_string($string))
43 43
         {
44 44
             $string = strtolower($string);
45 45
         }
46 46
 
47
-        if(array_key_exists($string, self::$booleanStrings))
47
+        if (array_key_exists($string, self::$booleanStrings))
48 48
         {
49 49
             return self::$booleanStrings[$string];
50 50
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     public static function toString($boolean, bool $yesno = false) : string
75 75
     {
76 76
         // allow 'yes', 'true', 'no', 'false' string notations as well
77
-        if(!is_bool($boolean)) {
77
+        if (!is_bool($boolean)) {
78 78
             $boolean = self::fromString($boolean);
79 79
         }
80 80
 
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public static function isBoolean($value) : bool
132 132
     {
133
-        if(is_bool($value)) {
133
+        if (is_bool($value)) {
134 134
             return true;
135 135
         }
136 136
 
137
-        if(!is_scalar($value)) {
137
+        if (!is_scalar($value)) {
138 138
             return false;
139 139
         }
140 140
 
Please login to merge, or discard this patch.
src/LipsumHelper/LipsumDetector.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public function setMinWords(int $min) : self
123 123
     {
124 124
         // Avoid a reset if the value is the same
125
-        if($this->minWords === $min)
125
+        if ($this->minWords === $min)
126 126
         {
127 127
             return $this;
128 128
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
     private function detect() : void
144 144
     {
145
-        if($this->detected) {
145
+        if ($this->detected) {
146 146
             return;
147 147
         }
148 148
 
@@ -150,15 +150,15 @@  discard block
 block discarded – undo
150 150
         $this->found = array();
151 151
         $this->count = 0;
152 152
 
153
-        foreach(self::$words as $word)
153
+        foreach (self::$words as $word)
154 154
         {
155
-            if(stripos($this->subject, $word) !== false)
155
+            if (stripos($this->subject, $word) !== false)
156 156
             {
157 157
                 $this->count++;
158 158
                 $this->found[] = $word;
159 159
             }
160 160
 
161
-            if($this->count >= $this->minWords) {
161
+            if ($this->count >= $this->minWords) {
162 162
                 break;
163 163
             }
164 164
         }
Please login to merge, or discard this patch.
src/StyleCollection.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles
35 35
      */
36
-    public function __construct(array $styles=array())
36
+    public function __construct(array $styles = array())
37 37
     {
38 38
         $this->options = new StyleOptions();
39 39
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles
45 45
      * @return StyleCollection
46 46
      */
47
-    public static function create(array $styles=array()) : StyleCollection
47
+    public static function create(array $styles = array()) : StyleCollection
48 48
     {
49 49
         return new StyleCollection($styles);
50 50
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $lines = explode(';', $string);
70 70
 
71
-        foreach($lines as $line)
71
+        foreach ($lines as $line)
72 72
         {
73 73
             $parts = explode(':', $line);
74 74
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function setStyles(array $styles) : StyleCollection
91 91
     {
92
-        foreach($styles as $name => $value)
92
+        foreach ($styles as $name => $value)
93 93
         {
94 94
             $this->styleAuto($name, $value);
95 95
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
      * @param bool $important
106 106
      * @return $this
107 107
      */
108
-    public function style(string $name, string $value, bool $important=false) : StyleCollection
108
+    public function style(string $name, string $value, bool $important = false) : StyleCollection
109 109
     {
110
-        if($value === '')
110
+        if ($value === '')
111 111
         {
112 112
             return $this;
113 113
         }
114 114
 
115
-        if($important && stripos($value, '!important') === false)
115
+        if ($important && stripos($value, '!important') === false)
116 116
         {
117 117
             $value .= ' !important';
118 118
         }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
      * @param bool $important
131 131
      * @return $this
132 132
      */
133
-    public function styleAuto(string $name, $value, bool $important=false) : StyleCollection
133
+    public function styleAuto(string $name, $value, bool $important = false) : StyleCollection
134 134
     {
135
-        if($value instanceof NumberInfo)
135
+        if ($value instanceof NumberInfo)
136 136
         {
137 137
             return $this->style($name, $value->toCSS(), $important);
138 138
         }
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
         return $this->style($name, (string)$value, $important);
141 141
     }
142 142
 
143
-    public function stylePX(string $name, int $px, bool $important=false) : StyleCollection
143
+    public function stylePX(string $name, int $px, bool $important = false) : StyleCollection
144 144
     {
145 145
         return $this->style($name, $px.'px', $important);
146 146
     }
147 147
 
148
-    public function stylePercent(string $name, float $percent, bool $important=false) : StyleCollection
148
+    public function stylePercent(string $name, float $percent, bool $important = false) : StyleCollection
149 149
     {
150 150
         return $this->style($name, $percent.'%', $important);
151 151
     }
152 152
 
153
-    public function styleEM(string $name, float $em, bool $important=false) : StyleCollection
153
+    public function styleEM(string $name, float $em, bool $important = false) : StyleCollection
154 154
     {
155 155
         return $this->style($name, $em.'em', $important);
156 156
     }
157 157
 
158
-    public function styleREM(string $name, float $em, bool $important=false) : StyleCollection
158
+    public function styleREM(string $name, float $em, bool $important = false) : StyleCollection
159 159
     {
160 160
         return $this->style($name, $em.'rem', $important);
161 161
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param bool $important
170 170
      * @return $this
171 171
      */
172
-    public function styleParseNumber(string $name, $value, bool $important=false) : StyleCollection
172
+    public function styleParseNumber(string $name, $value, bool $important = false) : StyleCollection
173 173
     {
174 174
         return $this->styleNumber($name, parseNumber($value), $important);
175 175
     }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * @param bool $important
183 183
      * @return $this
184 184
      */
185
-    public function styleNumber(string $name, NumberInfo $info, bool $important=false) : StyleCollection
185
+    public function styleNumber(string $name, NumberInfo $info, bool $important = false) : StyleCollection
186 186
     {
187 187
         $this->style($name, $info->toCSS(), $important);
188 188
         return $this;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
     public function remove(string $name) : StyleCollection
192 192
     {
193
-        if(isset($this->styles[$name]))
193
+        if (isset($this->styles[$name]))
194 194
         {
195 195
             unset($this->styles[$name]);
196 196
         }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     {
227 227
         $all = self::create();
228 228
 
229
-        foreach($collections as $collection)
229
+        foreach ($collections as $collection)
230 230
         {
231 231
             $all->mergeWith($collection);
232 232
         }
Please login to merge, or discard this patch.
src/ClassHelper/ClassNotExistsException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 
23 23
     public function __construct(string $class, ?int $code = null, ?Throwable $previous = null)
24 24
     {
25
-        if($code === null || $code === 0) {
25
+        if ($code === null || $code === 0) {
26 26
             $code = self::ERROR_CODE;
27 27
         }
28 28
 
Please login to merge, or discard this patch.
src/FileHelper/PHPClassInfo.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
         self::TYPE_TRAIT
49 49
     );
50 50
 
51
-   /**
52
-    * @param PHPFile $path The path to the PHP file to parse.
53
-    * @throws FileHelper_Exception
54
-    * @see FileHelper::findPHPClasses()
55
-    */
51
+    /**
52
+     * @param PHPFile $path The path to the PHP file to parse.
53
+     * @throws FileHelper_Exception
54
+     * @see FileHelper::findPHPClasses()
55
+     */
56 56
     public function __construct(PHPFile $path)
57 57
     {
58 58
         $this->file = $path
@@ -62,58 +62,58 @@  discard block
 block discarded – undo
62 62
         $this->parseFile();
63 63
     }
64 64
     
65
-   /**
66
-    * The name of the namespace of the classes in the file, if any.
67
-    * @return string
68
-    */
65
+    /**
66
+     * The name of the namespace of the classes in the file, if any.
67
+     * @return string
68
+     */
69 69
     public function getNamespace() : string
70 70
     {
71 71
         return $this->namespace;
72 72
     }
73 73
     
74
-   /**
75
-    * Whether the file contains a namespace.
76
-    * @return bool
77
-    */
74
+    /**
75
+     * Whether the file contains a namespace.
76
+     * @return bool
77
+     */
78 78
     public function hasNamespace() : bool
79 79
     {
80 80
         return !empty($this->namespace);
81 81
     }
82 82
     
83
-   /**
84
-    * The absolute path to the file.
85
-    * @return string
86
-    */
83
+    /**
84
+     * The absolute path to the file.
85
+     * @return string
86
+     */
87 87
     public function getPath() : string
88 88
     {
89 89
         return $this->file->getPath();
90 90
     }
91 91
    
92
-   /**
93
-    * Whether any classes were found in the file.
94
-    * @return bool
95
-    */
92
+    /**
93
+     * Whether any classes were found in the file.
94
+     * @return bool
95
+     */
96 96
     public function hasClasses() : bool
97 97
     {
98 98
         return !empty($this->classes);
99 99
     }
100 100
     
101
-   /**
102
-    * The names of the classes that were found in the file (with namespace if any).
103
-    * @return string[]
104
-    */
101
+    /**
102
+     * The names of the classes that were found in the file (with namespace if any).
103
+     * @return string[]
104
+     */
105 105
     public function getClassNames() : array
106 106
     {
107 107
         return array_keys($this->classes);
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves all classes that were detected in the file,
112
-    * which can be used to retrieve more information about
113
-    * them.
114
-    * 
115
-    * @return FileHelper_PHPClassInfo_Class[]
116
-    */
110
+    /**
111
+     * Retrieves all classes that were detected in the file,
112
+     * which can be used to retrieve more information about
113
+     * them.
114
+     * 
115
+     * @return FileHelper_PHPClassInfo_Class[]
116
+     */
117 117
     public function getClasses() : array
118 118
     {
119 119
         return array_values($this->classes);
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
         $this->classes[$class->getNameNS()] = $class;
186 186
     }
187 187
 
188
-   /**
189
-    * Strips all whitespace from the string, replacing it with 
190
-    * regular spaces (newlines, tabs, etc.).
191
-    * 
192
-    * @param string $string
193
-    * @return string
194
-    */
188
+    /**
189
+     * Strips all whitespace from the string, replacing it with 
190
+     * regular spaces (newlines, tabs, etc.).
191
+     * 
192
+     * @param string $string
193
+     * @return string
194
+     */
195 195
     protected function stripWhitespace(string $string) : string 
196 196
     {
197 197
         return preg_replace('/\s/', ' ', $string);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
         $this->detectNamespace($code);
127 127
         $result = $this->detectMatches($code);
128 128
 
129
-        if($result === null) {
129
+        if ($result === null) {
130 130
             return;
131 131
         }
132 132
         
133 133
         $indexes = array_keys($result[0]);
134 134
         
135
-        foreach($indexes as $idx)
135
+        foreach ($indexes as $idx)
136 136
         {
137 137
             $this->parseResult(
138 138
                 $result[1][$idx],
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
         preg_match_all('/(abstract|final)\s+('.$types.')\s+([\sa-z\d\\\\_,]+){|('.$types.')\s+([\sa-z\d\\\\_,]+){/ix', $code, $result, PREG_PATTERN_ORDER);
153 153
 
154
-        if(isset($result[0][0])) {
154
+        if (isset($result[0][0])) {
155 155
             return $result;
156 156
         }
157 157
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
         $result = array();
164 164
         preg_match_all('/namespace\s+([^;]+);/ix', $code, $result, PREG_PATTERN_ORDER);
165 165
 
166
-        if(isset($result[0][0])) {
166
+        if (isset($result[0][0])) {
167 167
             $this->namespace = trim($result[1][0]);
168 168
         }
169 169
     }
170 170
 
171 171
     private function parseResult(string $keyword, string $declaration, string $type, string $simpleType, string $simpleDeclaration) : void
172 172
     {
173
-        if(empty($keyword)) {
173
+        if (empty($keyword)) {
174 174
             $type = $simpleType;
175 175
             $declaration = $simpleDeclaration;
176 176
         }
Please login to merge, or discard this patch.