Passed
Push — master ( 606be1...b28623 )
by Sebastian
02:43
created
src/ConvertHelper/QueryParser.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@
 block discarded – undo
27 27
         
28 28
     }
29 29
     
30
-   /**
31
-    * We parse the query string ourselves, because the PHP implementation
32
-    * of parse_str has limitations that do not apply to query strings. This
33
-    * is due to the fact that parse_str has to create PHP-compatible variable
34
-    * names from the parameters. URL parameters simply allow way more things
35
-    * than PHP variable names.
36
-    * 
37
-    * @param string $queryString
38
-    * @return array
39
-    */
30
+    /**
31
+     * We parse the query string ourselves, because the PHP implementation
32
+     * of parse_str has limitations that do not apply to query strings. This
33
+     * is due to the fact that parse_str has to create PHP-compatible variable
34
+     * names from the parameters. URL parameters simply allow way more things
35
+     * than PHP variable names.
36
+     * 
37
+     * @param string $queryString
38
+     * @return array
39
+     */
40 40
     public function parse(string $queryString) : array
41 41
     {
42 42
         // allow HTML entities notation
Please login to merge, or discard this patch.
src/URLInfo.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -39,42 +39,42 @@  discard block
 block discarded – undo
39 39
     const TYPE_PHONE = 'phone';
40 40
     const TYPE_URL = 'url';
41 41
     
42
-   /**
43
-    * The original URL that was passed to the constructor.
44
-    * @var string
45
-    */
42
+    /**
43
+     * The original URL that was passed to the constructor.
44
+     * @var string
45
+     */
46 46
     protected $rawURL;
47 47
 
48
-   /**
49
-    * @var array
50
-    */
48
+    /**
49
+     * @var array
50
+     */
51 51
     protected $info;
52 52
     
53
-   /**
54
-    * @var string[]
55
-    */
53
+    /**
54
+     * @var string[]
55
+     */
56 56
     protected $excludedParams = array();
57 57
     
58
-   /**
59
-    * @var bool
60
-    * @see URLInfo::setParamExclusion()
61
-    */
58
+    /**
59
+     * @var bool
60
+     * @see URLInfo::setParamExclusion()
61
+     */
62 62
     protected $paramExclusion = false;
63 63
     
64
-   /**
65
-    * @var array
66
-    * @see URLInfo::getTypeLabel()
67
-    */
64
+    /**
65
+     * @var array
66
+     * @see URLInfo::getTypeLabel()
67
+     */
68 68
     protected static $typeLabels;
69 69
     
70
-   /**
71
-    * @var bool
72
-    */
70
+    /**
71
+     * @var bool
72
+     */
73 73
     protected $highlightExcluded = false;
74 74
     
75
-   /**
76
-    * @var array
77
-    */
75
+    /**
76
+     * @var array
77
+     */
78 78
     protected $infoKeys = array(
79 79
         'scheme',
80 80
         'host',
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
         'fragment'
87 87
     );
88 88
     
89
-   /**
90
-    * @var string
91
-    */
89
+    /**
90
+     * @var string
91
+     */
92 92
     protected $url;
93 93
     
94
-   /**
95
-    * @var URLInfo_Parser
96
-    */
94
+    /**
95
+     * @var URLInfo_Parser
96
+     */
97 97
     protected $parser;
98 98
     
99
-   /**
100
-    * @var URLInfo_Normalizer
101
-    */
99
+    /**
100
+     * @var URLInfo_Normalizer
101
+     */
102 102
     protected $normalizer;
103 103
     
104
-   /**
105
-    * @var bool
106
-    */
104
+    /**
105
+     * @var bool
106
+     */
107 107
     protected $encodeUTFChars = false;
108 108
     
109 109
     public function __construct(string $url)
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
         $this->info = $this->parser->getInfo();
121 121
     }
122 122
     
123
-   /**
124
-    * Whether to URL encode any non-encoded UTF8 characters in the URL.
125
-    * Default is to leave them as-is for better readability, since 
126
-    * browsers handle this well.
127
-    * 
128
-    * @param bool $enabled
129
-    * @return URLInfo
130
-    */
123
+    /**
124
+     * Whether to URL encode any non-encoded UTF8 characters in the URL.
125
+     * Default is to leave them as-is for better readability, since 
126
+     * browsers handle this well.
127
+     * 
128
+     * @param bool $enabled
129
+     * @return URLInfo
130
+     */
131 131
     public function setUTFEncoding(bool $enabled=true) : URLInfo
132 132
     {
133 133
         if($this->encodeUTFChars !== $enabled)
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
         return $this->encodeUTFChars;
145 145
     }
146 146
     
147
-   /**
148
-    * Filters an URL: removes control characters and the
149
-    * like to have a clean URL to work with.
150
-    * 
151
-    * @param string $url
152
-    * @return string
153
-    */
147
+    /**
148
+     * Filters an URL: removes control characters and the
149
+     * like to have a clean URL to work with.
150
+     * 
151
+     * @param string $url
152
+     * @return string
153
+     */
154 154
     public static function filterURL(string $url)
155 155
     {
156 156
         return URLInfo_Filter::filter($url);
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
         return $this->info['type'] === self::TYPE_PHONE;
181 181
     }
182 182
     
183
-   /**
184
-    * Whether the URL is a regular URL, not one of the 
185
-    * other types like a phone number or email address.
186
-    * 
187
-    * @return bool
188
-    */
183
+    /**
184
+     * Whether the URL is a regular URL, not one of the 
185
+     * other types like a phone number or email address.
186
+     * 
187
+     * @return bool
188
+     */
189 189
     public function isURL() : bool
190 190
     {
191 191
         $host = $this->getHost();
@@ -197,20 +197,20 @@  discard block
 block discarded – undo
197 197
         return $this->parser->isValid();
198 198
     }
199 199
     
200
-   /**
201
-    * Retrieves the host name, or an empty string if none is present.
202
-    * 
203
-    * @return string
204
-    */
200
+    /**
201
+     * Retrieves the host name, or an empty string if none is present.
202
+     * 
203
+     * @return string
204
+     */
205 205
     public function getHost() : string
206 206
     {
207 207
         return $this->getInfoKey('host');
208 208
     }
209 209
     
210
-   /**
211
-    * Retrieves the path, or an empty string if none is present.
212
-    * @return string
213
-    */
210
+    /**
211
+     * Retrieves the path, or an empty string if none is present.
212
+     * @return string
213
+     */
214 214
     public function getPath() : string
215 215
     {
216 216
         return $this->getInfoKey('path');
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
         return $this->getInfoKey('scheme');
227 227
     }
228 228
     
229
-   /**
230
-    * Retrieves the port specified in the URL, or -1 if none is preseent.
231
-    * @return int
232
-    */
229
+    /**
230
+     * Retrieves the port specified in the URL, or -1 if none is preseent.
231
+     * @return int
232
+     */
233 233
     public function getPort() : int
234 234
     {
235 235
         $port = $this->getInfoKey('port');
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
         return -1;
242 242
     }
243 243
     
244
-   /**
245
-    * Retrieves the raw query string, or an empty string if none is present.
246
-    * 
247
-    * @return string
248
-    * 
249
-    * @see URLInfo::getParams()
250
-    */
244
+    /**
245
+     * Retrieves the raw query string, or an empty string if none is present.
246
+     * 
247
+     * @return string
248
+     * 
249
+     * @see URLInfo::getParams()
250
+     */
251 251
     public function getQuery() : string
252 252
     {
253 253
         return $this->getInfoKey('query');
@@ -263,20 +263,20 @@  discard block
 block discarded – undo
263 263
         return $this->getInfoKey('pass');
264 264
     }
265 265
     
266
-   /**
267
-    * Whether the URL contains a port number.
268
-    * @return bool
269
-    */
266
+    /**
267
+     * Whether the URL contains a port number.
268
+     * @return bool
269
+     */
270 270
     public function hasPort() : bool
271 271
     {
272 272
         return $this->getPort() !== -1;
273 273
     }
274 274
     
275
-   /**
276
-    * Alias for the hasParams() method.
277
-    * @return bool
278
-    * @see URLInfo::hasParams()
279
-    */
275
+    /**
276
+     * Alias for the hasParams() method.
277
+     * @return bool
278
+     * @see URLInfo::hasParams()
279
+     */
280 280
     public function hasQuery() : bool
281 281
     {
282 282
         return $this->hasParams();
@@ -321,23 +321,23 @@  discard block
 block discarded – undo
321 321
         return '';
322 322
     }
323 323
 
324
-   /**
325
-    * Retrieves a normalized URL: this ensures that all parameters
326
-    * in the URL are always in the same order.
327
-    * 
328
-    * @return string
329
-    */
324
+    /**
325
+     * Retrieves a normalized URL: this ensures that all parameters
326
+     * in the URL are always in the same order.
327
+     * 
328
+     * @return string
329
+     */
330 330
     public function getNormalized() : string
331 331
     {
332 332
         return $this->normalize(true);
333 333
     }
334 334
     
335
-   /**
336
-    * Like getNormalized(), but if a username and password are present
337
-    * in the URL, returns the URL without them.
338
-    * 
339
-    * @return string
340
-    */
335
+    /**
336
+     * Like getNormalized(), but if a username and password are present
337
+     * in the URL, returns the URL without them.
338
+     * 
339
+     * @return string
340
+     */
341 341
     public function getNormalizedWithoutAuth() : string
342 342
     {
343 343
         return $this->normalize(false);
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
         return $this->normalizer->normalize();
359 359
     }
360 360
     
361
-   /**
362
-    * Creates a hash of the URL, which can be used for comparisons.
363
-    * Since any parameters in the URL's query are sorted alphabetically,
364
-    * the same links with a different parameter order will have the 
365
-    * same hash.
366
-    * 
367
-    * @return string
368
-    */
361
+    /**
362
+     * Creates a hash of the URL, which can be used for comparisons.
363
+     * Since any parameters in the URL's query are sorted alphabetically,
364
+     * the same links with a different parameter order will have the 
365
+     * same hash.
366
+     * 
367
+     * @return string
368
+     */
369 369
     public function getHash()
370 370
     {
371 371
         return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized());
372 372
     }
373 373
 
374
-   /**
375
-    * Highlights the URL using HTML tags with specific highlighting
376
-    * class names.
377
-    * 
378
-    * @return string Will return an empty string if the URL is not valid.
379
-    */
374
+    /**
375
+     * Highlights the URL using HTML tags with specific highlighting
376
+     * class names.
377
+     * 
378
+     * @return string Will return an empty string if the URL is not valid.
379
+     */
380 380
     public function getHighlighted() : string
381 381
     {
382 382
         if(!$this->isValid()) {
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
         return count($params);
411 411
     }
412 412
     
413
-   /**
414
-    * Retrieves all parameters specified in the url,
415
-    * if any, as an associative array. 
416
-    * 
417
-    * NOTE: Ignores parameters that have been added
418
-    * to the excluded parameters list.
419
-    *
420
-    * @return array
421
-    */
413
+    /**
414
+     * Retrieves all parameters specified in the url,
415
+     * if any, as an associative array. 
416
+     * 
417
+     * NOTE: Ignores parameters that have been added
418
+     * to the excluded parameters list.
419
+     *
420
+     * @return array
421
+     */
422 422
     public function getParams() : array
423 423
     {
424 424
         if(!$this->paramExclusion || empty($this->excludedParams)) {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
         return $keep;
437 437
     }
438 438
     
439
-   /**
440
-    * Retrieves the names of all parameters present in the URL, if any.
441
-    * @return string[]
442
-    */
439
+    /**
440
+     * Retrieves the names of all parameters present in the URL, if any.
441
+     * @return string[]
442
+     */
443 443
     public function getParamNames() : array
444 444
     {
445 445
         $params = $this->getParams();
446 446
         return array_keys($params);
447 447
     }
448 448
     
449
-   /**
450
-    * Retrieves a specific parameter value from the URL.
451
-    * 
452
-    * @param string $name
453
-    * @return string The parameter value, or an empty string if it does not exist.
454
-    */
449
+    /**
450
+     * Retrieves a specific parameter value from the URL.
451
+     * 
452
+     * @param string $name
453
+     * @return string The parameter value, or an empty string if it does not exist.
454
+     */
455 455
     public function getParam(string $name) : string
456 456
     {
457 457
         if(isset($this->info['params'][$name])) {
@@ -461,16 +461,16 @@  discard block
 block discarded – undo
461 461
         return '';
462 462
     }
463 463
     
464
-   /**
465
-    * Excludes an URL parameter entirely if present:
466
-    * the parser will act as if the parameter was not
467
-    * even present in the source URL, effectively
468
-    * stripping it.
469
-    *
470
-    * @param string $name
471
-    * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
472
-    * @return URLInfo
473
-    */
464
+    /**
465
+     * Excludes an URL parameter entirely if present:
466
+     * the parser will act as if the parameter was not
467
+     * even present in the source URL, effectively
468
+     * stripping it.
469
+     *
470
+     * @param string $name
471
+     * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
472
+     * @return URLInfo
473
+     */
474 474
     public function excludeParam(string $name, string $reason) : URLInfo
475 475
     {
476 476
         if(!isset($this->excludedParams[$name]))
@@ -523,25 +523,25 @@  discard block
 block discarded – undo
523 523
         return self::$typeLabels[$this->getType()];
524 524
     }
525 525
 
526
-   /**
527
-    * Whether excluded parameters should be highlighted in
528
-    * a different color in the URL when using the
529
-    * {@link URLInfo::getHighlighted()} method.
530
-    *
531
-    * @param bool $highlight
532
-    * @return URLInfo
533
-    */
526
+    /**
527
+     * Whether excluded parameters should be highlighted in
528
+     * a different color in the URL when using the
529
+     * {@link URLInfo::getHighlighted()} method.
530
+     *
531
+     * @param bool $highlight
532
+     * @return URLInfo
533
+     */
534 534
     public function setHighlightExcluded(bool $highlight=true) : URLInfo
535 535
     {
536 536
         $this->highlightExcluded = $highlight;
537 537
         return $this;
538 538
     }
539 539
     
540
-   /**
541
-    * Returns an array with all relevant URL information.
542
-    * 
543
-    * @return array
544
-    */
540
+    /**
541
+     * Returns an array with all relevant URL information.
542
+     * 
543
+     * @return array
544
+     */
545 545
     public function toArray() : array
546 546
     {
547 547
         return array(
@@ -585,24 +585,24 @@  discard block
 block discarded – undo
585 585
         return $this;
586 586
     }
587 587
     
588
-   /**
589
-    * Whether the parameter exclusion mode is enabled:
590
-    * In this case, if any parameters have been added to the
591
-    * exclusion list, all relevant methods will exclude these.
592
-    *
593
-    * @return bool
594
-    */
588
+    /**
589
+     * Whether the parameter exclusion mode is enabled:
590
+     * In this case, if any parameters have been added to the
591
+     * exclusion list, all relevant methods will exclude these.
592
+     *
593
+     * @return bool
594
+     */
595 595
     public function isParamExclusionEnabled() : bool
596 596
     {
597 597
         return $this->paramExclusion;
598 598
     }
599 599
     
600
-   /**
601
-    * Checks whether the link contains any parameters that
602
-    * are on the list of excluded parameters.
603
-    *
604
-    * @return bool
605
-    */
600
+    /**
601
+     * Checks whether the link contains any parameters that
602
+     * are on the list of excluded parameters.
603
+     *
604
+     * @return bool
605
+     */
606 606
     public function containsExcludedParams() : bool
607 607
     {
608 608
         if(empty($this->excludedParams)) {
@@ -670,16 +670,16 @@  discard block
 block discarded – undo
670 670
         return $this->highlightExcluded;
671 671
     }
672 672
     
673
-   /**
674
-    * Checks if the URL exists, i.e. can be connected to. Will return
675
-    * true if the returned HTTP status code is `200` or `302`.
676
-    * 
677
-    * NOTE: If the target URL requires HTTP authentication, the username
678
-    * and password should be integrated into the URL.
679
-    * 
680
-    * @return bool
681
-    * @throws BaseException
682
-    */
673
+    /**
674
+     * Checks if the URL exists, i.e. can be connected to. Will return
675
+     * true if the returned HTTP status code is `200` or `302`.
676
+     * 
677
+     * NOTE: If the target URL requires HTTP authentication, the username
678
+     * and password should be integrated into the URL.
679
+     * 
680
+     * @return bool
681
+     * @throws BaseException
682
+     */
683 683
     public function tryConnect(bool $verifySSL=true) : bool
684 684
     {
685 685
         requireCURL();
Please login to merge, or discard this patch.
src/URLInfo/Parser.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -23,24 +23,24 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class URLInfo_Parser
25 25
 {
26
-   /**
27
-    * @var string
28
-    */
26
+    /**
27
+     * @var string
28
+     */
29 29
     protected $url;
30 30
     
31
-   /**
32
-    * @var bool
33
-    */
31
+    /**
32
+     * @var bool
33
+     */
34 34
     protected $isValid = false;
35 35
     
36
-   /**
37
-    * @var array
38
-    */
36
+    /**
37
+     * @var array
38
+     */
39 39
     protected $info;
40 40
     
41
-   /**
42
-    * @var array|NULL
43
-    */
41
+    /**
42
+     * @var array|NULL
43
+     */
44 44
     protected $error;
45 45
     
46 46
     /**
@@ -56,25 +56,25 @@  discard block
 block discarded – undo
56 56
         'file'
57 57
     );
58 58
     
59
-   /**
60
-    * Stores a list of all unicode characters in the URL
61
-    * that have been filtered out before parsing it with
62
-    * parse_url.
63
-    * 
64
-    * @var string[]string
65
-    */
59
+    /**
60
+     * Stores a list of all unicode characters in the URL
61
+     * that have been filtered out before parsing it with
62
+     * parse_url.
63
+     * 
64
+     * @var string[]string
65
+     */
66 66
     protected $unicodeChars = array();
67 67
     
68
-   /**
69
-    * @var bool
70
-    */
68
+    /**
69
+     * @var bool
70
+     */
71 71
     protected $encodeUTF = false;
72 72
     
73
-   /**
74
-    * 
75
-    * @param string $url The target URL.
76
-    * @param bool $encodeUTF Whether to URL encode any plain text unicode characters.
77
-    */
73
+    /**
74
+     * 
75
+     * @param string $url The target URL.
76
+     * @param bool $encodeUTF Whether to URL encode any plain text unicode characters.
77
+     */
78 78
     public function __construct(string $url, bool $encodeUTF)
79 79
     {
80 80
         $this->url = $url;
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
         }
88 88
     }
89 89
 
90
-   /**
91
-    * Retrieves the array as parsed by PHP's parse_url,
92
-    * filtered and adjusted as necessary.
93
-    * 
94
-    * @return array
95
-    */
90
+    /**
91
+     * Retrieves the array as parsed by PHP's parse_url,
92
+     * filtered and adjusted as necessary.
93
+     * 
94
+     * @return array
95
+     */
96 96
     public function getInfo() : array
97 97
     {
98 98
         return $this->info;
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
         }
115 115
     }
116 116
     
117
-   /**
118
-    * Finds any non-url encoded unicode characters in 
119
-    * the URL, and encodes them before the URL is 
120
-    * passed to parse_url.
121
-    */
117
+    /**
118
+     * Finds any non-url encoded unicode characters in 
119
+     * the URL, and encodes them before the URL is 
120
+     * passed to parse_url.
121
+     */
122 122
     protected function filterUnicodeChars() : void
123 123
     {
124 124
         $chars = \AppUtils\ConvertHelper::string2array($this->url);
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
         return false;
237 237
     }
238 238
 
239
-   /**
240
-    * Goes through all information in the parse_url result
241
-    * array, and attempts to fix any user errors in formatting
242
-    * that can be recovered from, mostly regarding stray spaces.
243
-    */
239
+    /**
240
+     * Goes through all information in the parse_url result
241
+     * array, and attempts to fix any user errors in formatting
242
+     * that can be recovered from, mostly regarding stray spaces.
243
+     */
244 244
     protected function filterParsed()
245 245
     {
246 246
         $this->info['params'] = array();
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
         }
270 270
     }
271 271
     
272
-   /**
273
-    * Recursively goes through the array, and converts all previously
274
-    * URL encoded characters with their unicode character counterparts.
275
-    * 
276
-    * @param array $subject
277
-    * @return array
278
-    */
272
+    /**
273
+     * Recursively goes through the array, and converts all previously
274
+     * URL encoded characters with their unicode character counterparts.
275
+     * 
276
+     * @param array $subject
277
+     * @return array
278
+     */
279 279
     protected function restoreUnicodeChars(array $subject) : array
280 280
     {
281 281
         $result = array();
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
         return $result;
300 300
     }
301 301
     
302
-   /**
303
-    * Replaces all URL encoded unicode characters
304
-    * in the string with the unicode character.
305
-    * 
306
-    * @param string $string
307
-    * @return string
308
-    */
302
+    /**
303
+     * Replaces all URL encoded unicode characters
304
+     * in the string with the unicode character.
305
+     * 
306
+     * @param string $string
307
+     * @return string
308
+     */
309 309
     protected function restoreUnicodeChar(string $string) : string
310 310
     {
311 311
         if(strstr($string, '%'))
@@ -363,21 +363,21 @@  discard block
 block discarded – undo
363 363
         );
364 364
     }
365 365
    
366
-   /**
367
-    * Checks whether the URL that was parsed is valid.
368
-    * @return bool
369
-    */
366
+    /**
367
+     * Checks whether the URL that was parsed is valid.
368
+     * @return bool
369
+     */
370 370
     public function isValid() : bool
371 371
     {
372 372
         return $this->isValid;
373 373
     }
374 374
 
375
-   /**
376
-    * If the validation failed, retrieves the validation
377
-    * error message.
378
-    * 
379
-    * @return string
380
-    */
375
+    /**
376
+     * If the validation failed, retrieves the validation
377
+     * error message.
378
+     * 
379
+     * @return string
380
+     */
381 381
     public function getErrorMessage() : string
382 382
     {
383 383
         if(isset($this->error)) {
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
         return '';
388 388
     }
389 389
     
390
-   /**
391
-    * If the validation failed, retrieves the validation
392
-    * error code.
393
-    * 
394
-    * @return int
395
-    */
390
+    /**
391
+     * If the validation failed, retrieves the validation
392
+     * error code.
393
+     * 
394
+     * @return int
395
+     */
396 396
     public function getErrorCode() : int
397 397
     {
398 398
         if(isset($this->error)) {
Please login to merge, or discard this patch.
src/ConvertHelper/ControlCharacters.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const ERROR_MALFORMATTED_STRING = 53801;
24 24
     
25
-   /**
26
-    * @var string[]
27
-    */
25
+    /**
26
+     * @var string[]
27
+     */
28 28
     protected static $controlChars =  array(
29 29
         '0000-0008', // control chars
30 30
         '000E-000F', // control chars
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
         '2000-200F', // non-breaking space and co
33 33
     );
34 34
     
35
-   /**
36
-    * @var string|NULL
37
-    */
35
+    /**
36
+     * @var string|NULL
37
+     */
38 38
     protected static $controlCharsRegex;
39 39
 
40
-   /**
41
-    * @var string[]
42
-    */
40
+    /**
41
+     * @var string[]
42
+     */
43 43
     protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
44 44
     
45
-   /**
46
-    * @var string[]|NULL
47
-    */
45
+    /**
46
+     * @var string[]|NULL
47
+     */
48 48
     protected static $charsAsHex;
49 49
     
50 50
     public function __construct()
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
         }
68 68
     }
69 69
     
70
-   /**
71
-    * Retrieves the HEX character codes for all control
72
-    * characters that the {@link stripControlCharacters()}
73
-    * method will remove.
74
-    *
75
-    * @return string[]
76
-    */
70
+    /**
71
+     * Retrieves the HEX character codes for all control
72
+     * characters that the {@link stripControlCharacters()}
73
+     * method will remove.
74
+     *
75
+     * @return string[]
76
+     */
77 77
     public function getCharsAsHex() : array
78 78
     {
79 79
         if (isset(self::$charsAsHex))
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         return $stack;
121 121
     }
122 122
     
123
-   /**
124
-    * Retrieves an array of all control characters that
125
-    * the {@link stripControlCharacters()} method will
126
-    * remove, as the actual UTF-8 characters.
127
-    *
128
-    * @return string[]
129
-    */
123
+    /**
124
+     * Retrieves an array of all control characters that
125
+     * the {@link stripControlCharacters()} method will
126
+     * remove, as the actual UTF-8 characters.
127
+     *
128
+     * @return string[]
129
+     */
130 130
     public function getCharsAsUTF8() : array
131 131
     {
132 132
         $chars = $this->getCharsAsHex();
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         return $result;
140 140
     }
141 141
     
142
-   /**
143
-    * Retrieves all control characters as JSON encoded
144
-    * characters, e.g. "\u200b".
145
-    *
146
-    * @return string[]
147
-    */
142
+    /**
143
+     * Retrieves all control characters as JSON encoded
144
+     * characters, e.g. "\u200b".
145
+     *
146
+     * @return string[]
147
+     */
148 148
     public function getCharsAsJSON() : array
149 149
     {
150 150
         $chars = $this->getCharsAsHex();
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
         return $result;
158 158
     }
159 159
     
160
-   /**
161
-    * Removes all control characters from the specified string
162
-    * that can cause problems in some cases, like creating
163
-    * valid XML documents. This includes invisible non-breaking
164
-    * spaces.
165
-    *
166
-    * @param string $string
167
-    * @return string
168
-    * @see https://stackoverflow.com/a/8171868/2298192
169
-    * @see https://unicode-table.com/en
170
-    */
160
+    /**
161
+     * Removes all control characters from the specified string
162
+     * that can cause problems in some cases, like creating
163
+     * valid XML documents. This includes invisible non-breaking
164
+     * spaces.
165
+     *
166
+     * @param string $string
167
+     * @return string
168
+     * @see https://stackoverflow.com/a/8171868/2298192
169
+     * @see https://unicode-table.com/en
170
+     */
171 171
     public function stripControlCharacters(string $string) : string
172 172
     {
173 173
         if(empty($string)) 
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
         return str_replace("\t", str_repeat(' ', $tabSize), $string);
59 59
     }
60 60
     
61
-   /**
62
-    * Converts spaces to tabs in the specified string.
63
-    * 
64
-    * @param string $string
65
-    * @param int $tabSize The amount of spaces per tab in the source string.
66
-    * @return string
67
-    */
61
+    /**
62
+     * Converts spaces to tabs in the specified string.
63
+     * 
64
+     * @param string $string
65
+     * @param int $tabSize The amount of spaces per tab in the source string.
66
+     * @return string
67
+     */
68 68
     public static function spaces2tabs(string $string, int $tabSize=4) : string
69 69
     {
70 70
         return str_replace(str_repeat(' ', $tabSize), "\t", $string);
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
         return $converter->convert($string);
78 78
     }
79 79
     
80
-   /**
81
-    * Converts the specified amount of seconds into
82
-    * a human readable string split in months, weeks,
83
-    * days, hours, minutes and seconds.
84
-    *
85
-    * @param float $seconds
86
-    * @return string
87
-    */
80
+    /**
81
+     * Converts the specified amount of seconds into
82
+     * a human readable string split in months, weeks,
83
+     * days, hours, minutes and seconds.
84
+     *
85
+     * @param float $seconds
86
+     * @return string
87
+     */
88 88
     public static function time2string($seconds)
89 89
     {
90 90
         static $units = null;
@@ -156,41 +156,41 @@  discard block
 block discarded – undo
156 156
         return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
157 157
     }
158 158
 
159
-   /**
160
-    * Converts a timestamp into an easily understandable
161
-    * format, e.g. "2 hours", "1 day", "3 months"
162
-    *
163
-    * If you set the date to parameter, the difference
164
-    * will be calculated between the two dates and not
165
-    * the current time.
166
-    *
167
-    * @param integer|\DateTime $datefrom
168
-    * @param integer|\DateTime $dateto
169
-    * @return string
170
-    */
159
+    /**
160
+     * Converts a timestamp into an easily understandable
161
+     * format, e.g. "2 hours", "1 day", "3 months"
162
+     *
163
+     * If you set the date to parameter, the difference
164
+     * will be calculated between the two dates and not
165
+     * the current time.
166
+     *
167
+     * @param integer|\DateTime $datefrom
168
+     * @param integer|\DateTime $dateto
169
+     * @return string
170
+     */
171 171
     public static function duration2string($datefrom, $dateto = -1) : string
172 172
     {
173
-         $converter = new ConvertHelper_DurationConverter();
173
+            $converter = new ConvertHelper_DurationConverter();
174 174
          
175
-         if($datefrom instanceof \DateTime)
176
-         {
177
-             $converter->setDateFrom($datefrom);
178
-         }
179
-         else
180
-         {
181
-             $converter->setDateFrom(self::timestamp2date($datefrom)); 
182
-         }
175
+            if($datefrom instanceof \DateTime)
176
+            {
177
+                $converter->setDateFrom($datefrom);
178
+            }
179
+            else
180
+            {
181
+                $converter->setDateFrom(self::timestamp2date($datefrom)); 
182
+            }
183 183
 
184
-         if($dateto instanceof \DateTime)
185
-         {
186
-             $converter->setDateTo($dateto);
187
-         }
188
-         else if($dateto > 0)
189
-         {
190
-             $converter->setDateTo(self::timestamp2date($dateto));
191
-         }
184
+            if($dateto instanceof \DateTime)
185
+            {
186
+                $converter->setDateTo($dateto);
187
+            }
188
+            else if($dateto > 0)
189
+            {
190
+                $converter->setDateTo(self::timestamp2date($dateto));
191
+            }
192 192
 
193
-         return $converter->convert();
193
+            return $converter->convert();
194 194
     }
195 195
 
196 196
     /**
@@ -229,44 +229,44 @@  discard block
 block discarded – undo
229 229
         return $geshi->parse_code();
230 230
     }
231 231
     
232
-   /**
233
-    * Converts a number of bytes to a human readable form,
234
-    * e.g. xx Kb / xx Mb / xx Gb
235
-    *
236
-    * @param int $bytes The amount of bytes to convert.
237
-    * @param int $precision The amount of decimals
238
-    * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
239
-    * @return string
240
-    * 
241
-    * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
242
-    */
232
+    /**
233
+     * Converts a number of bytes to a human readable form,
234
+     * e.g. xx Kb / xx Mb / xx Gb
235
+     *
236
+     * @param int $bytes The amount of bytes to convert.
237
+     * @param int $precision The amount of decimals
238
+     * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
239
+     * @return string
240
+     * 
241
+     * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
242
+     */
243 243
     public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string
244 244
     {
245 245
         return self::parseBytes($bytes)->toString($precision, $base);
246 246
     }
247 247
     
248
-   /**
249
-    * Parses a number of bytes, and creates a converter instance which
250
-    * allows doing common operations with it.
251
-    * 
252
-    * @param int $bytes
253
-    * @return ConvertHelper_ByteConverter
254
-    */
248
+    /**
249
+     * Parses a number of bytes, and creates a converter instance which
250
+     * allows doing common operations with it.
251
+     * 
252
+     * @param int $bytes
253
+     * @return ConvertHelper_ByteConverter
254
+     */
255 255
     public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter
256 256
     {
257 257
         return new ConvertHelper_ByteConverter($bytes);
258 258
     }
259 259
 
260
-   /**
261
-    * Cuts a text to the specified length if it is longer than the
262
-    * target length. Appends a text to signify it has been cut at 
263
-    * the end of the string.
264
-    * 
265
-    * @param string $text
266
-    * @param int $targetLength
267
-    * @param string $append
268
-    * @return string
269
-    */
260
+    /**
261
+     * Cuts a text to the specified length if it is longer than the
262
+     * target length. Appends a text to signify it has been cut at 
263
+     * the end of the string.
264
+     * 
265
+     * @param string $text
266
+     * @param int $targetLength
267
+     * @param string $append
268
+     * @return string
269
+     */
270 270
     public static function text_cut(string $text, int $targetLength, string $append = '...') : string
271 271
     {
272 272
         $length = mb_strlen($text);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
         return $info->toString();
291 291
     }
292 292
     
293
-   /**
294
-    * Pretty print_r.
295
-    * 
296
-    * @param mixed $var The variable to dump.
297
-    * @param bool $return Whether to return the dumped code.
298
-    * @param bool $html Whether to style the dump as HTML.
299
-    * @return string
300
-    */
293
+    /**
294
+     * Pretty print_r.
295
+     * 
296
+     * @param mixed $var The variable to dump.
297
+     * @param bool $return Whether to return the dumped code.
298
+     * @param bool $html Whether to style the dump as HTML.
299
+     * @return string
300
+     */
301 301
     public static function print_r($var, bool $return=false, bool $html=true) : string
302 302
     {
303 303
         $result = parseVariable($var)->enableType()->toString();
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
         'no' => false
328 328
     );
329 329
 
330
-   /**
331
-    * Converts a string, number or boolean value to a boolean value.
332
-    * 
333
-    * @param mixed $string
334
-    * @throws ConvertHelper_Exception
335
-    * @return bool
336
-    * 
337
-    * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
338
-    */
330
+    /**
331
+     * Converts a string, number or boolean value to a boolean value.
332
+     * 
333
+     * @param mixed $string
334
+     * @throws ConvertHelper_Exception
335
+     * @return bool
336
+     * 
337
+     * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
338
+     */
339 339
     public static function string2bool($string) : bool
340 340
     {
341 341
         if($string === '' || $string === null || !is_scalar($string)) 
@@ -363,27 +363,27 @@  discard block
 block discarded – undo
363 363
         );
364 364
     }
365 365
     
366
-   /**
367
-    * Whether the specified string is a boolean string or boolean value.
368
-    * Alias for {@link ConvertHelper::isBoolean()}.
369
-    * 
370
-    * @param mixed $string
371
-    * @return bool
372
-    * @deprecated
373
-    * @see ConvertHelper::isBoolean()
374
-    */
366
+    /**
367
+     * Whether the specified string is a boolean string or boolean value.
368
+     * Alias for {@link ConvertHelper::isBoolean()}.
369
+     * 
370
+     * @param mixed $string
371
+     * @return bool
372
+     * @deprecated
373
+     * @see ConvertHelper::isBoolean()
374
+     */
375 375
     public static function isBooleanString($string) : bool
376 376
     {
377 377
         return self::isBoolean($string);
378 378
     }
379 379
 
380
-   /**
381
-    * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
382
-    * 
383
-    * @param string $text
384
-    * @return string
385
-    * @deprecated
386
-    */
380
+    /**
381
+     * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
382
+     * 
383
+     * @param string $text
384
+     * @return string
385
+     * @deprecated
386
+     */
387 387
     public static function text_makeXMLCompliant($text)
388 388
     {
389 389
         return XMLHelper::string2xml($text);
@@ -485,80 +485,80 @@  discard block
 block discarded – undo
485 485
         return $translit->convert($string);
486 486
     }
487 487
     
488
-   /**
489
-    * Retrieves the HEX character codes for all control
490
-    * characters that the {@link stripControlCharacters()} 
491
-    * method will remove.
492
-    * 
493
-    * @return string[]
494
-    */
488
+    /**
489
+     * Retrieves the HEX character codes for all control
490
+     * characters that the {@link stripControlCharacters()} 
491
+     * method will remove.
492
+     * 
493
+     * @return string[]
494
+     */
495 495
     public static function getControlCharactersAsHex()
496 496
     {
497 497
         return self::createControlCharacters()->getCharsAsHex();
498 498
     }
499 499
     
500
-   /**
501
-    * Retrieves an array of all control characters that
502
-    * the {@link stripControlCharacters()} method will 
503
-    * remove, as the actual UTF-8 characters.
504
-    * 
505
-    * @return string[]
506
-    */
500
+    /**
501
+     * Retrieves an array of all control characters that
502
+     * the {@link stripControlCharacters()} method will 
503
+     * remove, as the actual UTF-8 characters.
504
+     * 
505
+     * @return string[]
506
+     */
507 507
     public static function getControlCharactersAsUTF8()
508 508
     {
509 509
         return self::createControlCharacters()->getCharsAsUTF8();
510 510
     }
511 511
     
512
-   /**
513
-    * Retrieves all control characters as JSON encoded
514
-    * characters, e.g. "\u200b".
515
-    * 
516
-    * @return string[]
517
-    */
512
+    /**
513
+     * Retrieves all control characters as JSON encoded
514
+     * characters, e.g. "\u200b".
515
+     * 
516
+     * @return string[]
517
+     */
518 518
     public static function getControlCharactersAsJSON()
519 519
     {
520 520
         return self::createControlCharacters()->getCharsAsJSON();
521 521
     }
522 522
     
523
-   /**
524
-    * Removes all control characters from the specified string
525
-    * that can cause problems in some cases, like creating
526
-    * valid XML documents. This includes invisible non-breaking
527
-    * spaces.
528
-    *
529
-    * @param string $string
530
-    * @return string
531
-    */
523
+    /**
524
+     * Removes all control characters from the specified string
525
+     * that can cause problems in some cases, like creating
526
+     * valid XML documents. This includes invisible non-breaking
527
+     * spaces.
528
+     *
529
+     * @param string $string
530
+     * @return string
531
+     */
532 532
     public static function stripControlCharacters(string $string) : string
533 533
     {
534 534
         return self::createControlCharacters()->stripControlCharacters($string);
535 535
     }
536 536
     
537
-   /**
538
-    * Creates the control characters class, used to 
539
-    * work with control characters in strings.
540
-    * 
541
-    * @return ConvertHelper_ControlCharacters
542
-    */
537
+    /**
538
+     * Creates the control characters class, used to 
539
+     * work with control characters in strings.
540
+     * 
541
+     * @return ConvertHelper_ControlCharacters
542
+     */
543 543
     public static function createControlCharacters() : ConvertHelper_ControlCharacters
544 544
     {
545 545
         return new ConvertHelper_ControlCharacters();
546 546
     }
547 547
 
548
-   /**
549
-    * Converts a unicode character to the PHPO notation.
550
-    * 
551
-    * Example:
552
-    * 
553
-    * <pre>unicodeChar2php('"\u0000"')</pre>
554
-    * 
555
-    * Returns
556
-    * 
557
-    * <pre>\x0</pre>
558
-    * 
559
-    * @param string $unicodeChar
560
-    * @return string
561
-    */
548
+    /**
549
+     * Converts a unicode character to the PHPO notation.
550
+     * 
551
+     * Example:
552
+     * 
553
+     * <pre>unicodeChar2php('"\u0000"')</pre>
554
+     * 
555
+     * Returns
556
+     * 
557
+     * <pre>\x0</pre>
558
+     * 
559
+     * @param string $unicodeChar
560
+     * @return string
561
+     */
562 562
     public static function unicodeChar2php(string $unicodeChar) : string 
563 563
     {
564 564
         $unicodeChar = json_decode($unicodeChar);
@@ -684,25 +684,25 @@  discard block
 block discarded – undo
684 684
         return 'false';
685 685
     }
686 686
     
687
-   /**
688
-    * Converts an associative array with attribute name > value pairs
689
-    * to an attribute string that can be used in an HTML tag. Empty 
690
-    * attribute values are ignored.
691
-    * 
692
-    * Example:
693
-    * 
694
-    * array2attributeString(array(
695
-    *     'id' => 45,
696
-    *     'href' => 'http://www.mistralys.com'
697
-    * ));
698
-    * 
699
-    * Result:
700
-    * 
701
-    * id="45" href="http://www.mistralys.com"
702
-    * 
703
-    * @param array $array
704
-    * @return string
705
-    */
687
+    /**
688
+     * Converts an associative array with attribute name > value pairs
689
+     * to an attribute string that can be used in an HTML tag. Empty 
690
+     * attribute values are ignored.
691
+     * 
692
+     * Example:
693
+     * 
694
+     * array2attributeString(array(
695
+     *     'id' => 45,
696
+     *     'href' => 'http://www.mistralys.com'
697
+     * ));
698
+     * 
699
+     * Result:
700
+     * 
701
+     * id="45" href="http://www.mistralys.com"
702
+     * 
703
+     * @param array $array
704
+     * @return string
705
+     */
706 706
     public static function array2attributeString($array)
707 707
     {
708 708
         $tokens = array();
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
         return ' '.implode(' ', $tokens);
722 722
     }
723 723
     
724
-   /**
725
-    * Converts a string so it can safely be used in a javascript
726
-    * statement in an HTML tag: uses single quotes around the string
727
-    * and encodes all special characters as needed.
728
-    * 
729
-    * @param string $string
730
-    * @return string
731
-    */
724
+    /**
725
+     * Converts a string so it can safely be used in a javascript
726
+     * statement in an HTML tag: uses single quotes around the string
727
+     * and encodes all special characters as needed.
728
+     * 
729
+     * @param string $string
730
+     * @return string
731
+     */
732 732
     public static function string2attributeJS($string, $quoted=true)
733 733
     {
734 734
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
@@ -739,15 +739,15 @@  discard block
 block discarded – undo
739 739
         return $converted;
740 740
     }
741 741
     
742
-   /**
743
-    * Checks if the specified string is a boolean value, which
744
-    * includes string representations of boolean values, like 
745
-    * <code>yes</code> or <code>no</code>, and <code>true</code>
746
-    * or <code>false</code>.
747
-    * 
748
-    * @param mixed $value
749
-    * @return boolean
750
-    */
742
+    /**
743
+     * Checks if the specified string is a boolean value, which
744
+     * includes string representations of boolean values, like 
745
+     * <code>yes</code> or <code>no</code>, and <code>true</code>
746
+     * or <code>false</code>.
747
+     * 
748
+     * @param mixed $value
749
+     * @return boolean
750
+     */
751 751
     public static function isBoolean($value) : bool
752 752
     {
753 753
         if(is_bool($value)) {
@@ -761,12 +761,12 @@  discard block
 block discarded – undo
761 761
         return array_key_exists($value, self::$booleanStrings);
762 762
     }
763 763
     
764
-   /**
765
-    * Converts an associative array to an HTML style attribute value string.
766
-    * 
767
-    * @param array $subject
768
-    * @return string
769
-    */
764
+    /**
765
+     * Converts an associative array to an HTML style attribute value string.
766
+     * 
767
+     * @param array $subject
768
+     * @return string
769
+     */
770 770
     public static function array2styleString(array $subject) : string
771 771
     {
772 772
         $tokens = array();
@@ -777,23 +777,23 @@  discard block
 block discarded – undo
777 777
         return implode(';', $tokens);
778 778
     }
779 779
     
780
-   /**
781
-    * Converts a DateTime object to a timestamp, which
782
-    * is PHP 5.2 compatible.
783
-    * 
784
-    * @param \DateTime $date
785
-    * @return integer
786
-    */
780
+    /**
781
+     * Converts a DateTime object to a timestamp, which
782
+     * is PHP 5.2 compatible.
783
+     * 
784
+     * @param \DateTime $date
785
+     * @return integer
786
+     */
787 787
     public static function date2timestamp(\DateTime $date) : int
788 788
     {
789 789
         return (int)$date->format('U');
790 790
     }
791 791
     
792
-   /**
793
-    * Converts a timestamp into a DateTime instance.
794
-    * @param int $timestamp
795
-    * @return \DateTime
796
-    */
792
+    /**
793
+     * Converts a timestamp into a DateTime instance.
794
+     * @param int $timestamp
795
+     * @return \DateTime
796
+     */
797 797
     public static function timestamp2date(int $timestamp) : \DateTime
798 798
     {
799 799
         $date = new \DateTime();
@@ -801,50 +801,50 @@  discard block
 block discarded – undo
801 801
         return $date;
802 802
     }
803 803
     
804
-   /**
805
-    * Strips an absolute path to a file within the application
806
-    * to make the path relative to the application root path.
807
-    * 
808
-    * @param string $path
809
-    * @return string
810
-    * 
811
-    * @see FileHelper::relativizePath()
812
-    * @see FileHelper::relativizePathByDepth()
813
-    */
804
+    /**
805
+     * Strips an absolute path to a file within the application
806
+     * to make the path relative to the application root path.
807
+     * 
808
+     * @param string $path
809
+     * @return string
810
+     * 
811
+     * @see FileHelper::relativizePath()
812
+     * @see FileHelper::relativizePathByDepth()
813
+     */
814 814
     public static function fileRelativize(string $path) : string
815 815
     {
816 816
         return FileHelper::relativizePathByDepth($path);
817 817
     }
818 818
     
819 819
     /**
820
-    * Converts a PHP regex to a javascript RegExp object statement.
821
-    * 
822
-    * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
823
-    * More details are available on its usage there.
824
-    *
825
-    * @param string $regex A PHP preg regex
826
-    * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
827
-    * @return array|string Depending on the specified return type.
828
-    * 
829
-    * @see JSHelper::buildRegexStatement()
830
-    */
820
+     * Converts a PHP regex to a javascript RegExp object statement.
821
+     * 
822
+     * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
823
+     * More details are available on its usage there.
824
+     *
825
+     * @param string $regex A PHP preg regex
826
+     * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
827
+     * @return array|string Depending on the specified return type.
828
+     * 
829
+     * @see JSHelper::buildRegexStatement()
830
+     */
831 831
     public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
832 832
     {
833 833
         return JSHelper::buildRegexStatement($regex, $statementType);
834 834
     }
835 835
     
836
-   /**
837
-    * Converts the specified variable to JSON. Works just
838
-    * like the native `json_encode` method, except that it
839
-    * will trigger an exception on failure, which has the 
840
-    * json error details included in its developer details.
841
-    * 
842
-    * @param mixed $variable
843
-    * @param int $options JSON encode options.
844
-    * @param int $depth 
845
-    * @throws ConvertHelper_Exception
846
-    * @return string
847
-    */
836
+    /**
837
+     * Converts the specified variable to JSON. Works just
838
+     * like the native `json_encode` method, except that it
839
+     * will trigger an exception on failure, which has the 
840
+     * json error details included in its developer details.
841
+     * 
842
+     * @param mixed $variable
843
+     * @param int $options JSON encode options.
844
+     * @param int $depth 
845
+     * @throws ConvertHelper_Exception
846
+     * @return string
847
+     */
848 848
     public static function var2json($variable, int $options=0, int $depth=512) : string
849 849
     {
850 850
         $result = json_encode($variable, $options, $depth);
@@ -865,12 +865,12 @@  discard block
 block discarded – undo
865 865
         );
866 866
     }
867 867
     
868
-   /**
869
-    * Strips all known UTF byte order marks from the specified string.
870
-    * 
871
-    * @param string $string
872
-    * @return string
873
-    */
868
+    /**
869
+     * Strips all known UTF byte order marks from the specified string.
870
+     * 
871
+     * @param string $string
872
+     * @return string
873
+     */
874 874
     public static function stripUTFBom($string)
875 875
     {
876 876
         $boms = FileHelper::getUTFBOMs();
@@ -885,13 +885,13 @@  discard block
 block discarded – undo
885 885
         return $string;
886 886
     }
887 887
 
888
-   /**
889
-    * Converts a string to valid utf8, regardless
890
-    * of the string's encoding(s).
891
-    * 
892
-    * @param string $string
893
-    * @return string
894
-    */
888
+    /**
889
+     * Converts a string to valid utf8, regardless
890
+     * of the string's encoding(s).
891
+     * 
892
+     * @param string $string
893
+     * @return string
894
+     */
895 895
     public static function string2utf8($string)
896 896
     {
897 897
         if(!self::isStringASCII($string)) {
@@ -901,15 +901,15 @@  discard block
 block discarded – undo
901 901
         return $string;
902 902
     }
903 903
     
904
-   /**
905
-    * Checks whether the specified string is an ASCII
906
-    * string, without any special or UTF8 characters.
907
-    * Note: empty strings and NULL are considered ASCII.
908
-    * Any variable types other than strings are not.
909
-    * 
910
-    * @param mixed $string
911
-    * @return boolean
912
-    */
904
+    /**
905
+     * Checks whether the specified string is an ASCII
906
+     * string, without any special or UTF8 characters.
907
+     * Note: empty strings and NULL are considered ASCII.
908
+     * Any variable types other than strings are not.
909
+     * 
910
+     * @param mixed $string
911
+     * @return boolean
912
+     */
913 913
     public static function isStringASCII($string) : bool
914 914
     {
915 915
         if($string === '' || $string === NULL) {
@@ -934,22 +934,22 @@  discard block
 block discarded – undo
934 934
         return $url;
935 935
     }
936 936
 
937
-   /**
938
-    * Calculates a percentage match of the source string with the target string.
939
-    * 
940
-    * Options are:
941
-    * 
942
-    * - maxLevenshtein, default: 10
943
-    *   Any levenshtein results above this value are ignored.
944
-    *   
945
-    * - precision, default: 1
946
-    *   The precision of the percentage float value
947
-    * 
948
-    * @param string $source
949
-    * @param string $target
950
-    * @param array $options
951
-    * @return float
952
-    */
937
+    /**
938
+     * Calculates a percentage match of the source string with the target string.
939
+     * 
940
+     * Options are:
941
+     * 
942
+     * - maxLevenshtein, default: 10
943
+     *   Any levenshtein results above this value are ignored.
944
+     *   
945
+     * - precision, default: 1
946
+     *   The precision of the percentage float value
947
+     * 
948
+     * @param string $source
949
+     * @param string $target
950
+     * @param array $options
951
+     * @return float
952
+     */
953 953
     public static function matchString($source, $target, $options=array())
954 954
     {
955 955
         $defaults = array(
@@ -973,14 +973,14 @@  discard block
 block discarded – undo
973 973
         return round(100 - $percent, $options['precision']);
974 974
     }
975 975
     
976
-   /**
977
-    * Converts a date interval to a human readable string with
978
-    * all necessary time components, e.g. "1 year, 2 months and 4 days".
979
-    * 
980
-    * @param \DateInterval $interval
981
-    * @return string
982
-    * @see ConvertHelper_IntervalConverter
983
-    */
976
+    /**
977
+     * Converts a date interval to a human readable string with
978
+     * all necessary time components, e.g. "1 year, 2 months and 4 days".
979
+     * 
980
+     * @param \DateInterval $interval
981
+     * @return string
982
+     * @see ConvertHelper_IntervalConverter
983
+     */
984 984
     public static function interval2string(\DateInterval $interval) : string
985 985
     {
986 986
         $converter = new ConvertHelper_IntervalConverter();
@@ -995,60 +995,60 @@  discard block
 block discarded – undo
995 995
     
996 996
     const INTERVAL_SECONDS = 'seconds';
997 997
     
998
-   /**
999
-    * Converts an interval to its total amount of days.
1000
-    * @param \DateInterval $interval
1001
-    * @return int
1002
-    */
998
+    /**
999
+     * Converts an interval to its total amount of days.
1000
+     * @param \DateInterval $interval
1001
+     * @return int
1002
+     */
1003 1003
     public static function interval2days(\DateInterval $interval) : int
1004 1004
     {
1005 1005
         return self::interval2total($interval, self::INTERVAL_DAYS);
1006 1006
     }
1007 1007
 
1008
-   /**
1009
-    * Converts an interval to its total amount of hours.
1010
-    * @param \DateInterval $interval
1011
-    * @return int
1012
-    */
1008
+    /**
1009
+     * Converts an interval to its total amount of hours.
1010
+     * @param \DateInterval $interval
1011
+     * @return int
1012
+     */
1013 1013
     public static function interval2hours(\DateInterval $interval) : int
1014 1014
     {
1015 1015
         return self::interval2total($interval, self::INTERVAL_HOURS);
1016 1016
     }
1017 1017
     
1018
-   /**
1019
-    * Converts an interval to its total amount of minutes. 
1020
-    * @param \DateInterval $interval
1021
-    * @return int
1022
-    */
1018
+    /**
1019
+     * Converts an interval to its total amount of minutes. 
1020
+     * @param \DateInterval $interval
1021
+     * @return int
1022
+     */
1023 1023
     public static function interval2minutes(\DateInterval $interval) : int
1024 1024
     {
1025 1025
         return self::interval2total($interval, self::INTERVAL_MINUTES);
1026 1026
     }
1027 1027
     
1028
-   /**
1029
-    * Converts an interval to its total amount of seconds.
1030
-    * @param \DateInterval $interval
1031
-    * @return int
1032
-    */    
1028
+    /**
1029
+     * Converts an interval to its total amount of seconds.
1030
+     * @param \DateInterval $interval
1031
+     * @return int
1032
+     */    
1033 1033
     public static function interval2seconds(\DateInterval $interval) : int
1034 1034
     {
1035 1035
         return self::interval2total($interval, self::INTERVAL_SECONDS);
1036 1036
     }
1037 1037
     
1038
-   /**
1039
-    * Calculates the total amount of days / hours / minutes or seconds
1040
-    * of a date interval object (depending in the specified units), and 
1041
-    * returns the total amount.
1042
-    * 
1043
-    * @param \DateInterval $interval
1044
-    * @param string $unit What total value to calculate.
1045
-    * @return integer
1046
-    * 
1047
-    * @see ConvertHelper::INTERVAL_SECONDS
1048
-    * @see ConvertHelper::INTERVAL_MINUTES
1049
-    * @see ConvertHelper::INTERVAL_HOURS
1050
-    * @see ConvertHelper::INTERVAL_DAYS
1051
-    */
1038
+    /**
1039
+     * Calculates the total amount of days / hours / minutes or seconds
1040
+     * of a date interval object (depending in the specified units), and 
1041
+     * returns the total amount.
1042
+     * 
1043
+     * @param \DateInterval $interval
1044
+     * @param string $unit What total value to calculate.
1045
+     * @return integer
1046
+     * 
1047
+     * @see ConvertHelper::INTERVAL_SECONDS
1048
+     * @see ConvertHelper::INTERVAL_MINUTES
1049
+     * @see ConvertHelper::INTERVAL_HOURS
1050
+     * @see ConvertHelper::INTERVAL_DAYS
1051
+     */
1052 1052
     public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
1053 1053
     {
1054 1054
         $total = (int)$interval->format('%a');
@@ -1088,13 +1088,13 @@  discard block
 block discarded – undo
1088 1088
         'Sunday'
1089 1089
     );
1090 1090
     
1091
-   /**
1092
-    * Converts a date to the corresponding day name.
1093
-    * 
1094
-    * @param \DateTime $date
1095
-    * @param bool $short
1096
-    * @return string|NULL
1097
-    */
1091
+    /**
1092
+     * Converts a date to the corresponding day name.
1093
+     * 
1094
+     * @param \DateTime $date
1095
+     * @param bool $short
1096
+     * @return string|NULL
1097
+     */
1098 1098
     public static function date2dayName(\DateTime $date, bool $short=false)
1099 1099
     {
1100 1100
         $day = $date->format('l');
@@ -1109,21 +1109,21 @@  discard block
 block discarded – undo
1109 1109
         return null;
1110 1110
     }
1111 1111
     
1112
-   /**
1113
-    * Retrieves a list of english day names.
1114
-    * @return string[]
1115
-    */
1112
+    /**
1113
+     * Retrieves a list of english day names.
1114
+     * @return string[]
1115
+     */
1116 1116
     public static function getDayNamesInvariant()
1117 1117
     {
1118 1118
         return self::$daysInvariant;
1119 1119
     }
1120 1120
     
1121
-   /**
1122
-    * Retrieves the day names list for the current locale.
1123
-    * 
1124
-    * @param bool $short
1125
-    * @return array
1126
-    */
1121
+    /**
1122
+     * Retrieves the day names list for the current locale.
1123
+     * 
1124
+     * @param bool $short
1125
+     * @return array
1126
+     */
1127 1127
     public static function getDayNames(bool $short=false) : array
1128 1128
     {
1129 1129
         if($short) {
@@ -1183,16 +1183,16 @@  discard block
 block discarded – undo
1183 1183
         return $last;
1184 1184
     }
1185 1185
     
1186
-   /**
1187
-    * Splits a string into an array of all characters it is composed of.
1188
-    * Unicode character safe.
1189
-    * 
1190
-    * NOTE: Spaces and newlines (both \r and \n) are also considered single
1191
-    * characters.
1192
-    * 
1193
-    * @param string $string
1194
-    * @return array
1195
-    */
1186
+    /**
1187
+     * Splits a string into an array of all characters it is composed of.
1188
+     * Unicode character safe.
1189
+     * 
1190
+     * NOTE: Spaces and newlines (both \r and \n) are also considered single
1191
+     * characters.
1192
+     * 
1193
+     * @param string $string
1194
+     * @return array
1195
+     */
1196 1196
     public static function string2array(string $string) : array
1197 1197
     {
1198 1198
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
@@ -1203,12 +1203,12 @@  discard block
 block discarded – undo
1203 1203
         return array();
1204 1204
     }
1205 1205
     
1206
-   /**
1207
-    * Checks whether the specified string contains HTML code.
1208
-    * 
1209
-    * @param string $string
1210
-    * @return boolean
1211
-    */
1206
+    /**
1207
+     * Checks whether the specified string contains HTML code.
1208
+     * 
1209
+     * @param string $string
1210
+     * @return boolean
1211
+     */
1212 1212
     public static function isStringHTML(string $string) : bool
1213 1213
     {
1214 1214
         if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
@@ -1223,17 +1223,17 @@  discard block
 block discarded – undo
1223 1223
         return false;
1224 1224
     }
1225 1225
     
1226
-   /**
1227
-    * UTF8-safe wordwrap method: works like the regular wordwrap
1228
-    * PHP function but compatible with UTF8. Otherwise the lengths
1229
-    * are not calculated correctly.
1230
-    * 
1231
-    * @param string $str
1232
-    * @param int $width
1233
-    * @param string $break
1234
-    * @param bool $cut
1235
-    * @return string
1236
-    */
1226
+    /**
1227
+     * UTF8-safe wordwrap method: works like the regular wordwrap
1228
+     * PHP function but compatible with UTF8. Otherwise the lengths
1229
+     * are not calculated correctly.
1230
+     * 
1231
+     * @param string $str
1232
+     * @param int $width
1233
+     * @param string $break
1234
+     * @param bool $cut
1235
+     * @return string
1236
+     */
1237 1237
     public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string 
1238 1238
     {
1239 1239
         $wrapper = new ConvertHelper_WordWrapper();
@@ -1245,27 +1245,27 @@  discard block
 block discarded – undo
1245 1245
         ->wrapText($str);
1246 1246
     }
1247 1247
     
1248
-   /**
1249
-    * Calculates the byte length of a string, taking into 
1250
-    * account any unicode characters.
1251
-    * 
1252
-    * @param string $string
1253
-    * @return int
1254
-    * @see https://stackoverflow.com/a/9718273/2298192
1255
-    */
1248
+    /**
1249
+     * Calculates the byte length of a string, taking into 
1250
+     * account any unicode characters.
1251
+     * 
1252
+     * @param string $string
1253
+     * @return int
1254
+     * @see https://stackoverflow.com/a/9718273/2298192
1255
+     */
1256 1256
     public static function string2bytes($string)
1257 1257
     {
1258 1258
         return mb_strlen($string, '8bit');
1259 1259
     }
1260 1260
     
1261
-   /**
1262
-    * Creates a short, 8-character long hash for the specified string.
1263
-    * 
1264
-    * WARNING: Not cryptographically safe.
1265
-    * 
1266
-    * @param string $string
1267
-    * @return string
1268
-    */
1261
+    /**
1262
+     * Creates a short, 8-character long hash for the specified string.
1263
+     * 
1264
+     * WARNING: Not cryptographically safe.
1265
+     * 
1266
+     * @param string $string
1267
+     * @return string
1268
+     */
1269 1269
     public static function string2shortHash($string)
1270 1270
     {
1271 1271
         return hash('crc32', $string, false);
@@ -1291,40 +1291,40 @@  discard block
 block discarded – undo
1291 1291
         return ConvertHelper_ThrowableInfo::fromThrowable($e);
1292 1292
     }
1293 1293
     
1294
-   /**
1295
-    * Parses the specified query string like the native 
1296
-    * function <code>parse_str</code>, without the key
1297
-    * naming limitations.
1298
-    * 
1299
-    * Using parse_str, dots or spaces in key names are 
1300
-    * replaced by underscores. This method keeps all names
1301
-    * intact.
1302
-    * 
1303
-    * It still uses the parse_str implementation as it 
1304
-    * is tested and tried, but fixes the parameter names
1305
-    * after parsing, as needed.
1306
-    * 
1307
-    * @param string $queryString
1308
-    * @return array
1309
-    * @see ConvertHelper_QueryParser
1310
-    */
1294
+    /**
1295
+     * Parses the specified query string like the native 
1296
+     * function <code>parse_str</code>, without the key
1297
+     * naming limitations.
1298
+     * 
1299
+     * Using parse_str, dots or spaces in key names are 
1300
+     * replaced by underscores. This method keeps all names
1301
+     * intact.
1302
+     * 
1303
+     * It still uses the parse_str implementation as it 
1304
+     * is tested and tried, but fixes the parameter names
1305
+     * after parsing, as needed.
1306
+     * 
1307
+     * @param string $queryString
1308
+     * @return array
1309
+     * @see ConvertHelper_QueryParser
1310
+     */
1311 1311
     public static function parseQueryString(string $queryString) : array
1312 1312
     {
1313 1313
         $parser = new ConvertHelper_QueryParser();
1314 1314
         return $parser->parse($queryString);
1315 1315
     }
1316 1316
 
1317
-   /**
1318
-    * Searches for needle in the specified string, and returns a list
1319
-    * of all occurrences, including the matched string. The matched 
1320
-    * string is useful when doing a case insensitive search, as it 
1321
-    * shows the exact matched case of needle.
1322
-    *   
1323
-    * @param string $needle
1324
-    * @param string $haystack
1325
-    * @param bool $caseInsensitive
1326
-    * @return ConvertHelper_StringMatch[]
1327
-    */
1317
+    /**
1318
+     * Searches for needle in the specified string, and returns a list
1319
+     * of all occurrences, including the matched string. The matched 
1320
+     * string is useful when doing a case insensitive search, as it 
1321
+     * shows the exact matched case of needle.
1322
+     *   
1323
+     * @param string $needle
1324
+     * @param string $haystack
1325
+     * @param bool $caseInsensitive
1326
+     * @return ConvertHelper_StringMatch[]
1327
+     */
1328 1328
     public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1329 1329
     {
1330 1330
         if($needle === '') {
@@ -1350,14 +1350,14 @@  discard block
 block discarded – undo
1350 1350
         return $positions;
1351 1351
     }
1352 1352
     
1353
-   /**
1354
-    * Like explode, but trims all entries, and removes 
1355
-    * empty entries from the resulting array.
1356
-    * 
1357
-    * @param string $delimiter
1358
-    * @param string $string
1359
-    * @return string[]
1360
-    */
1353
+    /**
1354
+     * Like explode, but trims all entries, and removes 
1355
+     * empty entries from the resulting array.
1356
+     * 
1357
+     * @param string $delimiter
1358
+     * @param string $string
1359
+     * @return string[]
1360
+     */
1361 1361
     public static function explodeTrim(string $delimiter, string $string) : array
1362 1362
     {
1363 1363
         if(empty($string) || empty($delimiter)) {
@@ -1379,12 +1379,12 @@  discard block
 block discarded – undo
1379 1379
     
1380 1380
     protected static $eolChars;
1381 1381
 
1382
-   /**
1383
-    * Detects the most used end-of-line character in the subject string.
1384
-    * 
1385
-    * @param string $subjectString The string to check.
1386
-    * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1387
-    */
1382
+    /**
1383
+     * Detects the most used end-of-line character in the subject string.
1384
+     * 
1385
+     * @param string $subjectString The string to check.
1386
+     * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1387
+     */
1388 1388
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1389 1389
     {
1390 1390
         if(empty($subjectString)) {
@@ -1396,27 +1396,27 @@  discard block
 block discarded – undo
1396 1396
             $cr = chr((int)hexdec('0d'));
1397 1397
             $lf = chr((int)hexdec('0a'));
1398 1398
             
1399
-           self::$eolChars = array(
1400
-               array(
1401
-                   'char' => $cr.$lf,
1402
-                   'type' => ConvertHelper_EOL::TYPE_CRLF,
1403
-                   'description' => t('Carriage return followed by a line feed'),
1404
-               ),
1405
-               array(
1406
-                   'char' => $lf.$cr,
1407
-                   'type' => ConvertHelper_EOL::TYPE_LFCR,
1408
-                   'description' => t('Line feed followed by a carriage return'),
1409
-               ),
1410
-               array(
1411
-                  'char' => $lf,
1412
-                  'type' => ConvertHelper_EOL::TYPE_LF,
1413
-                  'description' => t('Line feed'),
1414
-               ),
1415
-               array(
1416
-                  'char' => $cr,
1417
-                  'type' => ConvertHelper_EOL::TYPE_CR,
1418
-                  'description' => t('Carriage Return'),
1419
-               ),
1399
+            self::$eolChars = array(
1400
+                array(
1401
+                    'char' => $cr.$lf,
1402
+                    'type' => ConvertHelper_EOL::TYPE_CRLF,
1403
+                    'description' => t('Carriage return followed by a line feed'),
1404
+                ),
1405
+                array(
1406
+                    'char' => $lf.$cr,
1407
+                    'type' => ConvertHelper_EOL::TYPE_LFCR,
1408
+                    'description' => t('Line feed followed by a carriage return'),
1409
+                ),
1410
+                array(
1411
+                    'char' => $lf,
1412
+                    'type' => ConvertHelper_EOL::TYPE_LF,
1413
+                    'description' => t('Line feed'),
1414
+                ),
1415
+                array(
1416
+                    'char' => $cr,
1417
+                    'type' => ConvertHelper_EOL::TYPE_CR,
1418
+                    'description' => t('Carriage Return'),
1419
+                ),
1420 1420
             );
1421 1421
         }
1422 1422
         
@@ -1444,13 +1444,13 @@  discard block
 block discarded – undo
1444 1444
         );
1445 1445
     }
1446 1446
 
1447
-   /**
1448
-    * Removes the specified keys from the target array,
1449
-    * if they exist.
1450
-    * 
1451
-    * @param array $array
1452
-    * @param array $keys
1453
-    */
1447
+    /**
1448
+     * Removes the specified keys from the target array,
1449
+     * if they exist.
1450
+     * 
1451
+     * @param array $array
1452
+     * @param array $keys
1453
+     */
1454 1454
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1455 1455
     {
1456 1456
         foreach($keys as $key) 
@@ -1461,13 +1461,13 @@  discard block
 block discarded – undo
1461 1461
         }
1462 1462
     }
1463 1463
     
1464
-   /**
1465
-    * Checks if the specified variable is an integer or a string containing an integer.
1466
-    * Accepts both positive and negative integers.
1467
-    * 
1468
-    * @param mixed $value
1469
-    * @return bool
1470
-    */
1464
+    /**
1465
+     * Checks if the specified variable is an integer or a string containing an integer.
1466
+     * Accepts both positive and negative integers.
1467
+     * 
1468
+     * @param mixed $value
1469
+     * @return bool
1470
+     */
1471 1471
     public static function isInteger($value) : bool
1472 1472
     {
1473 1473
         if(is_int($value)) {
@@ -1487,40 +1487,40 @@  discard block
 block discarded – undo
1487 1487
         return false;    
1488 1488
     }
1489 1489
     
1490
-   /**
1491
-    * Converts an amount of seconds to a DateInterval object.
1492
-    * 
1493
-    * @param int $seconds
1494
-    * @return \DateInterval
1495
-    * @throws ConvertHelper_Exception If the date interval cannot be created.
1496
-    * 
1497
-    * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1498
-    */
1490
+    /**
1491
+     * Converts an amount of seconds to a DateInterval object.
1492
+     * 
1493
+     * @param int $seconds
1494
+     * @return \DateInterval
1495
+     * @throws ConvertHelper_Exception If the date interval cannot be created.
1496
+     * 
1497
+     * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1498
+     */
1499 1499
     public static function seconds2interval(int $seconds) : \DateInterval
1500 1500
     {
1501 1501
         return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval();
1502 1502
     }
1503 1503
     
1504
-   /**
1505
-    * Converts a size string like "50 MB" to the corresponding byte size.
1506
-    * It is case insensitive, ignores spaces, and supports both traditional
1507
-    * "MB" and "MiB" notations.
1508
-    * 
1509
-    * @param string $size
1510
-    * @return int
1511
-    */
1504
+    /**
1505
+     * Converts a size string like "50 MB" to the corresponding byte size.
1506
+     * It is case insensitive, ignores spaces, and supports both traditional
1507
+     * "MB" and "MiB" notations.
1508
+     * 
1509
+     * @param string $size
1510
+     * @return int
1511
+     */
1512 1512
     public static function size2bytes(string $size) : int
1513 1513
     {
1514 1514
         return self::parseSize($size)->toBytes();
1515 1515
     }
1516 1516
     
1517
-   /**
1518
-    * Parses a size string like "50 MB" and returns a size notation instance
1519
-    * that has utility methods to access information on it, and convert it.
1520
-    * 
1521
-    * @param string $size
1522
-    * @return ConvertHelper_SizeNotation
1523
-    */
1517
+    /**
1518
+     * Parses a size string like "50 MB" and returns a size notation instance
1519
+     * that has utility methods to access information on it, and convert it.
1520
+     * 
1521
+     * @param string $size
1522
+     * @return ConvertHelper_SizeNotation
1523
+     */
1524 1524
     public static function parseSize(string $size) : ConvertHelper_SizeNotation
1525 1525
     {
1526 1526
         return new ConvertHelper_SizeNotation($size);
Please login to merge, or discard this patch.
src/RequestHelper/Boundaries.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
 {
23 23
     const ERROR_NO_BOUNDARIES_SPECIFIED = 44401;
24 24
     
25
-   /**
26
-    * @var RequestHelper
27
-    */
25
+    /**
26
+     * @var RequestHelper
27
+     */
28 28
     protected $helper;
29 29
 
30
-   /**
31
-    * @var RequestHelper_Boundaries_Boundary[]
32
-    */
30
+    /**
31
+     * @var RequestHelper_Boundaries_Boundary[]
32
+     */
33 33
     protected $boundaries = array();
34 34
     
35
-   /**
36
-    * @var integer
37
-    */
35
+    /**
36
+     * @var integer
37
+     */
38 38
     protected $contentLength = 0;
39 39
     
40 40
     public function __construct(RequestHelper $helper)
@@ -42,31 +42,31 @@  discard block
 block discarded – undo
42 42
         $this->helper = $helper;
43 43
     }
44 44
     
45
-   /**
46
-    * Retrieves the string that is used to separate mime boundaries in the body.
47
-    * 
48
-    * @return string
49
-    */
45
+    /**
46
+     * Retrieves the string that is used to separate mime boundaries in the body.
47
+     * 
48
+     * @return string
49
+     */
50 50
     public function getMimeBoundary() : string
51 51
     {
52 52
         return $this->helper->getMimeBoundary();
53 53
     }
54 54
     
55
-   /**
56
-    * Retrieves the end of line character(s) used in the body.
57
-    * 
58
-    * @return string
59
-    */
55
+    /**
56
+     * Retrieves the end of line character(s) used in the body.
57
+     * 
58
+     * @return string
59
+     */
60 60
     public function getEOL() : string
61 61
     {
62 62
         return $this->helper->getEOL();
63 63
     }
64 64
     
65
-   /**
66
-    * Retrieves the total content length of all boundary contents.
67
-    * 
68
-    * @return int
69
-    */
65
+    /**
66
+     * Retrieves the total content length of all boundary contents.
67
+     * 
68
+     * @return int
69
+     */
70 70
     public function getContentLength() : int
71 71
     {
72 72
         // this must use strlen, and not mb_strlen: the content length
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
         return strlen($this->render());
76 76
     }
77 77
     
78
-   /**
79
-    * Adds a file to be sent with the request.
80
-    *
81
-    * @param string $varName The variable name to send the file in
82
-    * @param string $fileName The name of the file as it should be received at the destination
83
-    * @param string $content The raw content of the file
84
-    * @param string $contentType The content type, use the constants to specify this
85
-    * @param string $encoding The encoding of the file, use the constants to specify this
86
-    */
78
+    /**
79
+     * Adds a file to be sent with the request.
80
+     *
81
+     * @param string $varName The variable name to send the file in
82
+     * @param string $fileName The name of the file as it should be received at the destination
83
+     * @param string $content The raw content of the file
84
+     * @param string $contentType The content type, use the constants to specify this
85
+     * @param string $encoding The encoding of the file, use the constants to specify this
86
+     */
87 87
     public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper_Boundaries
88 88
     {
89 89
         if(empty($contentType))
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
         return $this->addBoundary($boundary);
108 108
     }
109 109
     
110
-   /**
111
-    * Adds arbitrary content.
112
-    *
113
-    * @param string $varName
114
-    * @param string $content
115
-    * @param string $contentType
116
-    */
110
+    /**
111
+     * Adds arbitrary content.
112
+     *
113
+     * @param string $varName
114
+     * @param string $content
115
+     * @param string $contentType
116
+     */
117 117
     public function addContent(string $varName, string $content, string $contentType) : RequestHelper_Boundaries
118 118
     {
119 119
         $content = ConvertHelper::string2utf8($content);
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
         return $this->addBoundary($boundary);
128 128
     }
129 129
     
130
-   /**
131
-    * Adds a variable to be sent with the request. If it
132
-    * already exists, its value is overwritten.
133
-    *
134
-    * @param string $name
135
-    * @param string $value
136
-    */
130
+    /**
131
+     * Adds a variable to be sent with the request. If it
132
+     * already exists, its value is overwritten.
133
+     *
134
+     * @param string $name
135
+     * @param string $value
136
+     */
137 137
     public function addVariable(string $name, string $value) : RequestHelper_Boundaries
138 138
     {
139 139
         $boundary = $this->createBoundary($value)
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
         return $this;
150 150
     }
151 151
     
152
-   /**
153
-    * Renders the response body with all mime boundaries.
154
-    * 
155
-    * @return string
156
-    */
152
+    /**
153
+     * Renders the response body with all mime boundaries.
154
+     * 
155
+     * @return string
156
+     */
157 157
     public function render() : string
158 158
     {
159 159
         if(empty($this->boundaries)) 
Please login to merge, or discard this patch.