Ciconia / A New Markdown Parser for #PHP

class Text implements Serializable

Methods

__construct(string $text = '')
Text append(string $text)
Text prepend(string $text)
Text wrap(string $start, string $end)

Surround text with given string

Text lower()

Make a string lowercase

Text upper()

Make a string uppercase

Text trim(string $charList = null)

Strip whitespace (or other characters) from the beginning and end of a string

Text rtrim(string $charList = null)

Strip whitespace (or other characters) from the end of a string

bool isEmpty()
bool contains(string $text)

Checks whether the text contains $text

Text escapeHtml(int $option = ENT_QUOTES)

Convert special characters to HTML entities

Text replace(string $pattern, string|callable $replacement)

Perform a regular expression search and replace

Text replaceString(string|array $search, string|array $replace)

Replace all occurrences of the search string with the replacement string

boolean match(string $pattern, array|null $matches = null)

Perform a regular expression match

Text[]|Collection split(string $pattern, int $flags = PREG_SPLIT_DELIM_CAPTURE)

Split string by a regular expression

int getLength()

Gets the length of a string

setString(Text $text)

Set internal string value

string getString()

Returns internal string value

string __toString()
string serialize()

String representation of object

unserialize(string $serialized)

Constructs the object

Details

at line 19 public __construct(string $text = '')

Parameters

string $text

at line 29 public Text append(string $text)

Parameters

string $text

Return Value

Text

at line 41 public Text prepend(string $text)

Parameters

string $text

Return Value

Text

at line 56 public Text wrap(string $start, string $end)

Surround text with given string

Parameters

string $start
string $end

Return Value

Text

at line 68 public Text lower()

Make a string lowercase

Return Value

Text

at line 80 public Text upper()

Make a string uppercase

Return Value

Text

at line 95 public Text trim(string $charList = null)

Strip whitespace (or other characters) from the beginning and end of a string

Parameters

string $charList Optionally, the stripped characters can also be specified using the charlist parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.

Return Value

Text

at line 114 public Text rtrim(string $charList = null)

Strip whitespace (or other characters) from the end of a string

Parameters

string $charList You can also specify the characters you want to strip, by means of the charlist parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.

Return Value

Text

at line 128 public bool isEmpty()

Return Value

bool

at line 140 public bool contains(string $text)

Checks whether the text contains $text

Parameters

string $text A string to test

Return Value

bool True if the text contains $text

at line 152 public Text escapeHtml(int $option = ENT_QUOTES)

Convert special characters to HTML entities

Parameters

int $option

Return Value

Text

at line 168 public Text replace(string $pattern, string|callable $replacement)

Perform a regular expression search and replace

Parameters

string $pattern The pattern to search for. It can be either a string or an array with strings.
string|callable $replacement The string or an array with strings to replace. If $replacement is the callable, a callback that will be called and passed an array of matched elements in the subject string.

Return Value

Text

at line 193 public Text replaceString(string|array $search, string|array $replace)

Replace all occurrences of the search string with the replacement string

Parameters

string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
string|array $replace The replacement value that replaces found search values. An array may be used to designate multiple replacements.

Return Value

Text

at line 208 public boolean match(string $pattern, array|null $matches = null)

Perform a regular expression match

Parameters

string $pattern The pattern to search for, as a string.
array|null $matches If matches is provided, then it is filled with the results of search.

Return Value

boolean

at line 221 public Text[]|Collection split(string $pattern, int $flags = PREG_SPLIT_DELIM_CAPTURE)

Split string by a regular expression

Parameters

string $pattern The pattern to search for, as a string.
int $flags [optional] PREGSPLITNOEMPTY|PREGSPLITDELIMCAPTURE|PREGSPLITOFFSET_CAPTURE

Return Value

Text[]|Collection

at line 236 public int getLength()

Gets the length of a string

Return Value

int Returns the number of characters in string str having character encoding encoding. A multi-byte character is counted as 1.

at line 252 public setString(Text $text)

Set internal string value

Parameters

Text $text

at line 262 public string getString()

Returns internal string value

Return Value

string

at line 270 public string __toString()

Return Value

string

at line 280 public string serialize()

String representation of object

Return Value

string the string representation of the object or null

at line 290 public unserialize(string $serialized)

Constructs the object

Parameters

string $serialized The string representation of the object.