Property | Type | Description | |
---|---|---|---|
$_source | Closure | A closure which, given a number of bytes, returns that amount of random bytes. |
Method | Description | |
---|---|---|
clean ( string $str, array $options = [] ) : string | Cleans up a String::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 String::insert(). | |
compare ( string $known, string $user ) : boolean | Compares two strings in constant time to prevent timing attacks. | |
extract ( string $regex, string $str, integer $index ) : mixed | Extract a part of a string based on a regular expression $regex. | |
hash ( string $string, array $options = [] ) : string | Uses PHP's hashing functions to create a hash of the string provided, using the options specified. The default hash algorithm is SHA-512. | |
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. | |
random ( integer $bytes, array $options = [] ) : string | Generates random bytes for use in UUIDs and password salts, using (when available) a cryptographically strong random number generator. | |
tokenize ( string $data, array $options = [] ) : array | Tokenizes a string using $options['separator'], ignoring any instances of $options['separator'] that appear between $options['leftBound'] and $options['rightBound']. | |
uuid ( ) : string | Generates an RFC 4122-compliant version 4 UUID. |
Method | Description | |
---|---|---|
_source ( ) : Closure | Initializes String::$_source using the best available random number generator. |
public static clean ( string $str, array $options = [] ) : string | ||
$str | string | The string to clean. |
$options | array | Available options are: - `'after'`: characters marking the end of targeted substring. - `'andText'`: (defaults to `true`). - `'before'`: characters marking the start of targeted substring. - `'clean'`: `true` or an array of clean options: - `'gap'`: Regular expression matching gaps. - `'method'`: Either `'text'` or `'html'` (defaults to `'text'`). - `'replacement'`: String to use for cleaned substrings (defaults to `''`). - `'word'`: Regular expression matching words. |
return | string | The cleaned string. |
public static hash ( string $string, array $options = [] ) : string | ||
$string | string | The string to hash. |
$options | array | Supported options: - `'type'` _string_: Any valid hashing algorithm. See the `hash_algos()` function to determine which are available on your system. - `'salt'` _string_: A _salt_ value which, if specified, will be prepended to the string. - `'key'` _string_: If specified `hash_hmac()` will be used to hash the string, instead of `hash()`, with `'key'` being used as the message key. - `'raw'` _boolean_: If `true`, outputs the raw binary result of the hash operation. Defaults to `false`. |
return | string | Returns a hashed string. |
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: - `'after'`: The character or string after the name of the variable place-holder (defaults to `}`). - `'before'`: The character or string in front of the name of the variable place-holder (defaults to `'{:'`). - `'clean'`: A boolean or array with instructions for `String::clean()`. - `'escape'`: The character or string used to escape the before character or string (defaults to `'\'`). - `'format'`: A regular expression to use for matching variable place-holders (defaults to `'/(? |
return | string |
public static random ( integer $bytes, array $options = [] ) : string | ||
$bytes | integer | The number of random bytes to generate. |
$options | array | The options used when generating random bytes: - `'encode'` _integer_: If specified, and set to `String::ENCODE_BASE_64`, the resulting value will be base64-encoded, per the notes above. |
return | string | Returns a string of random bytes. |
public static tokenize ( string $data, array $options = [] ) : array | ||
$data | string | The data to tokenize. |
$options | array | Options to use when tokenizing: -`'separator'` _string_: The token to split the data on. -`'leftBound'` _string_: Left scope-enclosing boundary. -`'rightBound'` _string_: Right scope-enclosing boundary. |
return | array | Returns an array of tokens. |
protected static Closure $_source | ||
return | Closure |