@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | use Traits_Optionable; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var URLInfo |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var URLInfo |
|
| 27 | + */ |
|
| 28 | 28 | private $url; |
| 29 | 29 | |
| 30 | 30 | public function __construct(URLInfo $url) |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Whether to verify the host's SSL certificate, in |
|
| 46 | - * case of an https connection. |
|
| 47 | - * |
|
| 48 | - * @param bool $verifySSL |
|
| 49 | - * @return URLInfo_ConnectionTester |
|
| 50 | - */ |
|
| 44 | + /** |
|
| 45 | + * Whether to verify the host's SSL certificate, in |
|
| 46 | + * case of an https connection. |
|
| 47 | + * |
|
| 48 | + * @param bool $verifySSL |
|
| 49 | + * @return URLInfo_ConnectionTester |
|
| 50 | + */ |
|
| 51 | 51 | public function setVerifySSL(bool $verifySSL=true) : URLInfo_ConnectionTester |
| 52 | 52 | { |
| 53 | 53 | $this->setOption('verify-ssl', $verifySSL); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | return $this->getIntOption('timeout'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Initializes the CURL instance. |
|
| 86 | - * |
|
| 87 | - * @throws BaseException |
|
| 88 | - * @return resource |
|
| 89 | - */ |
|
| 84 | + /** |
|
| 85 | + * Initializes the CURL instance. |
|
| 86 | + * |
|
| 87 | + * @throws BaseException |
|
| 88 | + * @return resource |
|
| 89 | + */ |
|
| 90 | 90 | private function initCURL() |
| 91 | 91 | { |
| 92 | 92 | $ch = curl_init(); |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | return $ch; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @param resource $ch |
|
| 108 | - */ |
|
| 106 | + /** |
|
| 107 | + * @param resource $ch |
|
| 108 | + */ |
|
| 109 | 109 | private function configureOptions($ch) : void |
| 110 | 110 | { |
| 111 | 111 | if($this->isVerboseModeEnabled()) |
@@ -110,38 +110,38 @@ discard block |
||
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 115 | - * |
|
| 116 | - * @param bool $enabled |
|
| 117 | - * @return $this |
|
| 118 | - */ |
|
| 113 | + /** |
|
| 114 | + * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 115 | + * |
|
| 116 | + * @param bool $enabled |
|
| 117 | + * @return $this |
|
| 118 | + */ |
|
| 119 | 119 | public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
| 120 | 120 | { |
| 121 | 121 | $this->setOption('sorting', $enabled); |
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Whether to include email addresses in the search. |
|
| 127 | - * This is only relevant when using the getURLs() |
|
| 128 | - * method. |
|
| 129 | - * |
|
| 130 | - * @param bool $include |
|
| 131 | - * @return ConvertHelper_URLFinder |
|
| 132 | - */ |
|
| 125 | + /** |
|
| 126 | + * Whether to include email addresses in the search. |
|
| 127 | + * This is only relevant when using the getURLs() |
|
| 128 | + * method. |
|
| 129 | + * |
|
| 130 | + * @param bool $include |
|
| 131 | + * @return ConvertHelper_URLFinder |
|
| 132 | + */ |
|
| 133 | 133 | public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
| 134 | 134 | { |
| 135 | 135 | $this->setOption('include-emails', $include); |
| 136 | 136 | return $this; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 141 | - * |
|
| 142 | - * @param bool $omit |
|
| 143 | - * @return ConvertHelper_URLFinder |
|
| 144 | - */ |
|
| 139 | + /** |
|
| 140 | + * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 141 | + * |
|
| 142 | + * @param bool $omit |
|
| 143 | + * @return ConvertHelper_URLFinder |
|
| 144 | + */ |
|
| 145 | 145 | public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
| 146 | 146 | { |
| 147 | 147 | $this->setOption('omit-mailto', $omit); |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Fetches all URLs that can be found in the subject string. |
|
| 272 | - * |
|
| 273 | - * @return string[] |
|
| 274 | - */ |
|
| 270 | + /** |
|
| 271 | + * Fetches all URLs that can be found in the subject string. |
|
| 272 | + * |
|
| 273 | + * @return string[] |
|
| 274 | + */ |
|
| 275 | 275 | public function getURLs() : array |
| 276 | 276 | { |
| 277 | 277 | $this->parse(); |
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | return array_pop($parts); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - /** |
|
| 478 | - * Retrieves all email addresses from the subject string. |
|
| 479 | - * |
|
| 480 | - * @return string[] |
|
| 481 | - * |
|
| 482 | - * @see omitMailto() |
|
| 483 | - */ |
|
| 477 | + /** |
|
| 478 | + * Retrieves all email addresses from the subject string. |
|
| 479 | + * |
|
| 480 | + * @return string[] |
|
| 481 | + * |
|
| 482 | + * @see omitMailto() |
|
| 483 | + */ |
|
| 484 | 484 | public function getEmails() : array |
| 485 | 485 | { |
| 486 | 486 | $this->parse(); |
@@ -506,11 +506,11 @@ discard block |
||
| 506 | 506 | return $result; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - /** |
|
| 510 | - * Retrieves all URLs as URLInfo instances. |
|
| 511 | - * |
|
| 512 | - * @return URLInfo[] |
|
| 513 | - */ |
|
| 509 | + /** |
|
| 510 | + * Retrieves all URLs as URLInfo instances. |
|
| 511 | + * |
|
| 512 | + * @return URLInfo[] |
|
| 513 | + */ |
|
| 514 | 514 | public function getInfos() : array |
| 515 | 515 | { |
| 516 | 516 | $this->parse(); |
@@ -23,24 +23,24 @@ discard block |
||
| 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 | /** |
@@ -57,25 +57,25 @@ discard block |
||
| 57 | 57 | 'git' |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Stores a list of all unicode characters in the URL |
|
| 62 | - * that have been filtered out before parsing it with |
|
| 63 | - * parse_url. |
|
| 64 | - * |
|
| 65 | - * @var string[]string |
|
| 66 | - */ |
|
| 60 | + /** |
|
| 61 | + * Stores a list of all unicode characters in the URL |
|
| 62 | + * that have been filtered out before parsing it with |
|
| 63 | + * parse_url. |
|
| 64 | + * |
|
| 65 | + * @var string[]string |
|
| 66 | + */ |
|
| 67 | 67 | protected $unicodeChars = array(); |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var bool |
|
| 71 | - */ |
|
| 69 | + /** |
|
| 70 | + * @var bool |
|
| 71 | + */ |
|
| 72 | 72 | protected $encodeUTF = false; |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * |
|
| 76 | - * @param string $url The target URL. |
|
| 77 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 78 | - */ |
|
| 74 | + /** |
|
| 75 | + * |
|
| 76 | + * @param string $url The target URL. |
|
| 77 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 78 | + */ |
|
| 79 | 79 | public function __construct(string $url, bool $encodeUTF) |
| 80 | 80 | { |
| 81 | 81 | $this->url = $url; |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Retrieves the array as parsed by PHP's parse_url, |
|
| 93 | - * filtered and adjusted as necessary. |
|
| 94 | - * |
|
| 95 | - * @return array |
|
| 96 | - */ |
|
| 91 | + /** |
|
| 92 | + * Retrieves the array as parsed by PHP's parse_url, |
|
| 93 | + * filtered and adjusted as necessary. |
|
| 94 | + * |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | 97 | public function getInfo() : array |
| 98 | 98 | { |
| 99 | 99 | return $this->info; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Finds any non-url encoded unicode characters in |
|
| 120 | - * the URL, and encodes them before the URL is |
|
| 121 | - * passed to parse_url. |
|
| 122 | - */ |
|
| 118 | + /** |
|
| 119 | + * Finds any non-url encoded unicode characters in |
|
| 120 | + * the URL, and encodes them before the URL is |
|
| 121 | + * passed to parse_url. |
|
| 122 | + */ |
|
| 123 | 123 | protected function filterUnicodeChars() : void |
| 124 | 124 | { |
| 125 | 125 | $chars = ConvertHelper::string2array($this->url); |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Goes through all information in the parse_url result |
|
| 243 | - * array, and attempts to fix any user errors in formatting |
|
| 244 | - * that can be recovered from, mostly regarding stray spaces. |
|
| 245 | - */ |
|
| 241 | + /** |
|
| 242 | + * Goes through all information in the parse_url result |
|
| 243 | + * array, and attempts to fix any user errors in formatting |
|
| 244 | + * that can be recovered from, mostly regarding stray spaces. |
|
| 245 | + */ |
|
| 246 | 246 | protected function filterParsed() : void |
| 247 | 247 | { |
| 248 | 248 | $this->info['params'] = array(); |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * Recursively goes through the array, and converts all previously |
|
| 289 | - * URL encoded characters with their unicode character counterparts. |
|
| 290 | - * |
|
| 291 | - * @param array $subject |
|
| 292 | - * @return array |
|
| 293 | - */ |
|
| 287 | + /** |
|
| 288 | + * Recursively goes through the array, and converts all previously |
|
| 289 | + * URL encoded characters with their unicode character counterparts. |
|
| 290 | + * |
|
| 291 | + * @param array $subject |
|
| 292 | + * @return array |
|
| 293 | + */ |
|
| 294 | 294 | protected function restoreUnicodeChars(array $subject) : array |
| 295 | 295 | { |
| 296 | 296 | $result = array(); |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | return $result; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Replaces all URL encoded unicode characters |
|
| 319 | - * in the string with the unicode character. |
|
| 320 | - * |
|
| 321 | - * @param string $string |
|
| 322 | - * @return string |
|
| 323 | - */ |
|
| 317 | + /** |
|
| 318 | + * Replaces all URL encoded unicode characters |
|
| 319 | + * in the string with the unicode character. |
|
| 320 | + * |
|
| 321 | + * @param string $string |
|
| 322 | + * @return string |
|
| 323 | + */ |
|
| 324 | 324 | protected function restoreUnicodeChar(string $string) : string |
| 325 | 325 | { |
| 326 | 326 | if(strstr($string, '%')) |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | ); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Checks whether the URL that was parsed is valid. |
|
| 409 | - * @return bool |
|
| 410 | - */ |
|
| 407 | + /** |
|
| 408 | + * Checks whether the URL that was parsed is valid. |
|
| 409 | + * @return bool |
|
| 410 | + */ |
|
| 411 | 411 | public function isValid() : bool |
| 412 | 412 | { |
| 413 | 413 | return $this->isValid; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * If the validation failed, retrieves the validation |
|
| 418 | - * error message. |
|
| 419 | - * |
|
| 420 | - * @return string |
|
| 421 | - */ |
|
| 416 | + /** |
|
| 417 | + * If the validation failed, retrieves the validation |
|
| 418 | + * error message. |
|
| 419 | + * |
|
| 420 | + * @return string |
|
| 421 | + */ |
|
| 422 | 422 | public function getErrorMessage() : string |
| 423 | 423 | { |
| 424 | 424 | if(isset($this->error)) { |
@@ -428,12 +428,12 @@ discard block |
||
| 428 | 428 | return ''; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - /** |
|
| 432 | - * If the validation failed, retrieves the validation |
|
| 433 | - * error code. |
|
| 434 | - * |
|
| 435 | - * @return int |
|
| 436 | - */ |
|
| 431 | + /** |
|
| 432 | + * If the validation failed, retrieves the validation |
|
| 433 | + * error code. |
|
| 434 | + * |
|
| 435 | + * @return int |
|
| 436 | + */ |
|
| 437 | 437 | public function getErrorCode() : int |
| 438 | 438 | { |
| 439 | 439 | if(isset($this->error)) { |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - function render() : string; |
|
| 28 | + function render() : string; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Renders the string and echos it. |
| 32 | 32 | */ |
| 33 | - function display() : void; |
|
| 33 | + function display() : void; |
|
| 34 | 34 | } |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class BaseException extends \Exception |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $details; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param string $message |
|
| 32 | - * @param string $details |
|
| 33 | - * @param int $code |
|
| 34 | - * @param \Exception $previous |
|
| 35 | - */ |
|
| 30 | + /** |
|
| 31 | + * @param string $message |
|
| 32 | + * @param string $details |
|
| 33 | + * @param int $code |
|
| 34 | + * @param \Exception $previous |
|
| 35 | + */ |
|
| 36 | 36 | public function __construct(string $message, $details=null, $code=null, $previous=null) |
| 37 | 37 | { |
| 38 | 38 | parent::__construct($message, $code, $previous); |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | $this->details = $details; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Retrieves the detailed error description, if any. |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 43 | + /** |
|
| 44 | + * Retrieves the detailed error description, if any. |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | 47 | public function getDetails() : string |
| 48 | 48 | { |
| 49 | 49 | if($this->details !== null) { |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | return ''; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Displays pertinent information on the exception. |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * Displays pertinent information on the exception. |
|
| 58 | + */ |
|
| 59 | 59 | public function display() : void |
| 60 | 60 | { |
| 61 | 61 | if(!headers_sent()) { |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | echo $this->getInfo(); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Retrieves information on the exception that can be |
|
| 70 | - * easily accessed. |
|
| 71 | - * |
|
| 72 | - * @return ConvertHelper_ThrowableInfo |
|
| 73 | - */ |
|
| 68 | + /** |
|
| 69 | + * Retrieves information on the exception that can be |
|
| 70 | + * easily accessed. |
|
| 71 | + * |
|
| 72 | + * @return ConvertHelper_ThrowableInfo |
|
| 73 | + */ |
|
| 74 | 74 | public function getInfo() : ConvertHelper_ThrowableInfo |
| 75 | 75 | { |
| 76 | 76 | return ConvertHelper::throwable2info($this); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Dumps a current PHP function trace, as a text only string. |
|
| 81 | - */ |
|
| 79 | + /** |
|
| 80 | + * Dumps a current PHP function trace, as a text only string. |
|
| 81 | + */ |
|
| 82 | 82 | public static function dumpTraceAsString() : void |
| 83 | 83 | { |
| 84 | 84 | try |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Dumps a current PHP function trace, with HTML styling. |
|
| 96 | - */ |
|
| 94 | + /** |
|
| 95 | + * Dumps a current PHP function trace, with HTML styling. |
|
| 96 | + */ |
|
| 97 | 97 | public static function dumpTraceAsHTML() : void |
| 98 | 98 | { |
| 99 | 99 | try |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Creates an exception info instance from a throwable instance. |
|
| 113 | - * |
|
| 114 | - * @param Throwable $e |
|
| 115 | - * @return ConvertHelper_ThrowableInfo |
|
| 116 | - * @see ConvertHelper::throwable2info() |
|
| 117 | - */ |
|
| 111 | + /** |
|
| 112 | + * Creates an exception info instance from a throwable instance. |
|
| 113 | + * |
|
| 114 | + * @param Throwable $e |
|
| 115 | + * @return ConvertHelper_ThrowableInfo |
|
| 116 | + * @see ConvertHelper::throwable2info() |
|
| 117 | + */ |
|
| 118 | 118 | public static function createInfo(Throwable $e) : ConvertHelper_ThrowableInfo |
| 119 | 119 | { |
| 120 | 120 | return ConvertHelper::throwable2info($e); |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | return ConvertHelper_String::tabs2spaces($string, $tabSize); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Converts spaces to tabs in the specified string. |
|
| 65 | - * |
|
| 66 | - * @param string $string |
|
| 67 | - * @param int $tabSize The amount of spaces per tab in the source string. |
|
| 68 | - * @return string |
|
| 69 | - */ |
|
| 63 | + /** |
|
| 64 | + * Converts spaces to tabs in the specified string. |
|
| 65 | + * |
|
| 66 | + * @param string $string |
|
| 67 | + * @param int $tabSize The amount of spaces per tab in the source string. |
|
| 68 | + * @return string |
|
| 69 | + */ |
|
| 70 | 70 | public static function spaces2tabs(string $string, int $tabSize=4) : string |
| 71 | 71 | { |
| 72 | 72 | return ConvertHelper_String::spaces2tabs($string, $tabSize); |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | return ConvertHelper_String::hidden2visible($string); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Converts the specified amount of seconds into |
|
| 89 | - * a human-readable string split in months, weeks, |
|
| 90 | - * days, hours, minutes and seconds. |
|
| 91 | - * |
|
| 92 | - * @param float $seconds |
|
| 93 | - * @return string |
|
| 94 | - */ |
|
| 87 | + /** |
|
| 88 | + * Converts the specified amount of seconds into |
|
| 89 | + * a human-readable string split in months, weeks, |
|
| 90 | + * days, hours, minutes and seconds. |
|
| 91 | + * |
|
| 92 | + * @param float $seconds |
|
| 93 | + * @return string |
|
| 94 | + */ |
|
| 95 | 95 | public static function time2string($seconds) : string |
| 96 | 96 | { |
| 97 | 97 | $converter = new ConvertHelper_TimeConverter($seconds); |
@@ -115,85 +115,85 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public static function duration2string($datefrom, $dateto = -1) : string |
| 117 | 117 | { |
| 118 | - return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
| 118 | + return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
| 123 | - * |
|
| 124 | - * @param string $sql |
|
| 125 | - * @return string |
|
| 126 | - * @deprecated Use the Highlighter class directly instead. |
|
| 127 | - * @see Highlighter::sql() |
|
| 128 | - */ |
|
| 121 | + /** |
|
| 122 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
| 123 | + * |
|
| 124 | + * @param string $sql |
|
| 125 | + * @return string |
|
| 126 | + * @deprecated Use the Highlighter class directly instead. |
|
| 127 | + * @see Highlighter::sql() |
|
| 128 | + */ |
|
| 129 | 129 | public static function highlight_sql(string $sql) : string |
| 130 | 130 | { |
| 131 | 131 | return Highlighter::sql($sql); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Adds HTML syntax highlighting to the specified XML code. |
|
| 136 | - * |
|
| 137 | - * @param string $xml The XML to highlight. |
|
| 138 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
| 139 | - * @return string |
|
| 140 | - * @deprecated Use the Highlighter class directly instead. |
|
| 141 | - * @see Highlighter::xml() |
|
| 142 | - */ |
|
| 134 | + /** |
|
| 135 | + * Adds HTML syntax highlighting to the specified XML code. |
|
| 136 | + * |
|
| 137 | + * @param string $xml The XML to highlight. |
|
| 138 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
| 139 | + * @return string |
|
| 140 | + * @deprecated Use the Highlighter class directly instead. |
|
| 141 | + * @see Highlighter::xml() |
|
| 142 | + */ |
|
| 143 | 143 | public static function highlight_xml(string $xml, bool $formatSource=false) : string |
| 144 | 144 | { |
| 145 | 145 | return Highlighter::xml($xml, $formatSource); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * @param string $phpCode |
|
| 150 | - * @return string |
|
| 151 | - * @deprecated Use the Highlighter class directly instead. |
|
| 152 | - * @see Highlighter::php() |
|
| 153 | - */ |
|
| 148 | + /** |
|
| 149 | + * @param string $phpCode |
|
| 150 | + * @return string |
|
| 151 | + * @deprecated Use the Highlighter class directly instead. |
|
| 152 | + * @see Highlighter::php() |
|
| 153 | + */ |
|
| 154 | 154 | public static function highlight_php(string $phpCode) : string |
| 155 | 155 | { |
| 156 | 156 | return Highlighter::php($phpCode); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Converts a number of bytes to a human-readable form, |
|
| 161 | - * e.g. xx Kb / xx Mb / xx Gb |
|
| 162 | - * |
|
| 163 | - * @param int $bytes The amount of bytes to convert. |
|
| 164 | - * @param int $precision The amount of decimals |
|
| 165 | - * @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). |
|
| 166 | - * @return string |
|
| 167 | - * |
|
| 168 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
| 169 | - */ |
|
| 159 | + /** |
|
| 160 | + * Converts a number of bytes to a human-readable form, |
|
| 161 | + * e.g. xx Kb / xx Mb / xx Gb |
|
| 162 | + * |
|
| 163 | + * @param int $bytes The amount of bytes to convert. |
|
| 164 | + * @param int $precision The amount of decimals |
|
| 165 | + * @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). |
|
| 166 | + * @return string |
|
| 167 | + * |
|
| 168 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
| 169 | + */ |
|
| 170 | 170 | public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string |
| 171 | 171 | { |
| 172 | 172 | return self::parseBytes($bytes)->toString($precision, $base); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Parses a number of bytes, and creates a converter instance which |
|
| 177 | - * allows doing common operations with it. |
|
| 178 | - * |
|
| 179 | - * @param int $bytes |
|
| 180 | - * @return ConvertHelper_ByteConverter |
|
| 181 | - */ |
|
| 175 | + /** |
|
| 176 | + * Parses a number of bytes, and creates a converter instance which |
|
| 177 | + * allows doing common operations with it. |
|
| 178 | + * |
|
| 179 | + * @param int $bytes |
|
| 180 | + * @return ConvertHelper_ByteConverter |
|
| 181 | + */ |
|
| 182 | 182 | public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter |
| 183 | 183 | { |
| 184 | 184 | return new ConvertHelper_ByteConverter($bytes); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * Cuts a text to the specified length if it is longer than the |
|
| 189 | - * target length. Appends a text to signify it has been cut at |
|
| 190 | - * the end of the string. |
|
| 191 | - * |
|
| 192 | - * @param string $text |
|
| 193 | - * @param int $targetLength |
|
| 194 | - * @param string $append |
|
| 195 | - * @return string |
|
| 196 | - */ |
|
| 187 | + /** |
|
| 188 | + * Cuts a text to the specified length if it is longer than the |
|
| 189 | + * target length. Appends a text to signify it has been cut at |
|
| 190 | + * the end of the string. |
|
| 191 | + * |
|
| 192 | + * @param string $text |
|
| 193 | + * @param int $targetLength |
|
| 194 | + * @param string $append |
|
| 195 | + * @return string |
|
| 196 | + */ |
|
| 197 | 197 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
| 198 | 198 | { |
| 199 | 199 | return ConvertHelper_String::cutText($text, $targetLength, $append); |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | return $info->toString(); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Pretty `print_r`. |
|
| 222 | - * |
|
| 223 | - * @param mixed $var The variable to dump. |
|
| 224 | - * @param bool $return Whether to return the dumped code. |
|
| 225 | - * @param bool $html Whether to style the dump as HTML. |
|
| 226 | - * @return string |
|
| 227 | - */ |
|
| 220 | + /** |
|
| 221 | + * Pretty `print_r`. |
|
| 222 | + * |
|
| 223 | + * @param mixed $var The variable to dump. |
|
| 224 | + * @param bool $return Whether to return the dumped code. |
|
| 225 | + * @param bool $html Whether to style the dump as HTML. |
|
| 226 | + * @return string |
|
| 227 | + */ |
|
| 228 | 228 | public static function print_r($var, bool $return=false, bool $html=true) : string |
| 229 | 229 | { |
| 230 | 230 | $result = parseVariable($var)->enableType()->toString(); |
@@ -245,29 +245,29 @@ discard block |
||
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - /** |
|
| 249 | - * Converts a string, number or boolean value to a boolean value. |
|
| 250 | - * |
|
| 251 | - * @param mixed $string |
|
| 252 | - * @throws ConvertHelper_Exception |
|
| 253 | - * @return bool |
|
| 254 | - * |
|
| 255 | - * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
| 256 | - */ |
|
| 248 | + /** |
|
| 249 | + * Converts a string, number or boolean value to a boolean value. |
|
| 250 | + * |
|
| 251 | + * @param mixed $string |
|
| 252 | + * @throws ConvertHelper_Exception |
|
| 253 | + * @return bool |
|
| 254 | + * |
|
| 255 | + * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
| 256 | + */ |
|
| 257 | 257 | public static function string2bool($string) : bool |
| 258 | 258 | { |
| 259 | 259 | return ConvertHelper_Bool::fromString($string); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Whether the specified string is a boolean string or boolean value. |
|
| 264 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 265 | - * |
|
| 266 | - * @param mixed $string |
|
| 267 | - * @return bool |
|
| 268 | - * @deprecated |
|
| 269 | - * @see ConvertHelper::isBoolean() |
|
| 270 | - */ |
|
| 262 | + /** |
|
| 263 | + * Whether the specified string is a boolean string or boolean value. |
|
| 264 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 265 | + * |
|
| 266 | + * @param mixed $string |
|
| 267 | + * @return bool |
|
| 268 | + * @deprecated |
|
| 269 | + * @see ConvertHelper::isBoolean() |
|
| 270 | + */ |
|
| 271 | 271 | public static function isBooleanString($string) : bool |
| 272 | 272 | { |
| 273 | 273 | return self::isBoolean($string); |
@@ -337,36 +337,36 @@ discard block |
||
| 337 | 337 | return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Retrieves the HEX character codes for all control |
|
| 342 | - * characters that the {@link stripControlCharacters()} |
|
| 343 | - * method will remove. |
|
| 344 | - * |
|
| 345 | - * @return string[] |
|
| 346 | - */ |
|
| 340 | + /** |
|
| 341 | + * Retrieves the HEX character codes for all control |
|
| 342 | + * characters that the {@link stripControlCharacters()} |
|
| 343 | + * method will remove. |
|
| 344 | + * |
|
| 345 | + * @return string[] |
|
| 346 | + */ |
|
| 347 | 347 | public static function getControlCharactersAsHex() : array |
| 348 | 348 | { |
| 349 | 349 | return self::createControlCharacters()->getCharsAsHex(); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Retrieves an array of all control characters that |
|
| 354 | - * the {@link stripControlCharacters()} method will |
|
| 355 | - * remove, as the actual UTF-8 characters. |
|
| 356 | - * |
|
| 357 | - * @return string[] |
|
| 358 | - */ |
|
| 352 | + /** |
|
| 353 | + * Retrieves an array of all control characters that |
|
| 354 | + * the {@link stripControlCharacters()} method will |
|
| 355 | + * remove, as the actual UTF-8 characters. |
|
| 356 | + * |
|
| 357 | + * @return string[] |
|
| 358 | + */ |
|
| 359 | 359 | public static function getControlCharactersAsUTF8() : array |
| 360 | 360 | { |
| 361 | 361 | return self::createControlCharacters()->getCharsAsUTF8(); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - /** |
|
| 365 | - * Retrieves all control characters as JSON encoded |
|
| 366 | - * characters, e.g. "\u200b". |
|
| 367 | - * |
|
| 368 | - * @return string[] |
|
| 369 | - */ |
|
| 364 | + /** |
|
| 365 | + * Retrieves all control characters as JSON encoded |
|
| 366 | + * characters, e.g. "\u200b". |
|
| 367 | + * |
|
| 368 | + * @return string[] |
|
| 369 | + */ |
|
| 370 | 370 | public static function getControlCharactersAsJSON() : array |
| 371 | 371 | { |
| 372 | 372 | return self::createControlCharacters()->getCharsAsJSON(); |
@@ -387,31 +387,31 @@ discard block |
||
| 387 | 387 | return self::createControlCharacters()->stripControlCharacters($string); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * Creates the control characters class, used to |
|
| 392 | - * work with control characters in strings. |
|
| 393 | - * |
|
| 394 | - * @return ConvertHelper_ControlCharacters |
|
| 395 | - */ |
|
| 390 | + /** |
|
| 391 | + * Creates the control characters class, used to |
|
| 392 | + * work with control characters in strings. |
|
| 393 | + * |
|
| 394 | + * @return ConvertHelper_ControlCharacters |
|
| 395 | + */ |
|
| 396 | 396 | public static function createControlCharacters() : ConvertHelper_ControlCharacters |
| 397 | 397 | { |
| 398 | 398 | return new ConvertHelper_ControlCharacters(); |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - /** |
|
| 402 | - * Converts a unicode character to the PHP notation. |
|
| 403 | - * |
|
| 404 | - * Example: |
|
| 405 | - * |
|
| 406 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 407 | - * |
|
| 408 | - * Returns |
|
| 409 | - * |
|
| 410 | - * <pre>\x0</pre> |
|
| 411 | - * |
|
| 412 | - * @param string $unicodeChar |
|
| 413 | - * @return string |
|
| 414 | - */ |
|
| 401 | + /** |
|
| 402 | + * Converts a unicode character to the PHP notation. |
|
| 403 | + * |
|
| 404 | + * Example: |
|
| 405 | + * |
|
| 406 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 407 | + * |
|
| 408 | + * Returns |
|
| 409 | + * |
|
| 410 | + * <pre>\x0</pre> |
|
| 411 | + * |
|
| 412 | + * @param string $unicodeChar |
|
| 413 | + * @return string |
|
| 414 | + */ |
|
| 415 | 415 | public static function unicodeChar2php(string $unicodeChar) : string |
| 416 | 416 | { |
| 417 | 417 | $unicodeChar = json_decode($unicodeChar); |
@@ -525,138 +525,138 @@ discard block |
||
| 525 | 525 | return ConvertHelper_Bool::toStringStrict($boolean, $yesNo); |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - /** |
|
| 529 | - * Converts an associative array with attribute name > value pairs |
|
| 530 | - * to an attribute string that can be used in an HTML tag. Empty |
|
| 531 | - * attribute values are ignored. |
|
| 532 | - * |
|
| 533 | - * Example: |
|
| 534 | - * |
|
| 535 | - * array2attributeString(array( |
|
| 536 | - * 'id' => 45, |
|
| 537 | - * 'href' => 'http://www.mistralys.com' |
|
| 538 | - * )); |
|
| 539 | - * |
|
| 540 | - * Result: |
|
| 541 | - * |
|
| 542 | - * id="45" href="http://www.mistralys.com" |
|
| 543 | - * |
|
| 544 | - * @param array<string,mixed> $array |
|
| 545 | - * @return string |
|
| 546 | - */ |
|
| 528 | + /** |
|
| 529 | + * Converts an associative array with attribute name > value pairs |
|
| 530 | + * to an attribute string that can be used in an HTML tag. Empty |
|
| 531 | + * attribute values are ignored. |
|
| 532 | + * |
|
| 533 | + * Example: |
|
| 534 | + * |
|
| 535 | + * array2attributeString(array( |
|
| 536 | + * 'id' => 45, |
|
| 537 | + * 'href' => 'http://www.mistralys.com' |
|
| 538 | + * )); |
|
| 539 | + * |
|
| 540 | + * Result: |
|
| 541 | + * |
|
| 542 | + * id="45" href="http://www.mistralys.com" |
|
| 543 | + * |
|
| 544 | + * @param array<string,mixed> $array |
|
| 545 | + * @return string |
|
| 546 | + */ |
|
| 547 | 547 | public static function array2attributeString(array $array) : string |
| 548 | 548 | { |
| 549 | 549 | return ConvertHelper_Array::toAttributeString($array); |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - /** |
|
| 553 | - * Converts a string, so it can safely be used in a javascript |
|
| 554 | - * statement in an HTML tag: uses single quotes around the string |
|
| 555 | - * and encodes all special characters as needed. |
|
| 556 | - * |
|
| 557 | - * @param string $string |
|
| 558 | - * @return string |
|
| 559 | - * @deprecated Use the JSHelper class instead. |
|
| 560 | - * @see JSHelper::phpVariable2AttributeJS() |
|
| 561 | - */ |
|
| 552 | + /** |
|
| 553 | + * Converts a string, so it can safely be used in a javascript |
|
| 554 | + * statement in an HTML tag: uses single quotes around the string |
|
| 555 | + * and encodes all special characters as needed. |
|
| 556 | + * |
|
| 557 | + * @param string $string |
|
| 558 | + * @return string |
|
| 559 | + * @deprecated Use the JSHelper class instead. |
|
| 560 | + * @see JSHelper::phpVariable2AttributeJS() |
|
| 561 | + */ |
|
| 562 | 562 | public static function string2attributeJS(string $string) : string |
| 563 | 563 | { |
| 564 | 564 | return JSHelper::phpVariable2AttributeJS($string); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - /** |
|
| 568 | - * Checks if the specified string is a boolean value, which |
|
| 569 | - * includes string representations of boolean values, like |
|
| 570 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 571 | - * or <code>false</code>. |
|
| 572 | - * |
|
| 573 | - * @param mixed $value |
|
| 574 | - * @return boolean |
|
| 575 | - */ |
|
| 567 | + /** |
|
| 568 | + * Checks if the specified string is a boolean value, which |
|
| 569 | + * includes string representations of boolean values, like |
|
| 570 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 571 | + * or <code>false</code>. |
|
| 572 | + * |
|
| 573 | + * @param mixed $value |
|
| 574 | + * @return boolean |
|
| 575 | + */ |
|
| 576 | 576 | public static function isBoolean($value) : bool |
| 577 | 577 | { |
| 578 | 578 | return ConvertHelper_Bool::isBoolean($value); |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - /** |
|
| 582 | - * Converts an associative array to an HTML style attribute value string. |
|
| 583 | - * |
|
| 584 | - * @param array<string,mixed> $subject |
|
| 585 | - * @return string |
|
| 586 | - */ |
|
| 581 | + /** |
|
| 582 | + * Converts an associative array to an HTML style attribute value string. |
|
| 583 | + * |
|
| 584 | + * @param array<string,mixed> $subject |
|
| 585 | + * @return string |
|
| 586 | + */ |
|
| 587 | 587 | public static function array2styleString(array $subject) : string |
| 588 | 588 | { |
| 589 | 589 | return ConvertHelper_Array::toStyleString($subject); |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - /** |
|
| 593 | - * Converts a DateTime object to a timestamp, which |
|
| 594 | - * is PHP 5.2 compatible. |
|
| 595 | - * |
|
| 596 | - * @param DateTime $date |
|
| 597 | - * @return integer |
|
| 598 | - */ |
|
| 592 | + /** |
|
| 593 | + * Converts a DateTime object to a timestamp, which |
|
| 594 | + * is PHP 5.2 compatible. |
|
| 595 | + * |
|
| 596 | + * @param DateTime $date |
|
| 597 | + * @return integer |
|
| 598 | + */ |
|
| 599 | 599 | public static function date2timestamp(DateTime $date) : int |
| 600 | 600 | { |
| 601 | 601 | return ConvertHelper_Date::toTimestamp($date); |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - /** |
|
| 605 | - * Converts a timestamp into a DateTime instance. |
|
| 606 | - * @param int $timestamp |
|
| 607 | - * @return DateTime |
|
| 608 | - */ |
|
| 604 | + /** |
|
| 605 | + * Converts a timestamp into a DateTime instance. |
|
| 606 | + * @param int $timestamp |
|
| 607 | + * @return DateTime |
|
| 608 | + */ |
|
| 609 | 609 | public static function timestamp2date(int $timestamp) : DateTime |
| 610 | 610 | { |
| 611 | 611 | return ConvertHelper_Date::fromTimestamp($timestamp); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - /** |
|
| 615 | - * Strips an absolute path to a file within the application |
|
| 616 | - * to make the path relative to the application root path. |
|
| 617 | - * |
|
| 618 | - * @param string $path |
|
| 619 | - * @return string |
|
| 620 | - * |
|
| 621 | - * @see FileHelper::relativizePath() |
|
| 622 | - * @see FileHelper::relativizePathByDepth() |
|
| 623 | - */ |
|
| 614 | + /** |
|
| 615 | + * Strips an absolute path to a file within the application |
|
| 616 | + * to make the path relative to the application root path. |
|
| 617 | + * |
|
| 618 | + * @param string $path |
|
| 619 | + * @return string |
|
| 620 | + * |
|
| 621 | + * @see FileHelper::relativizePath() |
|
| 622 | + * @see FileHelper::relativizePathByDepth() |
|
| 623 | + */ |
|
| 624 | 624 | public static function fileRelativize(string $path) : string |
| 625 | 625 | { |
| 626 | 626 | return FileHelper::relativizePathByDepth($path); |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | - * Converts a PHP regex to a javascript RegExp object statement. |
|
| 631 | - * |
|
| 632 | - * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
| 633 | - * More details are available on its usage there. |
|
| 634 | - * |
|
| 635 | - * @param string $regex A PHP preg regex |
|
| 636 | - * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
| 637 | - * @return string Depending on the specified return type. |
|
| 638 | - * |
|
| 639 | - * @see JSHelper::buildRegexStatement() |
|
| 640 | - */ |
|
| 630 | + * Converts a PHP regex to a javascript RegExp object statement. |
|
| 631 | + * |
|
| 632 | + * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
| 633 | + * More details are available on its usage there. |
|
| 634 | + * |
|
| 635 | + * @param string $regex A PHP preg regex |
|
| 636 | + * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
| 637 | + * @return string Depending on the specified return type. |
|
| 638 | + * |
|
| 639 | + * @see JSHelper::buildRegexStatement() |
|
| 640 | + */ |
|
| 641 | 641 | public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string |
| 642 | 642 | { |
| 643 | 643 | return JSHelper::buildRegexStatement($regex, $statementType); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - /** |
|
| 647 | - * Converts the specified variable to JSON. Works just |
|
| 648 | - * like the native `json_encode` method, except that it |
|
| 649 | - * will trigger an exception on failure, which has the |
|
| 650 | - * json error details included in its developer details. |
|
| 651 | - * |
|
| 652 | - * @param mixed $variable |
|
| 653 | - * @param int $options JSON encode options. |
|
| 654 | - * @param int $depth |
|
| 655 | - * @return string |
|
| 656 | - * |
|
| 657 | - * @throws ConvertHelper_Exception |
|
| 658 | - * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
| 659 | - */ |
|
| 646 | + /** |
|
| 647 | + * Converts the specified variable to JSON. Works just |
|
| 648 | + * like the native `json_encode` method, except that it |
|
| 649 | + * will trigger an exception on failure, which has the |
|
| 650 | + * json error details included in its developer details. |
|
| 651 | + * |
|
| 652 | + * @param mixed $variable |
|
| 653 | + * @param int $options JSON encode options. |
|
| 654 | + * @param int $depth |
|
| 655 | + * @return string |
|
| 656 | + * |
|
| 657 | + * @throws ConvertHelper_Exception |
|
| 658 | + * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
| 659 | + */ |
|
| 660 | 660 | public static function var2json($variable, int $options=0, int $depth=512) : string |
| 661 | 661 | { |
| 662 | 662 | $result = json_encode($variable, $options, $depth); |
@@ -691,12 +691,12 @@ discard block |
||
| 691 | 691 | ->toString(); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - /** |
|
| 695 | - * Strips all known UTF byte order marks from the specified string. |
|
| 696 | - * |
|
| 697 | - * @param string $string |
|
| 698 | - * @return string |
|
| 699 | - */ |
|
| 694 | + /** |
|
| 695 | + * Strips all known UTF byte order marks from the specified string. |
|
| 696 | + * |
|
| 697 | + * @param string $string |
|
| 698 | + * @return string |
|
| 699 | + */ |
|
| 700 | 700 | public static function stripUTFBom(string $string) : string |
| 701 | 701 | { |
| 702 | 702 | $boms = FileHelper::getUTFBOMs(); |
@@ -715,69 +715,69 @@ discard block |
||
| 715 | 715 | return $string; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - /** |
|
| 719 | - * Converts a string to valid utf8, regardless |
|
| 720 | - * of the string's encoding(s). |
|
| 721 | - * |
|
| 722 | - * @param string $string |
|
| 723 | - * @return string |
|
| 724 | - */ |
|
| 718 | + /** |
|
| 719 | + * Converts a string to valid utf8, regardless |
|
| 720 | + * of the string's encoding(s). |
|
| 721 | + * |
|
| 722 | + * @param string $string |
|
| 723 | + * @return string |
|
| 724 | + */ |
|
| 725 | 725 | public static function string2utf8(string $string) : string |
| 726 | 726 | { |
| 727 | 727 | return ConvertHelper_String::toUtf8($string); |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | - /** |
|
| 731 | - * Checks whether the specified string is an ASCII |
|
| 732 | - * string, without any special or UTF8 characters. |
|
| 733 | - * Note: empty strings and NULL are considered ASCII. |
|
| 734 | - * Any variable types other than strings are not. |
|
| 735 | - * |
|
| 736 | - * @param string|float|int|NULL $string |
|
| 737 | - * @return boolean |
|
| 738 | - */ |
|
| 730 | + /** |
|
| 731 | + * Checks whether the specified string is an ASCII |
|
| 732 | + * string, without any special or UTF8 characters. |
|
| 733 | + * Note: empty strings and NULL are considered ASCII. |
|
| 734 | + * Any variable types other than strings are not. |
|
| 735 | + * |
|
| 736 | + * @param string|float|int|NULL $string |
|
| 737 | + * @return boolean |
|
| 738 | + */ |
|
| 739 | 739 | public static function isStringASCII($string) : bool |
| 740 | 740 | { |
| 741 | 741 | return ConvertHelper_String::isASCII(strval($string)); |
| 742 | 742 | } |
| 743 | 743 | |
| 744 | - /** |
|
| 745 | - * Adds HTML syntax highlighting to an URL. |
|
| 746 | - * |
|
| 747 | - * NOTE: Includes the necessary CSS styles. When |
|
| 748 | - * highlighting several URLs in the same page, |
|
| 749 | - * prefer using the `parseURL` function instead. |
|
| 750 | - * |
|
| 751 | - * @param string $url |
|
| 752 | - * @return string |
|
| 753 | - * @deprecated Use the Highlighter class directly instead. |
|
| 754 | - * @see Highlighter |
|
| 755 | - */ |
|
| 744 | + /** |
|
| 745 | + * Adds HTML syntax highlighting to an URL. |
|
| 746 | + * |
|
| 747 | + * NOTE: Includes the necessary CSS styles. When |
|
| 748 | + * highlighting several URLs in the same page, |
|
| 749 | + * prefer using the `parseURL` function instead. |
|
| 750 | + * |
|
| 751 | + * @param string $url |
|
| 752 | + * @return string |
|
| 753 | + * @deprecated Use the Highlighter class directly instead. |
|
| 754 | + * @see Highlighter |
|
| 755 | + */ |
|
| 756 | 756 | public static function highlight_url(string $url) : string |
| 757 | 757 | { |
| 758 | 758 | return Highlighter::url($url); |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - /** |
|
| 762 | - * Calculates a percentage match of the source string with the target string. |
|
| 763 | - * |
|
| 764 | - * Options are: |
|
| 765 | - * |
|
| 766 | - * - maxLevenshtein, default: 10 |
|
| 767 | - * Any levenshtein results above this value are ignored. |
|
| 768 | - * |
|
| 769 | - * - precision, default: 1 |
|
| 770 | - * The precision of the percentage float value |
|
| 771 | - * |
|
| 772 | - * @param string $source |
|
| 773 | - * @param string $target |
|
| 774 | - * @param array<string,mixed> $options |
|
| 775 | - * @return float |
|
| 776 | - * |
|
| 777 | - * @see ConvertHelper_TextComparer |
|
| 778 | - * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
| 779 | - * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
| 780 | - */ |
|
| 761 | + /** |
|
| 762 | + * Calculates a percentage match of the source string with the target string. |
|
| 763 | + * |
|
| 764 | + * Options are: |
|
| 765 | + * |
|
| 766 | + * - maxLevenshtein, default: 10 |
|
| 767 | + * Any levenshtein results above this value are ignored. |
|
| 768 | + * |
|
| 769 | + * - precision, default: 1 |
|
| 770 | + * The precision of the percentage float value |
|
| 771 | + * |
|
| 772 | + * @param string $source |
|
| 773 | + * @param string $target |
|
| 774 | + * @param array<string,mixed> $options |
|
| 775 | + * @return float |
|
| 776 | + * |
|
| 777 | + * @see ConvertHelper_TextComparer |
|
| 778 | + * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
| 779 | + * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
| 780 | + */ |
|
| 781 | 781 | public static function matchString(string $source, string $target, array $options=array()) : float |
| 782 | 782 | { |
| 783 | 783 | return (new ConvertHelper_TextComparer()) |
@@ -785,109 +785,109 @@ discard block |
||
| 785 | 785 | ->match($source, $target); |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - /** |
|
| 789 | - * Converts a date interval to a human-readable string with |
|
| 790 | - * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
| 791 | - * |
|
| 792 | - * @param DateInterval $interval |
|
| 793 | - * @return string |
|
| 794 | - * @see ConvertHelper_IntervalConverter |
|
| 795 | - * |
|
| 796 | - * @throws ConvertHelper_Exception |
|
| 797 | - * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
| 798 | - */ |
|
| 788 | + /** |
|
| 789 | + * Converts a date interval to a human-readable string with |
|
| 790 | + * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
| 791 | + * |
|
| 792 | + * @param DateInterval $interval |
|
| 793 | + * @return string |
|
| 794 | + * @see ConvertHelper_IntervalConverter |
|
| 795 | + * |
|
| 796 | + * @throws ConvertHelper_Exception |
|
| 797 | + * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
| 798 | + */ |
|
| 799 | 799 | public static function interval2string(DateInterval $interval) : string |
| 800 | 800 | { |
| 801 | 801 | return (new ConvertHelper_IntervalConverter()) |
| 802 | 802 | ->toString($interval); |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - /** |
|
| 806 | - * Converts an interval to its total amount of days. |
|
| 807 | - * @param DateInterval $interval |
|
| 808 | - * @return int |
|
| 809 | - */ |
|
| 805 | + /** |
|
| 806 | + * Converts an interval to its total amount of days. |
|
| 807 | + * @param DateInterval $interval |
|
| 808 | + * @return int |
|
| 809 | + */ |
|
| 810 | 810 | public static function interval2days(DateInterval $interval) : int |
| 811 | 811 | { |
| 812 | 812 | return ConvertHelper_DateInterval::toDays($interval); |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - /** |
|
| 816 | - * Converts an interval to its total amount of hours. |
|
| 817 | - * @param DateInterval $interval |
|
| 818 | - * @return int |
|
| 819 | - */ |
|
| 815 | + /** |
|
| 816 | + * Converts an interval to its total amount of hours. |
|
| 817 | + * @param DateInterval $interval |
|
| 818 | + * @return int |
|
| 819 | + */ |
|
| 820 | 820 | public static function interval2hours(DateInterval $interval) : int |
| 821 | 821 | { |
| 822 | 822 | return ConvertHelper_DateInterval::toHours($interval); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - /** |
|
| 826 | - * Converts an interval to its total amount of minutes. |
|
| 827 | - * @param DateInterval $interval |
|
| 828 | - * @return int |
|
| 829 | - */ |
|
| 825 | + /** |
|
| 826 | + * Converts an interval to its total amount of minutes. |
|
| 827 | + * @param DateInterval $interval |
|
| 828 | + * @return int |
|
| 829 | + */ |
|
| 830 | 830 | public static function interval2minutes(DateInterval $interval) : int |
| 831 | 831 | { |
| 832 | 832 | return ConvertHelper_DateInterval::toMinutes($interval); |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - /** |
|
| 836 | - * Converts an interval to its total amount of seconds. |
|
| 837 | - * @param DateInterval $interval |
|
| 838 | - * @return int |
|
| 839 | - */ |
|
| 835 | + /** |
|
| 836 | + * Converts an interval to its total amount of seconds. |
|
| 837 | + * @param DateInterval $interval |
|
| 838 | + * @return int |
|
| 839 | + */ |
|
| 840 | 840 | public static function interval2seconds(DateInterval $interval) : int |
| 841 | 841 | { |
| 842 | 842 | return ConvertHelper_DateInterval::toSeconds($interval); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - /** |
|
| 846 | - * Calculates the total amount of days / hours / minutes or seconds |
|
| 847 | - * of a date interval object (depending on the specified units), and |
|
| 848 | - * returns the total amount. |
|
| 849 | - * |
|
| 850 | - * @param DateInterval $interval |
|
| 851 | - * @param string $unit What total value to calculate. |
|
| 852 | - * @return integer |
|
| 853 | - * |
|
| 854 | - * @see ConvertHelper::INTERVAL_SECONDS |
|
| 855 | - * @see ConvertHelper::INTERVAL_MINUTES |
|
| 856 | - * @see ConvertHelper::INTERVAL_HOURS |
|
| 857 | - * @see ConvertHelper::INTERVAL_DAYS |
|
| 858 | - */ |
|
| 845 | + /** |
|
| 846 | + * Calculates the total amount of days / hours / minutes or seconds |
|
| 847 | + * of a date interval object (depending on the specified units), and |
|
| 848 | + * returns the total amount. |
|
| 849 | + * |
|
| 850 | + * @param DateInterval $interval |
|
| 851 | + * @param string $unit What total value to calculate. |
|
| 852 | + * @return integer |
|
| 853 | + * |
|
| 854 | + * @see ConvertHelper::INTERVAL_SECONDS |
|
| 855 | + * @see ConvertHelper::INTERVAL_MINUTES |
|
| 856 | + * @see ConvertHelper::INTERVAL_HOURS |
|
| 857 | + * @see ConvertHelper::INTERVAL_DAYS |
|
| 858 | + */ |
|
| 859 | 859 | public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int |
| 860 | 860 | { |
| 861 | 861 | return ConvertHelper_DateInterval::toTotal($interval, $unit); |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - /** |
|
| 865 | - * Converts a date to the corresponding day name. |
|
| 866 | - * |
|
| 867 | - * @param DateTime $date |
|
| 868 | - * @param bool $short |
|
| 869 | - * @return string|NULL |
|
| 870 | - */ |
|
| 864 | + /** |
|
| 865 | + * Converts a date to the corresponding day name. |
|
| 866 | + * |
|
| 867 | + * @param DateTime $date |
|
| 868 | + * @param bool $short |
|
| 869 | + * @return string|NULL |
|
| 870 | + */ |
|
| 871 | 871 | public static function date2dayName(DateTime $date, bool $short=false) : ?string |
| 872 | 872 | { |
| 873 | 873 | return ConvertHelper_Date::toDayName($date, $short); |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * Retrieves a list of english day names. |
|
| 878 | - * @return string[] |
|
| 879 | - */ |
|
| 876 | + /** |
|
| 877 | + * Retrieves a list of english day names. |
|
| 878 | + * @return string[] |
|
| 879 | + */ |
|
| 880 | 880 | public static function getDayNamesInvariant() : array |
| 881 | 881 | { |
| 882 | 882 | return ConvertHelper_Date::getDayNamesInvariant(); |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - /** |
|
| 886 | - * Retrieves the day names list for the current locale. |
|
| 887 | - * |
|
| 888 | - * @param bool $short |
|
| 889 | - * @return string[] |
|
| 890 | - */ |
|
| 885 | + /** |
|
| 886 | + * Retrieves the day names list for the current locale. |
|
| 887 | + * |
|
| 888 | + * @param bool $short |
|
| 889 | + * @return string[] |
|
| 890 | + */ |
|
| 891 | 891 | public static function getDayNames(bool $short=false) : array |
| 892 | 892 | { |
| 893 | 893 | return ConvertHelper_Date::getDayNames($short); |
@@ -906,68 +906,68 @@ discard block |
||
| 906 | 906 | return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction); |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - /** |
|
| 910 | - * Splits a string into an array of all characters it is composed of. |
|
| 911 | - * Unicode character safe. |
|
| 912 | - * |
|
| 913 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 914 | - * characters. |
|
| 915 | - * |
|
| 916 | - * @param string $string |
|
| 917 | - * @return string[] |
|
| 918 | - */ |
|
| 909 | + /** |
|
| 910 | + * Splits a string into an array of all characters it is composed of. |
|
| 911 | + * Unicode character safe. |
|
| 912 | + * |
|
| 913 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 914 | + * characters. |
|
| 915 | + * |
|
| 916 | + * @param string $string |
|
| 917 | + * @return string[] |
|
| 918 | + */ |
|
| 919 | 919 | public static function string2array(string $string) : array |
| 920 | 920 | { |
| 921 | 921 | return ConvertHelper_String::toArray($string); |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - /** |
|
| 925 | - * Checks whether the specified string contains HTML code. |
|
| 926 | - * |
|
| 927 | - * @param string $string |
|
| 928 | - * @return boolean |
|
| 929 | - */ |
|
| 924 | + /** |
|
| 925 | + * Checks whether the specified string contains HTML code. |
|
| 926 | + * |
|
| 927 | + * @param string $string |
|
| 928 | + * @return boolean |
|
| 929 | + */ |
|
| 930 | 930 | public static function isStringHTML(string $string) : bool |
| 931 | 931 | { |
| 932 | 932 | return ConvertHelper_String::isHTML($string); |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - /** |
|
| 936 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 937 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 938 | - * are not calculated correctly. |
|
| 939 | - * |
|
| 940 | - * @param string $str |
|
| 941 | - * @param int $width |
|
| 942 | - * @param string $break |
|
| 943 | - * @param bool $cut |
|
| 944 | - * @return string |
|
| 945 | - */ |
|
| 935 | + /** |
|
| 936 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 937 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 938 | + * are not calculated correctly. |
|
| 939 | + * |
|
| 940 | + * @param string $str |
|
| 941 | + * @param int $width |
|
| 942 | + * @param string $break |
|
| 943 | + * @param bool $cut |
|
| 944 | + * @return string |
|
| 945 | + */ |
|
| 946 | 946 | public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string |
| 947 | 947 | { |
| 948 | 948 | return ConvertHelper_String::wordwrap($str, $width, $break, $cut); |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - /** |
|
| 952 | - * Calculates the byte length of a string, taking into |
|
| 953 | - * account any unicode characters. |
|
| 954 | - * |
|
| 955 | - * @param string $string |
|
| 956 | - * @return int |
|
| 957 | - */ |
|
| 951 | + /** |
|
| 952 | + * Calculates the byte length of a string, taking into |
|
| 953 | + * account any unicode characters. |
|
| 954 | + * |
|
| 955 | + * @param string $string |
|
| 956 | + * @return int |
|
| 957 | + */ |
|
| 958 | 958 | public static function string2bytes(string $string): int |
| 959 | 959 | { |
| 960 | 960 | return ConvertHelper_String::toBytes($string); |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - /** |
|
| 964 | - * Creates a short, 8-character long hash for the specified string. |
|
| 965 | - * |
|
| 966 | - * WARNING: Not cryptographically safe. |
|
| 967 | - * |
|
| 968 | - * @param string $string |
|
| 969 | - * @return string |
|
| 970 | - */ |
|
| 963 | + /** |
|
| 964 | + * Creates a short, 8-character long hash for the specified string. |
|
| 965 | + * |
|
| 966 | + * WARNING: Not cryptographically safe. |
|
| 967 | + * |
|
| 968 | + * @param string $string |
|
| 969 | + * @return string |
|
| 970 | + */ |
|
| 971 | 971 | public static function string2shortHash(string $string) : string |
| 972 | 972 | { |
| 973 | 973 | return ConvertHelper_String::toShortHash($string); |
@@ -1013,88 +1013,88 @@ discard block |
||
| 1013 | 1013 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - /** |
|
| 1017 | - * Parses the specified query string like the native |
|
| 1018 | - * function <code>parse_str</code>, without the key |
|
| 1019 | - * naming limitations. |
|
| 1020 | - * |
|
| 1021 | - * Using parse_str, dots or spaces in key names are |
|
| 1022 | - * replaced by underscores. This method keeps all names |
|
| 1023 | - * intact. |
|
| 1024 | - * |
|
| 1025 | - * It still uses the parse_str implementation as it |
|
| 1026 | - * is tested and tried, but fixes the parameter names |
|
| 1027 | - * after parsing, as needed. |
|
| 1028 | - * |
|
| 1029 | - * @param string $queryString |
|
| 1030 | - * @return array<string,string> |
|
| 1031 | - * @see ConvertHelper_QueryParser |
|
| 1032 | - */ |
|
| 1016 | + /** |
|
| 1017 | + * Parses the specified query string like the native |
|
| 1018 | + * function <code>parse_str</code>, without the key |
|
| 1019 | + * naming limitations. |
|
| 1020 | + * |
|
| 1021 | + * Using parse_str, dots or spaces in key names are |
|
| 1022 | + * replaced by underscores. This method keeps all names |
|
| 1023 | + * intact. |
|
| 1024 | + * |
|
| 1025 | + * It still uses the parse_str implementation as it |
|
| 1026 | + * is tested and tried, but fixes the parameter names |
|
| 1027 | + * after parsing, as needed. |
|
| 1028 | + * |
|
| 1029 | + * @param string $queryString |
|
| 1030 | + * @return array<string,string> |
|
| 1031 | + * @see ConvertHelper_QueryParser |
|
| 1032 | + */ |
|
| 1033 | 1033 | public static function parseQueryString(string $queryString) : array |
| 1034 | 1034 | { |
| 1035 | 1035 | $parser = new ConvertHelper_QueryParser(); |
| 1036 | 1036 | return $parser->parse($queryString); |
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | - /** |
|
| 1040 | - * Searches for needle in the specified string, and returns a list |
|
| 1041 | - * of all occurrences, including the matched string. The matched |
|
| 1042 | - * string is useful when doing a case-insensitive search, as it |
|
| 1043 | - * shows the exact matched case of needle. |
|
| 1044 | - * |
|
| 1045 | - * @param string $needle |
|
| 1046 | - * @param string $haystack |
|
| 1047 | - * @param bool $caseInsensitive |
|
| 1048 | - * @return ConvertHelper_StringMatch[] |
|
| 1049 | - */ |
|
| 1039 | + /** |
|
| 1040 | + * Searches for needle in the specified string, and returns a list |
|
| 1041 | + * of all occurrences, including the matched string. The matched |
|
| 1042 | + * string is useful when doing a case-insensitive search, as it |
|
| 1043 | + * shows the exact matched case of needle. |
|
| 1044 | + * |
|
| 1045 | + * @param string $needle |
|
| 1046 | + * @param string $haystack |
|
| 1047 | + * @param bool $caseInsensitive |
|
| 1048 | + * @return ConvertHelper_StringMatch[] |
|
| 1049 | + */ |
|
| 1050 | 1050 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
| 1051 | 1051 | { |
| 1052 | 1052 | return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive); |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | - /** |
|
| 1056 | - * Like explode, but trims all entries, and removes |
|
| 1057 | - * empty entries from the resulting array. |
|
| 1058 | - * |
|
| 1059 | - * @param string $delimiter |
|
| 1060 | - * @param string $string |
|
| 1061 | - * @return string[] |
|
| 1062 | - */ |
|
| 1055 | + /** |
|
| 1056 | + * Like explode, but trims all entries, and removes |
|
| 1057 | + * empty entries from the resulting array. |
|
| 1058 | + * |
|
| 1059 | + * @param string $delimiter |
|
| 1060 | + * @param string $string |
|
| 1061 | + * @return string[] |
|
| 1062 | + */ |
|
| 1063 | 1063 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1064 | 1064 | { |
| 1065 | 1065 | return ConvertHelper_String::explodeTrim($delimiter, $string); |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - /** |
|
| 1069 | - * Detects the most used end-of-line character in the subject string. |
|
| 1070 | - * |
|
| 1071 | - * @param string $subjectString The string to check. |
|
| 1072 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1073 | - */ |
|
| 1068 | + /** |
|
| 1069 | + * Detects the most used end-of-line character in the subject string. |
|
| 1070 | + * |
|
| 1071 | + * @param string $subjectString The string to check. |
|
| 1072 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1073 | + */ |
|
| 1074 | 1074 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1075 | 1075 | { |
| 1076 | 1076 | return ConvertHelper_EOL::detect($subjectString); |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - /** |
|
| 1080 | - * Removes the specified keys from the target array, |
|
| 1081 | - * if they exist. |
|
| 1082 | - * |
|
| 1083 | - * @param array<string|int,mixed> $array |
|
| 1084 | - * @param string[] $keys |
|
| 1085 | - */ |
|
| 1079 | + /** |
|
| 1080 | + * Removes the specified keys from the target array, |
|
| 1081 | + * if they exist. |
|
| 1082 | + * |
|
| 1083 | + * @param array<string|int,mixed> $array |
|
| 1084 | + * @param string[] $keys |
|
| 1085 | + */ |
|
| 1086 | 1086 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1087 | 1087 | { |
| 1088 | 1088 | ConvertHelper_Array::removeKeys($array, $keys); |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - /** |
|
| 1092 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1093 | - * Accepts both positive and negative integers. |
|
| 1094 | - * |
|
| 1095 | - * @param mixed $value |
|
| 1096 | - * @return bool |
|
| 1097 | - */ |
|
| 1091 | + /** |
|
| 1092 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1093 | + * Accepts both positive and negative integers. |
|
| 1094 | + * |
|
| 1095 | + * @param mixed $value |
|
| 1096 | + * @return bool |
|
| 1097 | + */ |
|
| 1098 | 1098 | public static function isInteger($value) : bool |
| 1099 | 1099 | { |
| 1100 | 1100 | if(is_int($value)) { |
@@ -1114,52 +1114,52 @@ discard block |
||
| 1114 | 1114 | return false; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - /** |
|
| 1118 | - * Converts an amount of seconds to a DateInterval object. |
|
| 1119 | - * |
|
| 1120 | - * @param int $seconds |
|
| 1121 | - * @return DateInterval |
|
| 1122 | - * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
| 1123 | - * |
|
| 1124 | - * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
| 1125 | - */ |
|
| 1117 | + /** |
|
| 1118 | + * Converts an amount of seconds to a DateInterval object. |
|
| 1119 | + * |
|
| 1120 | + * @param int $seconds |
|
| 1121 | + * @return DateInterval |
|
| 1122 | + * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
| 1123 | + * |
|
| 1124 | + * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
| 1125 | + */ |
|
| 1126 | 1126 | public static function seconds2interval(int $seconds) : DateInterval |
| 1127 | 1127 | { |
| 1128 | 1128 | return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval(); |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - /** |
|
| 1132 | - * Converts a size string like "50 MB" to the corresponding byte size. |
|
| 1133 | - * It is case-insensitive, ignores spaces, and supports both traditional |
|
| 1134 | - * "MB" and "MiB" notations. |
|
| 1135 | - * |
|
| 1136 | - * @param string $size |
|
| 1137 | - * @return int |
|
| 1138 | - */ |
|
| 1131 | + /** |
|
| 1132 | + * Converts a size string like "50 MB" to the corresponding byte size. |
|
| 1133 | + * It is case-insensitive, ignores spaces, and supports both traditional |
|
| 1134 | + * "MB" and "MiB" notations. |
|
| 1135 | + * |
|
| 1136 | + * @param string $size |
|
| 1137 | + * @return int |
|
| 1138 | + */ |
|
| 1139 | 1139 | public static function size2bytes(string $size) : int |
| 1140 | 1140 | { |
| 1141 | 1141 | return self::parseSize($size)->toBytes(); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - /** |
|
| 1145 | - * Parses a size string like "50 MB" and returns a size notation instance |
|
| 1146 | - * that has utility methods to access information on it, and convert it. |
|
| 1147 | - * |
|
| 1148 | - * @param string $size |
|
| 1149 | - * @return ConvertHelper_SizeNotation |
|
| 1150 | - */ |
|
| 1144 | + /** |
|
| 1145 | + * Parses a size string like "50 MB" and returns a size notation instance |
|
| 1146 | + * that has utility methods to access information on it, and convert it. |
|
| 1147 | + * |
|
| 1148 | + * @param string $size |
|
| 1149 | + * @return ConvertHelper_SizeNotation |
|
| 1150 | + */ |
|
| 1151 | 1151 | public static function parseSize(string $size) : ConvertHelper_SizeNotation |
| 1152 | 1152 | { |
| 1153 | 1153 | return new ConvertHelper_SizeNotation($size); |
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - /** |
|
| 1157 | - * Creates a URL finder instance, which can be used to find |
|
| 1158 | - * URLs in a string - be it plain text, or HTML. |
|
| 1159 | - * |
|
| 1160 | - * @param string $subject |
|
| 1161 | - * @return ConvertHelper_URLFinder |
|
| 1162 | - */ |
|
| 1156 | + /** |
|
| 1157 | + * Creates a URL finder instance, which can be used to find |
|
| 1158 | + * URLs in a string - be it plain text, or HTML. |
|
| 1159 | + * |
|
| 1160 | + * @param string $subject |
|
| 1161 | + * @return ConvertHelper_URLFinder |
|
| 1162 | + */ |
|
| 1163 | 1163 | public static function createURLFinder(string $subject) : ConvertHelper_URLFinder |
| 1164 | 1164 | { |
| 1165 | 1165 | return new ConvertHelper_URLFinder($subject); |
@@ -20,43 +20,43 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class ConvertHelper_TabsNormalizer |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var integer |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var integer |
|
| 25 | + */ |
|
| 26 | 26 | protected $max = 0; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var integer |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var integer |
|
| 30 | + */ |
|
| 31 | 31 | protected $min = PHP_INT_MAX; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var bool |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var bool |
|
| 35 | + */ |
|
| 36 | 36 | protected $tabs2spaces = false; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string[] |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var string[] |
|
| 40 | + */ |
|
| 41 | 41 | protected $lines = array(); |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $eol = ''; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var integer |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var integer |
|
| 50 | + */ |
|
| 51 | 51 | protected $tabSize = 4; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Whether to enable or disable the conversion |
|
| 55 | - * of tabs to spaces. |
|
| 56 | - * |
|
| 57 | - * @param bool $enable |
|
| 58 | - * @return ConvertHelper_TabsNormalizer |
|
| 59 | - */ |
|
| 53 | + /** |
|
| 54 | + * Whether to enable or disable the conversion |
|
| 55 | + * of tabs to spaces. |
|
| 56 | + * |
|
| 57 | + * @param bool $enable |
|
| 58 | + * @return ConvertHelper_TabsNormalizer |
|
| 59 | + */ |
|
| 60 | 60 | public function convertTabsToSpaces(bool $enable=true) : ConvertHelper_TabsNormalizer |
| 61 | 61 | { |
| 62 | 62 | $this->tabs2spaces = $enable; |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | return $this; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Sets the size of a tab, in spaces. Used to convert tabs |
|
| 69 | - * from spaces and the other way around. Defaults to 4. |
|
| 70 | - * |
|
| 71 | - * @param int $amountSpaces |
|
| 72 | - * @return ConvertHelper_TabsNormalizer |
|
| 73 | - */ |
|
| 67 | + /** |
|
| 68 | + * Sets the size of a tab, in spaces. Used to convert tabs |
|
| 69 | + * from spaces and the other way around. Defaults to 4. |
|
| 70 | + * |
|
| 71 | + * @param int $amountSpaces |
|
| 72 | + * @return ConvertHelper_TabsNormalizer |
|
| 73 | + */ |
|
| 74 | 74 | public function setTabSize(int $amountSpaces) : ConvertHelper_TabsNormalizer |
| 75 | 75 | { |
| 76 | 76 | $this->tabSize = $amountSpaces; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | return $this; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Normalizes tabs in the specified string by indenting everything |
|
| 83 | - * back to the minimum tab distance. With the second parameter, |
|
| 84 | - * tabs can optionally be converted to spaces as well (recommended |
|
| 85 | - * for HTML output). |
|
| 86 | - * |
|
| 87 | - * @param string $string |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 81 | + /** |
|
| 82 | + * Normalizes tabs in the specified string by indenting everything |
|
| 83 | + * back to the minimum tab distance. With the second parameter, |
|
| 84 | + * tabs can optionally be converted to spaces as well (recommended |
|
| 85 | + * for HTML output). |
|
| 86 | + * |
|
| 87 | + * @param string $string |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | 90 | public function normalize(string $string) : string |
| 91 | 91 | { |
| 92 | 92 | $this->splitLines($string); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | return implode($this->eol, $converted); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Finds out the minimum and maximum amount of |
|
| 148 | - * tabs in the string. |
|
| 149 | - */ |
|
| 146 | + /** |
|
| 147 | + * Finds out the minimum and maximum amount of |
|
| 148 | + * tabs in the string. |
|
| 149 | + */ |
|
| 150 | 150 | protected function countOccurrences() : void |
| 151 | 151 | { |
| 152 | 152 | foreach($this->lines as $line) |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | ) |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var string[] |
|
| 76 | - */ |
|
| 74 | + /** |
|
| 75 | + * @var string[] |
|
| 76 | + */ |
|
| 77 | 77 | protected $selected = array(); |
| 78 | 78 | |
| 79 | 79 | public function convert(string $string) : string |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | return str_replace(array_keys($chars), array_values($chars), $string); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Selects a character set to replace. Can be called |
|
| 88 | - * several times to add additional sets to the collection. |
|
| 89 | - * |
|
| 90 | - * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 91 | - * @return ConvertHelper_HiddenConverter |
|
| 92 | - * |
|
| 93 | - * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 94 | - * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 95 | - */ |
|
| 86 | + /** |
|
| 87 | + * Selects a character set to replace. Can be called |
|
| 88 | + * several times to add additional sets to the collection. |
|
| 89 | + * |
|
| 90 | + * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 91 | + * @return ConvertHelper_HiddenConverter |
|
| 92 | + * |
|
| 93 | + * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 94 | + * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 95 | + */ |
|
| 96 | 96 | public function selectCharacters(string $type) : ConvertHelper_HiddenConverter |
| 97 | 97 | { |
| 98 | 98 | if(!in_array($type, $this->selected)) { |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | return $this; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Resolves the list of characters to make visible. |
|
| 107 | - * |
|
| 108 | - * @return string[] |
|
| 109 | - */ |
|
| 105 | + /** |
|
| 106 | + * Resolves the list of characters to make visible. |
|
| 107 | + * |
|
| 108 | + * @return string[] |
|
| 109 | + */ |
|
| 110 | 110 | protected function resolveSelection() : array |
| 111 | 111 | { |
| 112 | 112 | $selected = $this->selected; |
@@ -27,16 +27,16 @@ |
||
| 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<string,string> |
|
| 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<string,string> |
|
| 39 | + */ |
|
| 40 | 40 | public function parse(string $queryString) : array |
| 41 | 41 | { |
| 42 | 42 | // allow HTML entities notation |