PHP Класс Jyxo\StringUtil

Автор: Jan Tichý
Автор: Jakub Tománek
Автор: Jaroslav Hanslík
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Описание методов

crc() публичный статический Метод

Generates a crc checksum same on 32 and 64-bit platforms.
public static crc ( string $string ) : integer
$string string Input string
Результат integer

cut() публичный статический Метод

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
Результат string

cutWords() публичный статический Метод

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
Результат string

escape() публичный статический Метод

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
Результат string

fixLineEnding() публичный статический Метод

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
Результат string

formatBytes() публичный статический Метод

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
Результат string

lcfirst() публичный статический Метод

Works correctly with multibyte encodings.
public static lcfirst ( string $string ) : string
$string string Input string
Результат string

obfuscateEmail() публичный статический Метод

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
Результат string

random() публичный статический Метод

Generates a random string of given length.
public static random ( integer $length ) : string
$length integer String length
Результат string