Test Setup Failed
Branch master (43d553)
by Sebastian
02:42
created
src/Request/Param.php 3 patches
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
         }
115 115
     }
116 116
     
117
-   /**
118
-    * Adds a callback as a validation method. The callback gets the
119
-    * value to validate as first parameter, and any additional 
120
-    * parameters passed here get appended to that.
121
-    * 
122
-    * The callback must return boolean true or false depending on
123
-    * whether the value is valid.
124
-    * 
125
-    * @param callable $callback
126
-    * @param array $args
127
-    * @return Request_Param
128
-    */
117
+    /**
118
+     * Adds a callback as a validation method. The callback gets the
119
+     * value to validate as first parameter, and any additional 
120
+     * parameters passed here get appended to that.
121
+     * 
122
+     * The callback must return boolean true or false depending on
123
+     * whether the value is valid.
124
+     * 
125
+     * @param callable $callback
126
+     * @param array $args
127
+     * @return Request_Param
128
+     */
129 129
     public function setCallback($callback, array $args=array()) : Request_Param
130 130
     {
131 131
         if(!is_callable($callback)) {
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
         return $value;
170 170
     }
171 171
     
172
-   /**
173
-    * Validates the specified value using the validation type. Returns
174
-    * the validated value. 
175
-    * 
176
-    * @param mixed $value
177
-    * @param string $type
178
-    * @param array $params
179
-    * @throws Request_Exception
180
-    * @return mixed
181
-    */
172
+    /**
173
+     * Validates the specified value using the validation type. Returns
174
+     * the validated value. 
175
+     * 
176
+     * @param mixed $value
177
+     * @param string $type
178
+     * @param array $params
179
+     * @throws Request_Exception
180
+     * @return mixed
181
+     */
182 182
     protected function validateType($value, string $type, array $params)
183 183
     {
184 184
         $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type);
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
     
277 277
     protected $valueType = self::VALUE_TYPE_STRING;
278 278
 
279
-   /**
280
-    * Sets the variable to contain a comma-separated list of integer IDs.
281
-    * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
282
-    * <code>145</code>.
283
-    * 
284
-    * @return Request_Param
285
-    */
279
+    /**
280
+     * Sets the variable to contain a comma-separated list of integer IDs.
281
+     * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
282
+     * <code>145</code>.
283
+     * 
284
+     * @return Request_Param
285
+     */
286 286
     public function setIDList()
287 287
     {
288 288
         $this->valueType = self::VALUE_TYPE_ID_LIST;
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
         return $this;
292 292
     }
293 293
     
294
-   /**
295
-    * Sets the variable to be an alias, as defined by the
296
-    * {@link RegexHelper::REGEX_ALIAS} regular expression.
297
-    * 
298
-    * @return Request_Param
299
-    * @see RegexHelper::REGEX_ALIAS
300
-    */
294
+    /**
295
+     * Sets the variable to be an alias, as defined by the
296
+     * {@link RegexHelper::REGEX_ALIAS} regular expression.
297
+     * 
298
+     * @return Request_Param
299
+     * @see RegexHelper::REGEX_ALIAS
300
+     */
301 301
     public function setAlias()
302 302
     {
303 303
         return $this->setRegex(RegexHelper::REGEX_ALIAS);
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
         return $this->setValidation(self::VALIDATION_TYPE_ALPHA);
339 339
     }
340 340
     
341
-   /**
342
-    * Sets the parameter value as a string containing lowercase
343
-    * and/or uppercase letters, as well as numbers.
344
-    * 
345
-    * @return Request_Param
346
-    */
341
+    /**
342
+     * Sets the parameter value as a string containing lowercase
343
+     * and/or uppercase letters, as well as numbers.
344
+     * 
345
+     * @return Request_Param
346
+     */
347 347
     public function setAlnum()
348 348
     {
349 349
         return $this->setValidation(self::VALIDATION_TYPE_ALNUM);   
@@ -376,17 +376,17 @@  discard block
 block discarded – undo
376 376
         );
377 377
     }
378 378
     
379
-   /**
380
-    * Only available for array values: the parameter must be
381
-    * an array value, and the array may only contain values 
382
-    * specified in the values array.
383
-    * 
384
-    * Submitted values that are not in the allowed list of
385
-    * values are stripped from the value.
386
-    *  
387
-    * @param array $values List of allowed values
388
-    * @return \AppUtils\Request_Param
389
-    */
379
+    /**
380
+     * Only available for array values: the parameter must be
381
+     * an array value, and the array may only contain values 
382
+     * specified in the values array.
383
+     * 
384
+     * Submitted values that are not in the allowed list of
385
+     * values are stripped from the value.
386
+     *  
387
+     * @param array $values List of allowed values
388
+     * @return \AppUtils\Request_Param
389
+     */
390 390
     public function setValuesList(array $values)
391 391
     {
392 392
         $this->setArray();
@@ -404,53 +404,53 @@  discard block
 block discarded – undo
404 404
         return $this->setValidation(self::VALIDATION_TYPE_ARRAY);
405 405
     }
406 406
     
407
-   /**
408
-    * Specifies that a JSON-encoded string is expected.
409
-    * 
410
-    * NOTE: Numbers or quoted strings are technically valid
411
-    * JSON, but are not accepted, because it is assumed
412
-    * at least an array or object are expected.
413
-    * 
414
-    * @return \AppUtils\Request_Param
415
-    */
407
+    /**
408
+     * Specifies that a JSON-encoded string is expected.
409
+     * 
410
+     * NOTE: Numbers or quoted strings are technically valid
411
+     * JSON, but are not accepted, because it is assumed
412
+     * at least an array or object are expected.
413
+     * 
414
+     * @return \AppUtils\Request_Param
415
+     */
416 416
     public function setJSON() : Request_Param
417 417
     {
418 418
         return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true));
419 419
     }
420 420
     
421
-   /**
422
-    * Like {@link Request_Param::setJSON()}, but accepts
423
-    * only JSON objects. Arrays will not be accepted.
424
-    * 
425
-    * @return \AppUtils\Request_Param
426
-    */
421
+    /**
422
+     * Like {@link Request_Param::setJSON()}, but accepts
423
+     * only JSON objects. Arrays will not be accepted.
424
+     * 
425
+     * @return \AppUtils\Request_Param
426
+     */
427 427
     public function setJSONObject() : Request_Param
428 428
     {
429 429
         return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false));
430 430
     }
431 431
     
432
-   /**
433
-    * The parameter is a string boolean representation. This means
434
-    * it can be any of the following: "yes", "true", "no", "false".
435
-    * The value is automatically converted to a boolean when retrieving
436
-    * the parameter.
437
-    * 
438
-    * @return Request_Param
439
-    */
432
+    /**
433
+     * The parameter is a string boolean representation. This means
434
+     * it can be any of the following: "yes", "true", "no", "false".
435
+     * The value is automatically converted to a boolean when retrieving
436
+     * the parameter.
437
+     * 
438
+     * @return Request_Param
439
+     */
440 440
     public function setBoolean() : Request_Param
441 441
     {
442 442
         return $this->addClassFilter('Boolean');
443 443
     }
444 444
     
445
-   /**
446
-    * Validates the request parameter as an MD5 string,
447
-    * so that only values resembling md5 values are accepted.
448
-    * 
449
-    * NOTE: This can only guarantee the format, not whether
450
-    * it is an actual valid hash of something.
451
-    * 
452
-    * @return \AppUtils\Request_Param
453
-    */
445
+    /**
446
+     * Validates the request parameter as an MD5 string,
447
+     * so that only values resembling md5 values are accepted.
448
+     * 
449
+     * NOTE: This can only guarantee the format, not whether
450
+     * it is an actual valid hash of something.
451
+     * 
452
+     * @return \AppUtils\Request_Param
453
+     */
454 454
     public function setMD5() : Request_Param
455 455
     {
456 456
         return $this->setRegex(RegexHelper::REGEX_MD5);
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
         return $this;
493 493
     }
494 494
     
495
-   /**
496
-    * Retrieves the value of the request parameter,
497
-    * applying all filters (if any) and validation
498
-    * (if any).
499
-    * 
500
-    * @param mixed $default
501
-    * @return mixed
502
-    */
495
+    /**
496
+     * Retrieves the value of the request parameter,
497
+     * applying all filters (if any) and validation
498
+     * (if any).
499
+     * 
500
+     * @param mixed $default
501
+     * @return mixed
502
+     */
503 503
     public function get($default=null)
504 504
     {
505 505
         $value = $this->request->getParam($this->paramName);
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
         return $this;
588 588
     }
589 589
     
590
-   /**
591
-    * Adds a filter that trims whitespace from the request
592
-    * parameter using the PHP <code>trim</code> function.
593
-    * 
594
-    * @return \AppUtils\Request_Param
595
-    */
590
+    /**
591
+     * Adds a filter that trims whitespace from the request
592
+     * parameter using the PHP <code>trim</code> function.
593
+     * 
594
+     * @return \AppUtils\Request_Param
595
+     */
596 596
     public function addFilterTrim() : Request_Param
597 597
     {
598 598
         // to guarantee we only work with strings
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
         return $this->addCallbackFilter('trim');
602 602
     }
603 603
 
604
-   /**
605
-    * Converts the value to a string, even if it is not
606
-    * a string value. Complex types like arrays and objects
607
-    * are converted to an empty string.
608
-    * 
609
-    * @return \AppUtils\Request_Param
610
-    */
604
+    /**
605
+     * Converts the value to a string, even if it is not
606
+     * a string value. Complex types like arrays and objects
607
+     * are converted to an empty string.
608
+     * 
609
+     * @return \AppUtils\Request_Param
610
+     */
611 611
     public function addStringFilter() : Request_Param
612 612
     {
613 613
         return $this->addClassFilter('String');
@@ -657,12 +657,12 @@  discard block
 block discarded – undo
657 657
         return $this->addCallbackFilter('strip_tags', array($allowedTags));
658 658
     }
659 659
     
660
-   /**
661
-    * Adds a filter that strips all whitespace from the
662
-    * request parameter, from spaces to tabs and newlines.
663
-    * 
664
-    * @return \AppUtils\Request_Param
665
-    */
660
+    /**
661
+     * Adds a filter that strips all whitespace from the
662
+     * request parameter, from spaces to tabs and newlines.
663
+     * 
664
+     * @return \AppUtils\Request_Param
665
+     */
666 666
     public function addStripWhitespaceFilter() : Request_Param
667 667
     {
668 668
         // to ensure we only work with strings.
@@ -671,14 +671,14 @@  discard block
 block discarded – undo
671 671
         return $this->addClassFilter('StripWhitespace');
672 672
     }   
673 673
     
674
-   /**
675
-    * Adds a filter that transforms comma separated values
676
-    * into an array of values.
677
-    * 
678
-    * @param bool $trimEntries Trim whitespace from each entry?
679
-    * @param bool $stripEmptyEntries Remove empty entries from the array?
680
-    * @return \AppUtils\Request_Param
681
-    */
674
+    /**
675
+     * Adds a filter that transforms comma separated values
676
+     * into an array of values.
677
+     * 
678
+     * @param bool $trimEntries Trim whitespace from each entry?
679
+     * @param bool $stripEmptyEntries Remove empty entries from the array?
680
+     * @return \AppUtils\Request_Param
681
+     */
682 682
     public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param
683 683
     {
684 684
         $this->setArray();
@@ -703,12 +703,12 @@  discard block
 block discarded – undo
703 703
         );
704 704
     }
705 705
     
706
-   /**
707
-    * Adds a filter that encodes all HTML special characters
708
-    * using the PHP <code>htmlspecialchars</code> function.
709
-    * 
710
-    * @return \AppUtils\Request_Param
711
-    */
706
+    /**
707
+     * Adds a filter that encodes all HTML special characters
708
+     * using the PHP <code>htmlspecialchars</code> function.
709
+     * 
710
+     * @return \AppUtils\Request_Param
711
+     */
712 712
     public function addHTMLSpecialcharsFilter() : Request_Param
713 713
     {
714 714
         return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8'));
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
     
722 722
     protected $required = false;
723 723
     
724
-   /**
725
-    * Marks this request parameter as required. To use this feature,
726
-    * you have to call the request's {@link Request::validate()}
727
-    * method.
728
-    * 
729
-    * @return Request_Param
730
-    * @see Request::validate()
731
-    */
724
+    /**
725
+     * Marks this request parameter as required. To use this feature,
726
+     * you have to call the request's {@link Request::validate()}
727
+     * method.
728
+     * 
729
+     * @return Request_Param
730
+     * @see Request::validate()
731
+     */
732 732
     public function makeRequired() : Request_Param
733 733
     {
734 734
         $this->required = true;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
     * @param array $args
127 127
     * @return Request_Param
128 128
     */
129
-    public function setCallback($callback, array $args=array()) : Request_Param
129
+    public function setCallback($callback, array $args = array()) : Request_Param
130 130
     {
131
-        if(!is_callable($callback)) {
131
+        if (!is_callable($callback)) {
132 132
             throw new Request_Exception(
133 133
                 'Not a valid callback',
134 134
                 'The specified callback is not a valid callable entity.',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         
162 162
         // go through all enqueued validations in turn, each time
163 163
         // replacing the value with the adjusted, validated value.
164
-        foreach($this->validations as $validateDef) 
164
+        foreach ($this->validations as $validateDef) 
165 165
         {
166 166
             $value = $this->validateType($value, $validateDef['type'], $validateDef['params']);
167 167
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type);
185 185
         
186
-        if(!class_exists($class))
186
+        if (!class_exists($class))
187 187
         {
188 188
             throw new Request_Exception(
189 189
                 'Unknown validation type.',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $validator = new $class($this);
200 200
         $validator->setOptions($params);
201 201
         
202
-        if($this->valueType === self::VALUE_TYPE_ID_LIST)
202
+        if ($this->valueType === self::VALUE_TYPE_ID_LIST)
203 203
         {
204 204
             $value = $this->validateType_idList($value, $validator);
205 205
         }
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
     
214 214
     protected function validateType_idList($value, Request_Param_Validator $validator) : array
215 215
     {
216
-        if(!is_array($value))
216
+        if (!is_array($value))
217 217
         {
218 218
             $value = explode(',', $value);
219 219
         }
220 220
         
221 221
         $keep = array();
222 222
         
223
-        foreach($value as $subval)
223
+        foreach ($value as $subval)
224 224
         {
225 225
             $subval = trim($subval);
226 226
             $subval = $validator->validate($subval);
227 227
             
228
-            if($subval !== null) {
228
+            if ($subval !== null) {
229 229
                 $keep[] = intval($subval);
230 230
             }
231 231
         }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     {
366 366
         $args = func_get_args(); // cannot be used as function parameter in some PHP versions
367 367
         
368
-        if(is_array($args[0])) 
368
+        if (is_array($args[0])) 
369 369
         {
370 370
             $args = $args[0];
371 371
         }
@@ -500,10 +500,10 @@  discard block
 block discarded – undo
500 500
     * @param mixed $default
501 501
     * @return mixed
502 502
     */
503
-    public function get($default=null)
503
+    public function get($default = null)
504 504
     {
505 505
         $value = $this->request->getParam($this->paramName);
506
-        if($value !== null && $value !== '') {
506
+        if ($value !== null && $value !== '') {
507 507
             return $value;
508 508
         }
509 509
 
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
     {
523 523
         $total = count($this->filters);
524 524
         for ($i = 0; $i < $total; $i++) {
525
-            $method = 'applyFilter_' . $this->filters[$i]['type'];
525
+            $method = 'applyFilter_'.$this->filters[$i]['type'];
526 526
             $value = $this->$method($value, $this->filters[$i]['params']);
527 527
         }
528 528
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     * @param bool $stripEmptyEntries Remove empty entries from the array?
680 680
     * @return \AppUtils\Request_Param
681 681
     */
682
-    public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param
682
+    public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : Request_Param
683 683
     {
684 684
         $this->setArray();
685 685
         
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
         );
693 693
     }
694 694
     
695
-    protected function addClassFilter(string $name, array $params=array()) : Request_Param
695
+    protected function addClassFilter(string $name, array $params = array()) : Request_Param
696 696
     {
697 697
         return $this->addFilter(
698 698
             self::FILTER_TYPE_CLASS,
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -202,8 +202,7 @@
 block discarded – undo
202 202
         if($this->valueType === self::VALUE_TYPE_ID_LIST)
203 203
         {
204 204
             $value = $this->validateType_idList($value, $validator);
205
-        }
206
-        else
205
+        } else
207 206
         {
208 207
             $value = $validator->validate($value);
209 208
         }
Please login to merge, or discard this patch.
src/VariableInfo/Renderer/String.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 
7 7
 abstract class VariableInfo_Renderer_String extends VariableInfo_Renderer
8 8
 {
9
-   /**
10
-    * @var mixed
11
-    */
9
+    /**
10
+     * @var mixed
11
+     */
12 12
     protected $value;
13 13
     
14 14
     protected function init()
Please login to merge, or discard this patch.
src/VariableInfo/Renderer/HTML.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
             str_replace(' ', '-', $this->type)
41 41
         );
42 42
         
43
-        if($this->info->getBoolOption('prepend-type') && !$this->info->isNull())
43
+        if ($this->info->getBoolOption('prepend-type') && !$this->info->isNull())
44 44
         {
45 45
             $typeLabel = '<span style="color:#1c2eb1" class="variable-type">'.$this->info->getType().'</span> ';
46 46
             $converted = $typeLabel.' '.$converted;
Please login to merge, or discard this patch.
src/VariableInfo/Renderer/String/Callable.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     {
11 11
         $string = '';
12 12
         
13
-        if(is_string($this->value[0])) 
13
+        if (is_string($this->value[0])) 
14 14
         {
15 15
             $string .= $this->value[0].'::';
16 16
         } 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
         if(is_string($this->value[0])) 
14 14
         {
15 15
             $string .= $this->value[0].'::';
16
-        } 
17
-        else 
16
+        } else 
18 17
         {
19 18
             $string .= get_class($this->value[0]).'->';
20 19
         }
Please login to merge, or discard this patch.
src/VariableInfo/Renderer/String/Array.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
     {
11 11
         $result = array();
12 12
         
13
-        foreach($this->value as $key => $val)
13
+        foreach ($this->value as $key => $val)
14 14
         {
15 15
             $result[$key] = parseVariable($val)->toString();
16 16
         }
Please login to merge, or discard this patch.
src/VariableInfo/Renderer.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,19 +6,19 @@  discard block
 block discarded – undo
6 6
 
7 7
 abstract class VariableInfo_Renderer
8 8
 {
9
-   /**
10
-    * @var mixed
11
-    */
9
+    /**
10
+     * @var mixed
11
+     */
12 12
     protected $value;
13 13
     
14
-   /**
15
-    * @var VariableInfo
16
-    */
14
+    /**
15
+     * @var VariableInfo
16
+     */
17 17
     protected $info;
18 18
     
19
-   /**
20
-    * @var string
21
-    */
19
+    /**
20
+     * @var string
21
+     */
22 22
     protected $type;
23 23
     
24 24
     public function __construct(VariableInfo $info)
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
     
32 32
     abstract protected function init();
33 33
 
34
-   /**
35
-    * Renders the value to the target format.
36
-    * 
37
-    * @return mixed
38
-    */
34
+    /**
35
+     * Renders the value to the target format.
36
+     * 
37
+     * @return mixed
38
+     */
39 39
     public function render()
40 40
     {
41 41
         return $this->_render();
Please login to merge, or discard this patch.
src/XMLHelper/Converter/Decorator.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -21,25 +21,25 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class XMLHelper_Converter_Decorator implements \JsonSerializable
23 23
 {
24
-   /**
25
-    * @var \SimpleXMLElement
26
-    */
24
+    /**
25
+     * @var \SimpleXMLElement
26
+     */
27 27
     private $subject;
28 28
     
29 29
     const DEF_DEPTH = 512;
30 30
     
31
-   /**
32
-    * @var array
33
-    */
31
+    /**
32
+     * @var array
33
+     */
34 34
     private $options = array(
35 35
         '@attributes' => true,
36 36
         '@text' => true,
37 37
         'depth' => self::DEF_DEPTH
38 38
     );
39 39
 
40
-   /**
41
-    * @var array|string|null
42
-    */
40
+    /**
41
+     * @var array|string|null
42
+     */
43 43
     protected $result = array();
44 44
     
45 45
     public function __construct(\SimpleXMLElement $element)
@@ -47,36 +47,36 @@  discard block
 block discarded – undo
47 47
         $this->subject = $element;
48 48
     }
49 49
     
50
-   /**
51
-    * Whether to use the `@attributes` key to store element attributes.
52
-    * 
53
-    * @param bool $bool
54
-    * @return XMLHelper_Converter_Decorator
55
-    */
50
+    /**
51
+     * Whether to use the `@attributes` key to store element attributes.
52
+     * 
53
+     * @param bool $bool
54
+     * @return XMLHelper_Converter_Decorator
55
+     */
56 56
     public function useAttributes(bool $bool) : XMLHelper_Converter_Decorator 
57 57
     {
58 58
         $this->options['@attributes'] = (bool)$bool;
59 59
         return $this;
60 60
     }
61 61
     
62
-   /**
63
-    * Whether to use the `@text` key to store the node text.
64
-    * 
65
-    * @param bool $bool
66
-    * @return XMLHelper_Converter_Decorator
67
-    */
62
+    /**
63
+     * Whether to use the `@text` key to store the node text.
64
+     * 
65
+     * @param bool $bool
66
+     * @return XMLHelper_Converter_Decorator
67
+     */
68 68
     public function useText(bool $bool) : XMLHelper_Converter_Decorator 
69 69
     {
70 70
         $this->options['@text'] = (bool)$bool;
71 71
         return $this;
72 72
     }
73 73
     
74
-   /**
75
-    * Set the maximum depth to parse in the document.
76
-    * 
77
-    * @param int $depth
78
-    * @return XMLHelper_Converter_Decorator
79
-    */
74
+    /**
75
+     * Set the maximum depth to parse in the document.
76
+     * 
77
+     * @param int $depth
78
+     * @return XMLHelper_Converter_Decorator
79
+     */
80 80
     public function setDepth(int $depth) : XMLHelper_Converter_Decorator 
81 81
     {
82 82
         $this->options['depth'] = (int)max(0, $depth);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     
108 108
     protected function detectAttributes()
109 109
     {
110
-        if(!$this->options['@attributes']) {
110
+        if (!$this->options['@attributes']) {
111 111
             return;
112 112
         }
113 113
         
114 114
         $attributes = $this->subject->attributes();
115 115
         
116
-        if(!empty($attributes)) 
116
+        if (!empty($attributes)) 
117 117
         {
118 118
             $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes));
119 119
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         $children = $this->subject;
125 125
         $depth = $this->options['depth'] - 1;
126 126
         
127
-        if($depth <= 0) 
127
+        if ($depth <= 0) 
128 128
         {
129 129
             $children = [];
130 130
         }
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
             
138 138
             $decorator->options = ['depth' => $depth] + $this->options;
139 139
             
140
-            if(isset($this->result[$name])) 
140
+            if (isset($this->result[$name])) 
141 141
             {
142
-                if(!is_array($this->result[$name])) 
142
+                if (!is_array($this->result[$name])) 
143 143
                 {
144 144
                     $this->result[$name] = [$this->result[$name]];
145 145
                 }
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
         // json encode non-whitespace element simplexml text values.
159 159
         $text = trim((string)$this->subject);
160 160
         
161
-        if(strlen($text)) 
161
+        if (strlen($text)) 
162 162
         {
163
-            if($this->options['@text']) 
163
+            if ($this->options['@text']) 
164 164
             {
165 165
                 $this->result['@text'] = $text;
166 166
             } 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -145,8 +145,7 @@  discard block
 block discarded – undo
145 145
                 }
146 146
                 
147 147
                 $this->result[$name][] = $decorator;
148
-            } 
149
-            else 
148
+            } else 
150 149
             {
151 150
                 $this->result[$name] = $decorator;
152 151
             }
@@ -163,8 +162,7 @@  discard block
 block discarded – undo
163 162
             if($this->options['@text']) 
164 163
             {
165 164
                 $this->result['@text'] = $text;
166
-            } 
167
-            else 
165
+            } else 
168 166
             {
169 167
                 $this->result = $text;
170 168
             }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
  * @param mixed $value
17 17
  * @return \AppUtils\NumberInfo
18 18
  */
19
-function parseNumber($value, $forceNew=false)
19
+function parseNumber($value, $forceNew = false)
20 20
 {
21
-    if($value instanceof NumberInfo && $forceNew !== true) {
21
+    if ($value instanceof NumberInfo && $forceNew !== true) {
22 22
         return $value;
23 23
     }
24 24
     
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     $args = func_get_args();
100 100
     
101 101
     // is the localization package installed?
102
-    if(class_exists('\AppLocalize\Localization')) 
102
+    if (class_exists('\AppLocalize\Localization')) 
103 103
     {
104 104
         return call_user_func_array('\AppLocalize\t', $args);
105 105
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function requireCURL() : void
119 119
 {
120
-    if(function_exists('curl_init')) {
120
+    if (function_exists('curl_init')) {
121 121
         return;
122 122
     }
123 123
     
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  */
136 136
 function init()
137 137
 {
138
-    if(!class_exists('\AppLocalize\Localization')) {
138
+    if (!class_exists('\AppLocalize\Localization')) {
139 139
         return;
140 140
     }
141 141
     
Please login to merge, or discard this patch.
src/FileHelper/FileFinder.php 3 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
     
34 34
     const PATH_MODE_STRIP = 'strip';
35 35
     
36
-   /**
37
-    * @var string
38
-    */
36
+    /**
37
+     * @var string
38
+     */
39 39
     protected $path;
40 40
     
41
-   /**
42
-    * @var array
43
-    */
41
+    /**
42
+     * @var array
43
+     */
44 44
     protected $found;
45 45
     
46
-   /**
47
-    * The path must exist when the class is instantiated: its
48
-    * real path will be determined to work with.
49
-    * 
50
-    * @param string $path The absolute path to the target folder.
51
-    * @throws FileHelper_Exception
52
-    * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST
53
-    */
46
+    /**
47
+     * The path must exist when the class is instantiated: its
48
+     * real path will be determined to work with.
49
+     * 
50
+     * @param string $path The absolute path to the target folder.
51
+     * @throws FileHelper_Exception
52
+     * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST
53
+     */
54 54
     public function __construct(string $path)
55 55
     {
56 56
         $real = realpath($path);
@@ -82,66 +82,66 @@  discard block
 block discarded – undo
82 82
         );
83 83
     }
84 84
     
85
-   /**
86
-    * Enables extension stripping, to return file names without extension.
87
-    * 
88
-    * @return FileHelper_FileFinder
89
-    */
85
+    /**
86
+     * Enables extension stripping, to return file names without extension.
87
+     * 
88
+     * @return FileHelper_FileFinder
89
+     */
90 90
     public function stripExtensions() : FileHelper_FileFinder
91 91
     {
92 92
         return $this->setOption('strip-extensions', true);
93 93
     }
94 94
     
95
-   /**
96
-    * Enables recursing into subfolders.
97
-    * 
98
-    * @return FileHelper_FileFinder
99
-    */
95
+    /**
96
+     * Enables recursing into subfolders.
97
+     * 
98
+     * @return FileHelper_FileFinder
99
+     */
100 100
     public function makeRecursive() : FileHelper_FileFinder
101 101
     {
102 102
         return $this->setOption('recursive', true);
103 103
     }
104 104
     
105
-   /**
106
-    * Retrieves all extensions that were added to
107
-    * the include list.
108
-    * 
109
-    * @return array
110
-    */
105
+    /**
106
+     * Retrieves all extensions that were added to
107
+     * the include list.
108
+     * 
109
+     * @return array
110
+     */
111 111
     public function getIncludeExtensions() : array
112 112
     {
113 113
         return $this->getArrayOption('include-extensions');
114 114
     }
115 115
     
116
-   /**
117
-    * Includes a single extension in the file search: only
118
-    * files with this extension will be used in the results.
119
-    * 
120
-    * NOTE: Included extensions take precedence before excluded
121
-    * extensions. If any excluded extensions are specified, they
122
-    * will be ignored.
123
-    * 
124
-    * @param string $extension Extension name, without dot (`php` for example).
125
-    * @return FileHelper_FileFinder
126
-    * @see FileHelper_FileFinder::includeExtensions()
127
-    */
116
+    /**
117
+     * Includes a single extension in the file search: only
118
+     * files with this extension will be used in the results.
119
+     * 
120
+     * NOTE: Included extensions take precedence before excluded
121
+     * extensions. If any excluded extensions are specified, they
122
+     * will be ignored.
123
+     * 
124
+     * @param string $extension Extension name, without dot (`php` for example).
125
+     * @return FileHelper_FileFinder
126
+     * @see FileHelper_FileFinder::includeExtensions()
127
+     */
128 128
     public function includeExtension(string $extension) : FileHelper_FileFinder
129 129
     {
130 130
         return $this->includeExtensions(array($extension));
131 131
     }
132 132
     
133
-   /**
134
-    * Includes several extensions in the file search: only
135
-    * files with these extensions wil be used in the results.
136
-    * 
137
-    * NOTE: Included extensions take precedence before excluded
138
-    * extensions. If any excluded extensions are specified, they
139
-    * will be ignored.
140
-    * 
141
-    * @param array $extensions Extension names, without dot (`php` for example).
142
-    * @return FileHelper_FileFinder
143
-    * @see FileHelper_FileFinder::includeExtension()
144
-    */
133
+    /**
134
+     * Includes several extensions in the file search: only
135
+     * files with these extensions wil be used in the results.
136
+     * 
137
+     * NOTE: Included extensions take precedence before excluded
138
+     * extensions. If any excluded extensions are specified, they
139
+     * will be ignored.
140
+     * 
141
+     * @param array $extensions Extension names, without dot (`php` for example).
142
+     * @return FileHelper_FileFinder
143
+     * @see FileHelper_FileFinder::includeExtension()
144
+     */
145 145
     public function includeExtensions(array $extensions) : FileHelper_FileFinder
146 146
     {
147 147
         $items = $this->getIncludeExtensions();
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
         return $this;
153 153
     }
154 154
 
155
-   /**
156
-    * Retrieves a list of all extensions currently set as 
157
-    * excluded from the search.
158
-    * 
159
-    * @return array
160
-    */
155
+    /**
156
+     * Retrieves a list of all extensions currently set as 
157
+     * excluded from the search.
158
+     * 
159
+     * @return array
160
+     */
161 161
     public function getExcludeExtensions() : array
162 162
     {
163 163
         return $this->getArrayOption('exclude-extensions');
164 164
     }
165 165
     
166
-   /**
167
-    * Excludes a single extension from the search.
168
-    * 
169
-    * @param string $extension Extension name, without dot (`php` for example).
170
-    * @return FileHelper_FileFinder
171
-    * @see FileHelper_FileFinder::excludeExtensions()
172
-    */
166
+    /**
167
+     * Excludes a single extension from the search.
168
+     * 
169
+     * @param string $extension Extension name, without dot (`php` for example).
170
+     * @return FileHelper_FileFinder
171
+     * @see FileHelper_FileFinder::excludeExtensions()
172
+     */
173 173
     public function excludeExtension(string $extension) : FileHelper_FileFinder
174 174
     {
175 175
         return $this->excludeExtensions(array($extension));
176 176
     }
177 177
 
178
-   /**
179
-    * Add several extensions to the list of extensions to
180
-    * exclude from the file search.
181
-    *  
182
-    * @param array $extensions Extension names, without dot (`php` for example).
183
-    * @return FileHelper_FileFinder
184
-    * @see FileHelper_FileFinder::excludeExtension()
185
-    */
178
+    /**
179
+     * Add several extensions to the list of extensions to
180
+     * exclude from the file search.
181
+     *  
182
+     * @param array $extensions Extension names, without dot (`php` for example).
183
+     * @return FileHelper_FileFinder
184
+     * @see FileHelper_FileFinder::excludeExtension()
185
+     */
186 186
     public function excludeExtensions(array $extensions) : FileHelper_FileFinder
187 187
     {
188 188
         $items = $this->getExcludeExtensions();
@@ -193,52 +193,52 @@  discard block
 block discarded – undo
193 193
         return $this;
194 194
     }
195 195
     
196
-   /**
197
-    * In this mode, the entire path to the file will be stripped,
198
-    * leaving only the file name in the files list.
199
-    * 
200
-    * @return FileHelper_FileFinder
201
-    */
196
+    /**
197
+     * In this mode, the entire path to the file will be stripped,
198
+     * leaving only the file name in the files list.
199
+     * 
200
+     * @return FileHelper_FileFinder
201
+     */
202 202
     public function setPathmodeStrip() : FileHelper_FileFinder
203 203
     {
204 204
         return $this->setPathmode(self::PATH_MODE_STRIP);
205 205
     }
206 206
     
207
-   /**
208
-    * In this mode, only the path relative to the source folder
209
-    * will be included in the files list.
210
-    * 
211
-    * @return FileHelper_FileFinder
212
-    */
207
+    /**
208
+     * In this mode, only the path relative to the source folder
209
+     * will be included in the files list.
210
+     * 
211
+     * @return FileHelper_FileFinder
212
+     */
213 213
     public function setPathmodeRelative() : FileHelper_FileFinder
214 214
     {
215 215
         return $this->setPathmode(self::PATH_MODE_RELATIVE);
216 216
     }
217 217
     
218
-   /**
219
-    * In this mode, the full, absolute paths to the files will
220
-    * be included in the files list.
221
-    * 
222
-    * @return FileHelper_FileFinder
223
-    */
218
+    /**
219
+     * In this mode, the full, absolute paths to the files will
220
+     * be included in the files list.
221
+     * 
222
+     * @return FileHelper_FileFinder
223
+     */
224 224
     public function setPathmodeAbsolute() : FileHelper_FileFinder
225 225
     {
226 226
         return $this->setPathmode(self::PATH_MODE_ABSOLUTE);
227 227
     }
228 228
     
229
-   /**
230
-    * This sets a character or string to replace the slashes
231
-    * in the paths with. 
232
-    * 
233
-    * This is used for example in the `getPHPClassNames()` 
234
-    * method, to return files from subfolders as class names
235
-    * using the "_" character:
236
-    * 
237
-    * Subfolder/To/File.php => Subfolder_To_File.php
238
-    * 
239
-    * @param string $character
240
-    * @return \AppUtils\FileHelper_FileFinder
241
-    */
229
+    /**
230
+     * This sets a character or string to replace the slashes
231
+     * in the paths with. 
232
+     * 
233
+     * This is used for example in the `getPHPClassNames()` 
234
+     * method, to return files from subfolders as class names
235
+     * using the "_" character:
236
+     * 
237
+     * Subfolder/To/File.php => Subfolder_To_File.php
238
+     * 
239
+     * @param string $character
240
+     * @return \AppUtils\FileHelper_FileFinder
241
+     */
242 242
     public function setSlashReplacement(string $character) : FileHelper_FileFinder
243 243
     {
244 244
         return $this->setOption('slash-replacement', $character);
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
         return $this->setOption('pathmode', $mode);
250 250
     }
251 251
     
252
-   /**
253
-    * Retrieves a list of all matching file names/paths,
254
-    * depending on the selected options.
255
-    * 
256
-    * @return array
257
-    */
252
+    /**
253
+     * Retrieves a list of all matching file names/paths,
254
+     * depending on the selected options.
255
+     * 
256
+     * @return array
257
+     */
258 258
     public function getAll() : array
259 259
     {
260 260
         $this->find($this->path, true);
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
         return $this->found;
263 263
     }
264 264
     
265
-   /**
266
-    * Retrieves only PHP files. Can be combined with other
267
-    * options like enabling recursion into subfolders.
268
-    * 
269
-    * @return array
270
-    */
265
+    /**
266
+     * Retrieves only PHP files. Can be combined with other
267
+     * options like enabling recursion into subfolders.
268
+     * 
269
+     * @return array
270
+     */
271 271
     public function getPHPFiles() : array
272 272
     {
273 273
         $this->includeExtensions(array('php'));
274 274
         return $this->getAll();
275 275
     }
276 276
     
277
-   /**
278
-    * Generates PHP class names from file paths: it replaces
279
-    * slashes with underscores, and removes file extensions.
280
-    * 
281
-    * @return array An array of PHP file names without extension.
282
-    */
277
+    /**
278
+     * Generates PHP class names from file paths: it replaces
279
+     * slashes with underscores, and removes file extensions.
280
+     * 
281
+     * @return array An array of PHP file names without extension.
282
+     */
283 283
     public function getPHPClassNames() : array
284 284
     {
285 285
         $this->includeExtensions(array('php'));
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
         return $path;
351 351
     }
352 352
     
353
-   /**
354
-    * Checks whether the specified extension is allowed 
355
-    * with the current settings.
356
-    * 
357
-    * @param string $extension
358
-    * @return bool
359
-    */
353
+    /**
354
+     * Checks whether the specified extension is allowed 
355
+     * with the current settings.
356
+     * 
357
+     * @param string $extension
358
+     * @return bool
359
+     */
360 360
     protected function filterExclusion(string $extension) : bool
361 361
     {
362 362
         $include = $this->getOption('include-extensions');
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
         return true;
379 379
     }
380 380
     
381
-   /**
382
-    * Adjusts the path according to the selected path mode.
383
-    * 
384
-    * @param string $path
385
-    * @return string
386
-    */
381
+    /**
382
+     * Adjusts the path according to the selected path mode.
383
+     * 
384
+     * @param string $path
385
+     * @return string
386
+     */
387 387
     protected function filterPath(string $path) : string
388 388
     {
389 389
         switch($this->getStringOption('pathmode'))
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @see FileHelper_FileFinder
8 8
  */
9 9
 
10
-declare(strict_types = 1);
10
+declare(strict_types=1);
11 11
 
12 12
 namespace AppUtils;
13 13
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         $real = realpath($path);
57 57
         
58
-        if($real === false) 
58
+        if ($real === false) 
59 59
         {
60 60
             throw new FileHelper_Exception(
61 61
                 'Target path does not exist',
@@ -290,22 +290,22 @@  discard block
 block discarded – undo
290 290
         return $this->getAll();
291 291
     }
292 292
     
293
-    protected function find(string $path, bool $isRoot=false) : void
293
+    protected function find(string $path, bool $isRoot = false) : void
294 294
     {
295
-        if($isRoot) {
295
+        if ($isRoot) {
296 296
             $this->found = array();
297 297
         }
298 298
         
299 299
         $recursive = $this->getBoolOption('recursive');
300 300
         
301 301
         $d = new \DirectoryIterator($path);
302
-        foreach($d as $item)
302
+        foreach ($d as $item)
303 303
         {
304 304
             $pathname = $item->getPathname();
305 305
             
306
-            if($item->isDir())
306
+            if ($item->isDir())
307 307
             {
308
-                if($recursive && !$item->isDot()) {
308
+                if ($recursive && !$item->isDot()) {
309 309
                     $this->find($pathname);
310 310
                 }
311 311
                 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             
315 315
             $file = $this->filterFile($pathname);
316 316
             
317
-            if($file !== null) 
317
+            if ($file !== null) 
318 318
             {
319 319
                 $this->found[] = $file;
320 320
             }
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
         
328 328
         $extension = FileHelper::getExtension($path);
329 329
         
330
-        if(!$this->filterExclusion($extension)) {
330
+        if (!$this->filterExclusion($extension)) {
331 331
             return null;
332 332
         }
333 333
         
334 334
         $path = $this->filterPath($path);
335 335
         
336
-        if($this->getOption('strip-extensions') === true)
336
+        if ($this->getOption('strip-extensions') === true)
337 337
         {
338 338
             $path = str_replace('.'.$extension, '', $path);
339 339
         }
340 340
         
341
-        if($path === '') {
341
+        if ($path === '') {
342 342
             return null;
343 343
         }
344 344
         
345 345
         $replace = $this->getOption('slash-replacement');
346
-        if(!empty($replace)) {
346
+        if (!empty($replace)) {
347 347
             $path = str_replace('/', $replace, $path);
348 348
         }
349 349
         
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
         $include = $this->getOption('include-extensions');
363 363
         $exclude = $this->getOption('exclude-extensions');
364 364
         
365
-        if(!empty($include))
365
+        if (!empty($include))
366 366
         {
367
-            if(!in_array($extension, $include)) {
367
+            if (!in_array($extension, $include)) {
368 368
                 return false;
369 369
             }
370 370
         }
371
-        else if(!empty($exclude))
371
+        else if (!empty($exclude))
372 372
         {
373
-            if(in_array($extension, $exclude)) {
373
+            if (in_array($extension, $exclude)) {
374 374
                 return false;
375 375
             }
376 376
         }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     */
387 387
     protected function filterPath(string $path) : string
388 388
     {
389
-        switch($this->getStringOption('pathmode'))
389
+        switch ($this->getStringOption('pathmode'))
390 390
         {
391 391
             case self::PATH_MODE_STRIP:
392 392
                 return basename($path);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -367,8 +367,7 @@
 block discarded – undo
367 367
             if(!in_array($extension, $include)) {
368 368
                 return false;
369 369
             }
370
-        }
371
-        else if(!empty($exclude))
370
+        } else if(!empty($exclude))
372 371
         {
373 372
             if(in_array($extension, $exclude)) {
374 373
                 return false;
Please login to merge, or discard this patch.