\rex_string

String utility class.

Summary

Methods
Properties
Constants
size()
normalizeEncoding()
normalize()
split()
versionSplit()
versionCompare()
yamlEncode()
yamlDecode()
buildQuery()
buildAttributes()
highlight()
sanitizeHtml()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

size()

size(string  $string) : int

Returns the string size in bytes.

Parameters

string $string

String

Returns

int —

Size in bytes

normalizeEncoding()

normalizeEncoding(string  $string) : string

Normalizes the encoding of a string (UTF8 NFD to NFC).

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.

Parameters

string $string

Input string

Returns

string —

normalize()

normalize(string  $string, string  $replaceChar = '_', string  $allowedChars = '') : string

Normalizes a string.

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.

Parameters

string $string

Input string

string $replaceChar

Character that is used to replace not allowed chars

string $allowedChars

Allowed character list

Returns

string —

split()

split(string  $string) : array

Splits a string by spaces (Strings with quotes will be regarded).

Examples: "a b 'c d'" -> array('a', 'b', 'c d') "a=1 b='c d'" -> array('a' => 1, 'b' => 'c d')

Parameters

string $string

Returns

array —

versionSplit()

versionSplit(mixed  $version) : mixed

Parameters

mixed $version

Returns

mixed —

versionCompare()

versionCompare(mixed  $version1, mixed  $version2, mixed  $comparator = null) : mixed

Parameters

mixed $version1
mixed $version2
mixed $comparator

Returns

mixed —

yamlEncode()

yamlEncode(array  $value, int  $inline = 3) : string

Returns a string containing the YAML representation of $value.

Parameters

array $value

The value being encoded

int $inline

The level where you switch to inline YAML

Returns

string —

yamlDecode()

yamlDecode(string  $value) : array

Parses YAML into a PHP array.

Parameters

string $value

YAML string

Throws

\rex_yaml_parse_exception

Returns

array —

buildQuery()

buildQuery(array  $params, string  $argSeparator = '&') : string

Generates URL-encoded query string.

Parameters

array $params
string $argSeparator

Returns

string —

buildAttributes()

buildAttributes(array  $attributes) : string

Returns a string by key="value" pair.

Parameters

array $attributes

Returns

string —

highlight()

highlight(string  $string) : string

Highlights a string.

Parameters

string $string

Returns

string —

sanitizeHtml()

sanitizeHtml(string  $html) : string

Cleanup the given html string and removes possible malicious codes/markup.

Parameters

string $html

Returns

string —