PHP Class rex_string, redaxo

Datei anzeigen Open project: redaxo/redaxo Class Usage Examples

Public Methods

Method Description
buildAttributes ( array $attributes ) : string Returns a string by key="value" pair.
buildQuery ( array $params, string $argSeparator = '&' ) : string Generates URL-encoded query string.
highlight ( string $string ) : string Highlights a string.
normalize ( string $string, string $replaceChar = '_', string $allowedChars = '' ) : string Normalizes a string.
normalizeEncoding ( string $string ) : string Normalizes the encoding of a string (UTF8 NFD to NFC).
size ( string $string ) : integer Returns the string size in bytes.
split ( string $string ) : array Splits a string by spaces (Strings with quotes will be regarded).
versionCompare ( string $version1, string $version2, string $comparator = null ) : integer | boolean Compares two version number strings.
versionSplit ( string $version ) : array Splits a version string.
yamlDecode ( string $value ) : array Parses YAML into a PHP array.
yamlEncode ( array $value, integer $inline = 3 ) : string Returns a string containing the YAML representation of $value.

Method Details

buildAttributes() public static method

Returns a string by key="value" pair.
public static buildAttributes ( array $attributes ) : string
$attributes array
return string

buildQuery() public static method

Generates URL-encoded query string.
public static buildQuery ( array $params, string $argSeparator = '&' ) : string
$params array
$argSeparator string
return string

highlight() public static method

Highlights a string.
public static highlight ( string $string ) : string
$string string
return string

normalize() public static method

Makes the string lowercase, replaces umlauts by their ascii representation (รค -> ae etc.), and replaces all other chars that do not match a-z, 0-9 or $allowedChars by $replaceChar.
public static normalize ( string $string, string $replaceChar = '_', string $allowedChars = '' ) : string
$string string Input string
$replaceChar string Character that is used to replace not allowed chars
$allowedChars string Character whitelist
return string

normalizeEncoding() public static method

On HFS+ filesystem (OS X) filenames are stored in UTF8 NFD while all other filesystems are using UTF8 NFC. NFC is more common in general.
public static normalizeEncoding ( string $string ) : string
$string string Input string
return string

size() public static method

Returns the string size in bytes.
public static size ( string $string ) : integer
$string string String
return integer Size in bytes

split() public static method

Examples: "a b 'c d'" -> array('a', 'b', 'c d') "a=1 b='c d'" -> array('a' => 1, 'b' => 'c d')
public static split ( string $string ) : array
$string string
return array

versionCompare() public static method

In contrast to version_compare() it treats "1.0" and "1.0.0" as equal and it supports a space as separator for the version parts, e.g. "1.0 beta1"
See also: http://www.php.net/manual/en/function.version-compare.php
public static versionCompare ( string $version1, string $version2, string $comparator = null ) : integer | boolean
$version1 string First version number
$version2 string Second version number
$comparator string Optional comparator
return integer | boolean

versionSplit() public static method

Splits a version string.
public static versionSplit ( string $version ) : array
$version string Version
return array Version parts

yamlDecode() public static method

Parses YAML into a PHP array.
public static yamlDecode ( string $value ) : array
$value string YAML string
return array

yamlEncode() public static method

Returns a string containing the YAML representation of $value.
public static yamlEncode ( array $value, integer $inline = 3 ) : string
$value array The value being encoded
$inline integer The level where you switch to inline YAML
return string