Methods

uuid()

uuid() : string

Generate a UUID (GUID)

Returns

string

append()

append(string  $str) : $this

Appends the given string to the current string.

Parameters

string $str

String you wish to append

Returns

$this

prepend()

prepend(string  $str) : $this

Prepend the given string to the current string.

Parameters

string $str

String you wish to append

Returns

$this

trim()

trim(string|null  $char = null) : $this

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

Parameters

string|null $char

Char you want to trim.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

caseLower()

caseLower() : $this

Make a string lowercase.

Returns

$this

caseUpper()

caseUpper() : $this

Make a string uppercase.

Returns

$this

caseFirstUpper()

caseFirstUpper() : $this

Transforms the whole string to lower case, but the first char will be upper case.

See also: charFirstUpper

Returns

$this

caseWordUpper()

caseWordUpper() : $this

Make the first character of every word upper.

Returns

$this

caseFirstLower()

caseFirstLower() : $this

Make the first character lowercase.

Returns

$this

charFirstUpper()

charFirstUpper() : $this

Make the first character uppercase.

See also: caseFirstUpper

Returns

$this

nl2br()

nl2br() : $this

Inserts HTML line breaks before all newlines in a string.

Returns

$this

br2nl()

br2nl() : $this

Replace HTML line break with newline character.

Returns

$this

stripTrailingSlash()

stripTrailingSlash() : $this

Strips trailing slash from the current string.

If there are two or more slashes at the end of the string, all of them will be stripped.

Returns

$this

stripStartingSlash()

stripStartingSlash() : $this

Strips a slash from the start of the string.

If there are two or more slashes at the beginning of the string, all of them will be stripped.

Returns

$this

trimLeft()

trimLeft(string  $char) : $this

Strip the $char from the start of the string.

Parameters

string $char

Char you want to trim.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

trimRight()

trimRight(string  $char) : $this

Strip the $char from the end of the string.

Parameters

string $char

Char you want to trim.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

subString()

subString(integer  $startPosition, integer  $length) : $this

Returns a substring from the current string.

Parameters

integer $startPosition

From which char position will the substring start.

integer $length

Where will the substring end. If 0 - to the end of string.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

replace()

replace(string|array  $search, string|array  $replace) : $this

Replaces the occurrences of $search inside the current string with $replace.

This function is CASE-INSENSITIVE.

Parameters

string|array $search

String, or array of strings, that will replaced.

string|array $replace

String, or array of strings, with whom $search occurrences will be replaced.

Returns

$this

pregReplace()

pregReplace(string  $pattern, mixed  $replacement, integer  $limit = -1, null  $count = null) : $this

Replace string using regex

Parameters

string $pattern

The pattern to search for. It can be either a string or an array with strings.

mixed $replacement

The string or an array with strings to replace.

integer $limit

The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).

null $count

If specified, this variable will be filled with the number of replacements done.

Returns

$this

explode()

explode(string  $delimiter, null|integer  $limit = null) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

Explode the current string with the given delimiter and return ArrayObject with the exploded values.

Parameters

string $delimiter

String upon which the current string will be exploded.

null|integer $limit

Limit the number of exploded items.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

ArrayObject object containing exploded values.

split()

split(integer  $chunkSize = 1) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

Split the string into chunks.

Parameters

integer $chunkSize

Size of each chunk. Set it to 1 if you want to get all the characters from the string.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject

ArrayObject containing string chunks.

hash()

hash(string  $algo = 'sha1') : $this

Generate a hash value from the current string using the defined algorithm.

Parameters

string $algo

Name of the algorithm used for calculation (md5, sha1, ripemd160,...).

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

htmlEntityDecode()

htmlEntityDecode() : $this

Decode html entities in the current string.

Returns

$this

htmlEntityEncode()

htmlEntityEncode(string|null  $flags = null, string  $encoding = 'UTF-8') : $this

Convert all HTML entities to their applicable characters.

For more info visit: http://www.php.net/manual/en/function.htmlentities.php

Parameters

string|null $flags

Default flags are set to ENT_COMPAT | ENT_HTML401

string $encoding

Which encoding will be used in the conversion. Default is UTF-8.

Returns

$this

addSlashes()

addSlashes() : $this

Quote string slashes.

To remove slashes use StringObject::stripSlashes().

Returns

$this

stripSlashes()

stripSlashes() : $this

Un-quote string quoted with StringObject::addSlashes()

Returns

$this

chunkSplit()

chunkSplit(integer  $chunkSize = 76, string  $endChar = "\n") : $this

Split the string into chunks with each chunk ending with $endChar.

This function is multi-byte safe.

Parameters

integer $chunkSize

Size of each chunk.

string $endChar

String that will be appended to the end of each chunk.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

md5()

md5() : $this

Hash current string using md5 algorithm.

Returns

$this

crc32()

crc32() : $this

Calculates the crc32 polynomial of a string.

Returns

$this

sha1()

sha1() : $this

Calculate the sha1 hash of a string.

Returns

$this

quoteMeta()

quoteMeta() : $this

Quote meta characters.

Meta characters are: . \ + * ? [ ^ ] ( $ )

Returns

$this

format()

format(string|array  $args) : $this

Format the string according to the provided $format.

Parameters

string|array $args

Arguments used for string formatting. For more info visit http://www.php.net/manual/en/function.sprintf.php

Returns

$this

padLeft()

padLeft(integer  $length, string  $padString) : $this

Pad the string to a certain length with another string.

Parameters

integer $length

Length to which to pad.

string $padString

String that will be appended.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

padRight()

padRight(integer  $length, string  $padString) : $this

Pad the string to a certain length with another string.

Parameters

integer $length

Length to which to pad.

string $padString

String that will be appended.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

padBoth()

padBoth(integer  $length, string  $padString) : $this

Pad the string to a certain length with another string.

Parameters

integer $length

Length to which to pad.

string $padString

String that will be appended.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

repeat()

repeat(integer  $multiplier) : $this

Repeats the current string $multiplier times.

Parameters

integer $multiplier

How many times to repeat the string.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

shuffle()

shuffle() : $this

Shuffle characters in current string.

Returns

$this

stripTags()

stripTags(string  $whiteList = '') : $this

Remove HTML tags from the string.

Parameters

string $whiteList

A list of allowed HTML tags that you don't want to strip. Example: '

'

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

reverse()

reverse() : $this

Reverse the string.

Returns

$this

wordWrap()

wordWrap(integer  $length, string  $break = "\n", boolean  $cut = false) : $this

Wraps a string to a given number of characters using a string break character.

Parameters

integer $length

The number of characters at which the string will be wrapped.

string $break

The line is broken using the optional break parameter.

boolean $cut

If the cut is set to TRUE, the string is always wrapped at or before the specified width. So if you have a word that is larger than the given width, it is broken apart.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

truncate()

truncate(integer  $length, string  $ellipsis = '') : $this

Truncate the string to the given length without breaking words.

Parameters

integer $length

Length to which you which to trim.

string $ellipsis

Ellipsis is calculated in the string $length.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

$this

match()

match(string  $regEx, boolean  $matchAll = true) : \app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject|boolean

Preg matches current string against the given regular expression.

If you just wish if string is contained within the current string, use StringObject::contains().

Parameters

string $regEx

Regular expression to match.

boolean $matchAll

Use preg_match_all, or just preg_match. Default is preg_match_all.

Throws

\app\framework\Component\StdLib\StdObject\StringObject\StringObjectException

Returns

\app\framework\Component\StdLib\StdObject\ArrayObject\ArrayObject|boolean —

If there are matches, an ArrayObject with the the $matches is returned, else, false is returned.

urlEncode()

urlEncode() : $this

Url encodes the current string.

Returns

$this

urlDecode()

urlDecode() : $this

Url decodes the current string.

Returns

$this

base64Encode()

base64Encode(boolean  $webSafe = false) : $this

Encode string using base64_encode

Parameters

boolean $webSafe

Web safe encoding (replaces '+' with '-' and '/' with '_' after encoding)

Returns

$this

base64Decode()

base64Decode(boolean  $webSafe = false) : $this

Decode base64 encoded string

Parameters

boolean $webSafe

Web sage decoding (replaces '-' with '+' and '_' with '/' before decoding)

Returns

$this

slug()

slug() : $this

Create a slug

Returns

$this

kebabCase()

kebabCase() : $this

Convert string to kebab-case

Returns

$this

snakeCase()

snakeCase() : $this

Convert string to snake_case

Returns

$this

pascalCase()

pascalCase() : $this

Convert string to PascalCase

Returns

$this

camelCase()

camelCase() : $this

Convert string to camelCase

Returns

$this

sentenceCase()

sentenceCase() : $this

Convert string to kebab-case

Returns

$this

singularize()

singularize() : $this

Convert string to its singular form

Returns

$this

pluralize()

pluralize() : $this

Convert string to its plural form

Returns

$this