PHP Class Jyxo\StringUtil

Author: Jan Tichý
Author: Jakub Tománek
Author: Jaroslav Hanslík
Afficher le fichier Open project: jyxo/php Class Usage Examples

Méthodes publiques

Méthode Description
crc ( string $string ) : integer Generates a crc checksum same on 32 and 64-bit platforms.
cut ( string $string, integer $max = 50, string $etc = '...' ) : string Trims a string to given length.
cutWords ( string $string, integer $length = 25, string $etc = '...' ) : string Trims all words in a string longer than given length.
escape ( string $string, integer $quoteStyle = ENT_QUOTES, boolean $doubleEncode = false ) : string Htmlspecialchars function alias with some parameters automatically set.
fixLineEnding ( string $string, string $lineEnd = " " ) : string Fixes and unifies line endings in a string.
formatBytes ( float $size, string $decimalPoint = ',', string $thousandsSeparator = ' ' ) : string Converts given size in bytes to kB, MB, GB, TB or PB and appends the appropriate unit.
lcfirst ( string $string ) : string Converts first character of a string to lowercase.
obfuscateEmail ( string $email, boolean $comment = false ) : string Obfuscates an email address.
random ( integer $length ) : string Generates a random string of given length.

Method Details

crc() public static méthode

Generates a crc checksum same on 32 and 64-bit platforms.
public static crc ( string $string ) : integer
$string string Input string
Résultat integer

cut() public static méthode

Trims at word boundaries (all non-alphanumeric characters are considered delimiters). If the given string is trimmed, an "etc" is added at the end. Its length is also considered.
public static cut ( string $string, integer $max = 50, string $etc = '...' ) : string
$string string Trimmed string
$max integer Maximum length
$etc string "etc" definition
Résultat string

cutWords() public static méthode

String is delimited by whitespaces. If a word is trimmed, an "etc" is added at the end. Its length is also considered.
public static cutWords ( string $string, integer $length = 25, string $etc = '...' ) : string
$string string Processed string
$length integer Maximum word length
$etc string "etc" definition
Résultat string

escape() public static méthode

Htmlspecialchars function alias with some parameters automatically set.
public static escape ( string $string, integer $quoteStyle = ENT_QUOTES, boolean $doubleEncode = false ) : string
$string string Input string
$quoteStyle integer Quote style
$doubleEncode boolean Prevent from double encoding
Résultat string

fixLineEnding() public static méthode

Fixes and unifies line endings in a string.
public static fixLineEnding ( string $string, string $lineEnd = " " ) : string
$string string String to fix
$lineEnd string Desired line ending
Résultat string

formatBytes() public static méthode

Converts given size in bytes to kB, MB, GB, TB or PB and appends the appropriate unit.
public static formatBytes ( float $size, string $decimalPoint = ',', string $thousandsSeparator = ' ' ) : string
$size float Input size
$decimalPoint string Decimal point
$thousandsSeparator string Thousands separator
Résultat string

lcfirst() public static méthode

Works correctly with multibyte encodings.
public static lcfirst ( string $string ) : string
$string string Input string
Résultat string

obfuscateEmail() public static méthode

Obfuscates an email address.
public static obfuscateEmail ( string $email, boolean $comment = false ) : string
$email string Email address
$comment boolean Put a comment into the address
Résultat string

random() public static méthode

Generates a random string of given length.
public static random ( integer $length ) : string
$length integer String length
Résultat string