PHP Класс kahlan\util\Text

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
clean ( string $str, array $options = [] ) : string Cleans up a Text::insert() formatted string with given $options depending on the 'clean' option. The goal of this function is to replace all whitespace and unneeded mark-up around place-holders that did not get replaced by Text::insert().
dump ( mixed $value, $quote = '"' ) : string Dump some scalar data using a string representation
insert ( string $str, array $data, array $options = [] ) : string Replaces variable placeholders inside a string with any given data. Each key in the $data array corresponds to a variable placeholder name in $str.
toString ( string $value, array $options = [] ) : string Generate a string representation of arbitrary data.

Защищенные методы

Метод Описание
_arrayToString ( array $datas, array $options ) : string Generate a string representation of an array.
_dump ( string $string ) : string Expands escape sequences and escape special chars in a string.
_objectToString ( array $value, $options ) : string Generate a string representation of an object.

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

_arrayToString() защищенный статический Метод

Generate a string representation of an array.
protected static _arrayToString ( array $datas, array $options ) : string
$datas array An array.
$options array An array of options.
Результат string The dumped string.

_dump() защищенный статический Метод

Expands escape sequences and escape special chars in a string.
protected static _dump ( string $string ) : string
$string string A string which contain escape sequence.
Результат string A valid double quotable string.

_objectToString() защищенный статический Метод

Generate a string representation of an object.
protected static _objectToString ( array $value, $options ) : string
$value array The object.
Результат string The dumped string.

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

Cleans up a Text::insert() formatted string with given $options depending on the 'clean' option. The goal of this function is to replace all whitespace and unneeded mark-up around place-holders that did not get replaced by Text::insert().
public static clean ( string $str, array $options = [] ) : string
$str string The string to clean.
$options array Available options are: - `'before'`: characters marking the start of targeted substring. - `'after'`: characters marking the end of targeted substring. - `'escape'`: The character or string used to escape the before character or string (defaults to `'\\'`). - `'gap'`: Regular expression matching gaps. - `'word'`: Regular expression matching words. - `'replacement'`: String to use for cleaned substrings (defaults to `''`).
Результат string The cleaned string.

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

Dump some scalar data using a string representation
public static dump ( mixed $value, $quote = '"' ) : string
$value mixed The scalar data to dump
Результат string The dumped string.

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

Usage: {{{ Text::insert( 'My name is {:name} and I am {:age} years old.', ['name' => 'Bob', 'age' => '65'] ); }}}
public static insert ( string $str, array $data, array $options = [] ) : string
$str string A string containing variable place-holders.
$data array A key, value array where each key stands for a place-holder variable name to be replaced with value.
$options array Available options are: - `'before'`: The character or string in front of the name of the variable place-holder (defaults to `'{:'`). - `'after'`: The character or string after the name of the variable place-holder (defaults to `}`). - `'escape'`: The character or string used to escape the before character or string (defaults to `'\\'`). - `'clean'`: A boolean or array with instructions for `Text::clean()`.
Результат string

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

Generate a string representation of arbitrary data.
public static toString ( string $value, array $options = [] ) : string
$value string The data to dump in string.
$options array Available options are: - `'quote'` : dump will quote string data if true (default `true`). - `'object'`: dump options for objects. - `'method'`: default method to call on string instance (default `__toString`). - `'array'` : dump options for arrays. - `'indent'`: level of indent (defaults to `1`). - `'char'`: indentation character. - `'multiplier'`: number of indentation character per indent (default `4`)
Результат string The dumped string.