String handling methods.


    class StringUtility {



    • cleanInsert() — Cleans up a StringUtility::insert() formatted string with given $options depending on the 'clean' key in $options. The default method used is text but html is also available. The goal of this function is to replace all whitespace and unneeded markup around placeholders that did not get replaced by StringUtility::insert().
    • excerpt() — Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
    • highlight() — Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.
    • insert() — Replaces variable placeholders inside a $str with any given $data. Each key in the $data array corresponds to a variable placeholder name in $str.
    • tail() — Truncates text starting from the end.
    • toList() — Creates a comma separated list where the last two items are joined with 'and', forming natural English
    • tokenize() — Tokenizes a string using $separator, ignoring any instance of $separator that appears between $leftBound and $rightBound.
    • truncate() — Truncates text.
    • uuid() — Generate a random UUID
    • wordWrap() — Unicode aware version of wordwrap.
    • wrap() — Wraps text to a specific width, can optionally wrap at word breaks.