You are here

private static function Ctype::convert_int_to_char_for_ctype in Lockr 7.3

Converts integers to their char versions according to normal ctype behaviour, if needed.

If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer.

Parameters

string|int $int:

Return value

mixed

11 calls to Ctype::convert_int_to_char_for_ctype()
Ctype::ctype_alnum in vendor/symfony/polyfill-ctype/Ctype.php
Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
Ctype::ctype_alpha in vendor/symfony/polyfill-ctype/Ctype.php
Returns TRUE if every character in text is a letter, FALSE otherwise.
Ctype::ctype_cntrl in vendor/symfony/polyfill-ctype/Ctype.php
Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
Ctype::ctype_digit in vendor/symfony/polyfill-ctype/Ctype.php
Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
Ctype::ctype_graph in vendor/symfony/polyfill-ctype/Ctype.php
Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.

... See full list

File

vendor/symfony/polyfill-ctype/Ctype.php, line 211

Class

Ctype
Ctype implementation through regex.

Namespace

Symfony\Polyfill\Ctype

Code

private static function convert_int_to_char_for_ctype($int) {
  if (!\is_int($int)) {
    return $int;
  }
  if ($int < -128 || $int > 255) {
    return (string) $int;
  }
  if ($int < 0) {
    $int += 256;
  }
  return \chr($int);
}