PHP Trait Webiny\Component\StdLib\StdObject\StringObject\ManipulatorTrait

Inheritance: use trait Webiny\Component\StdLib\StdObject\StdObjectManipulatorTrait
Mostrar archivo Open project: Webiny/Framework

Public Methods

Method Description
addSlashes ( ) Quote string slashes.
append ( string $str ) Appends the given string to the current string.
base64Decode ( boolean $webSafe = false ) Decode base64 encoded string
base64Encode ( boolean $webSafe = false ) Encode string using base64_encode
br2nl ( ) Replace HTML line break with newline character.
camelCase ( ) Convert string to camelCase
caseFirstLower ( ) Make the first character lowercase.
caseFirstUpper ( ) Transforms the whole string to lower case, but the first char will be upper case.
caseLower ( ) Make a string lowercase.
caseUpper ( ) Make a string uppercase.
caseWordUpper ( ) Make the first character of every word upper.
charFirstUpper ( ) Make the first character uppercase.
chunkSplit ( integer $chunkSize = 76, string $endChar = " " ) Split the string into chunks with each chunk ending with $endChar.
crc32 ( ) Calculates the crc32 polynomial of a string.
explode ( string $delimiter, null | integer $limit = null ) : ArrayObject Explode the current string with the given delimiter and return ArrayObject with the exploded values.
format ( string | array $args ) Format the string according to the provided $format.
hash ( string $algo = 'sha1' ) Generate a hash value from the current string using the defined algorithm.
htmlEntityDecode ( ) Decode html entities in the current string.
htmlEntityEncode ( string | null $flags = null, string $encoding = 'UTF-8' ) Convert all HTML entities to their applicable characters.
kebabCase ( ) Convert string to kebab-case
match ( string $regEx, boolean $matchAll = true ) : ArrayObject | boolean Preg matches current string against the given regular expression.
md5 ( ) Hash current string using md5 algorithm.
nl2br ( ) Inserts HTML line breaks before all newlines in a string.
padBoth ( integer $length, string $padString ) Pad the string to a certain length with another string.
padLeft ( integer $length, string $padString ) Pad the string to a certain length with another string.
padRight ( integer $length, string $padString ) Pad the string to a certain length with another string.
parseString ( ) : ArrayObject Parse current string as a query string and return ArrayObject with results.
pascalCase ( ) Convert string to PascalCase
pluralize ( ) Convert string to its plural form
pregReplace ( string $pattern, mixed $replacement, integer $limit, null &$count = null ) Replace string using regex
prepend ( string $str ) Prepend the given string to the current string.
quoteMeta ( ) Quote meta characters.
repeat ( integer $multiplier ) Repeats the current string $multiplier times.
replace ( string | array $search, string | array $replace ) Replaces the occurrences of $search inside the current string with $replace.
reverse ( ) Reverse the string.
sentenceCase ( ) Convert string to kebab-case
sha1 ( ) Calculate the sha1 hash of a string.
shuffle ( ) Shuffle characters in current string.
singularize ( ) Convert string to its singular form
slug ( ) Create a slug
snakeCase ( ) Convert string to snake_case
split ( integer $chunkSize = 1 ) : ArrayObject Split the string into chunks.
stripSlashes ( ) Un-quote string quoted with StringObject::addSlashes()
stripStartingSlash ( ) Strips a slash from the start of the string.
stripTags ( string $whiteList = '' ) Remove HTML tags from the string.
stripTrailingSlash ( ) Strips trailing slash from the current string.
subString ( integer $startPosition, integer $length ) Returns a substring from the current string.
trim ( string | null $char = null ) Strip whitespace (or other characters) from the beginning and end of a string.
trimLeft ( string $char ) Strip the $char from the start of the string.
trimRight ( string $char ) Strip the $char from the end of the string.
truncate ( integer $length, string $ellipsis = '' ) Truncate the string to the given length without breaking words.
urlDecode ( ) Url decodes the current string.
urlEncode ( ) Url encodes the current string.
uuid ( ) : string Generate a UUID (GUID)
wordWrap ( integer $length, string $break = " ", boolean $cut = false ) Wraps a string to a given number of characters using a string break character.

Method Details

addSlashes() public method

To remove slashes use StringObject::stripSlashes().
public addSlashes ( )

append() public method

Appends the given string to the current string.
public append ( string $str )
$str string String you wish to append

base64Decode() public method

Decode base64 encoded string
public base64Decode ( boolean $webSafe = false )
$webSafe boolean Web sage decoding (replaces '-' with '+' and '_' with '/' before decoding)

base64Encode() public method

Encode string using base64_encode
public base64Encode ( boolean $webSafe = false )
$webSafe boolean Web safe encoding (replaces '+' with '-' and '/' with '_' after encoding)

br2nl() public method

Replace HTML line break with newline character.
public br2nl ( )

camelCase() public method

Convert string to camelCase
public camelCase ( )

caseFirstLower() public method

Make the first character lowercase.
public caseFirstLower ( )

caseFirstUpper() public method

See also: charFirstUpper
public caseFirstUpper ( )

caseLower() public method

Make a string lowercase.
public caseLower ( )

caseUpper() public method

Make a string uppercase.
public caseUpper ( )

caseWordUpper() public method

Make the first character of every word upper.
public caseWordUpper ( )

charFirstUpper() public method

See also: caseFirstUpper
public charFirstUpper ( )

chunkSplit() public method

This function is multi-byte safe.
public chunkSplit ( integer $chunkSize = 76, string $endChar = " " )
$chunkSize integer Size of each chunk.
$endChar string String that will be appended to the end of each chunk.

crc32() public method

Calculates the crc32 polynomial of a string.
public crc32 ( )

explode() public method

Explode the current string with the given delimiter and return ArrayObject with the exploded values.
public explode ( string $delimiter, null | integer $limit = null ) : ArrayObject
$delimiter string String upon which the current string will be exploded.
$limit null | integer Limit the number of exploded items.
return Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject ArrayObject object containing exploded values.

format() public method

Format the string according to the provided $format.
public format ( string | array $args )
$args string | array Arguments used for string formatting. For more info visit http://www.php.net/manual/en/function.sprintf.php

hash() public method

Generate a hash value from the current string using the defined algorithm.
public hash ( string $algo = 'sha1' )
$algo string Name of the algorithm used for calculation (md5, sha1, ripemd160,...).

htmlEntityDecode() public method

Decode html entities in the current string.
public htmlEntityDecode ( )

htmlEntityEncode() public method

For more info visit: http://www.php.net/manual/en/function.htmlentities.php
public htmlEntityEncode ( string | null $flags = null, string $encoding = 'UTF-8' )
$flags string | null Default flags are set to ENT_COMPAT | ENT_HTML401
$encoding string Which encoding will be used in the conversion. Default is UTF-8.

kebabCase() public method

Convert string to kebab-case
public kebabCase ( )

match() public method

If you just wish if string is contained within the current string, use StringObject::contains().
public match ( string $regEx, boolean $matchAll = true ) : ArrayObject | boolean
$regEx string Regular expression to match.
$matchAll boolean Use preg_match_all, or just preg_match. Default is preg_match_all.
return Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject | boolean If there are matches, an ArrayObject with the the $matches is returned, else, false is returned.

md5() public method

Hash current string using md5 algorithm.
public md5 ( )

nl2br() public method

Inserts HTML line breaks before all newlines in a string.
public nl2br ( )

padBoth() public method

Pad the string to a certain length with another string.
public padBoth ( integer $length, string $padString )
$length integer Length to which to pad.
$padString string String that will be appended.

padLeft() public method

Pad the string to a certain length with another string.
public padLeft ( integer $length, string $padString )
$length integer Length to which to pad.
$padString string String that will be appended.

padRight() public method

Pad the string to a certain length with another string.
public padRight ( integer $length, string $padString )
$length integer Length to which to pad.
$padString string String that will be appended.

parseString() public method

Parse current string as a query string and return ArrayObject with results.
public parseString ( ) : ArrayObject
return Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject ArrayObject from the parsed string.

pascalCase() public method

Convert string to PascalCase
public pascalCase ( )

pluralize() public method

Convert string to its plural form
public pluralize ( )

pregReplace() public method

TODO: unit test
public pregReplace ( string $pattern, mixed $replacement, integer $limit, null &$count = null )
$pattern string The pattern to search for. It can be either a string or an array with strings.
$replacement mixed The string or an array with strings to replace.
$limit integer The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
$count null If specified, this variable will be filled with the number of replacements done.

prepend() public method

Prepend the given string to the current string.
public prepend ( string $str )
$str string String you wish to append

quoteMeta() public method

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

repeat() public method

Repeats the current string $multiplier times.
public repeat ( integer $multiplier )
$multiplier integer How many times to repeat the string.

replace() public method

This function is CASE-INSENSITIVE.
public replace ( string | array $search, string | array $replace )
$search string | array String, or array of strings, that will replaced.
$replace string | array String, or array of strings, with whom $search occurrences will be replaced.

reverse() public method

Reverse the string.
public reverse ( )

sentenceCase() public method

Convert string to kebab-case
public sentenceCase ( )

sha1() public method

Calculate the sha1 hash of a string.
public sha1 ( )

shuffle() public method

Shuffle characters in current string.
public shuffle ( )

singularize() public method

Convert string to its singular form
public singularize ( )

slug() public method

Create a slug
public slug ( )

snakeCase() public method

Convert string to snake_case
public snakeCase ( )

split() public method

Split the string into chunks.
public split ( integer $chunkSize = 1 ) : ArrayObject
$chunkSize integer Size of each chunk. Set it to 1 if you want to get all the characters from the string.
return Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject ArrayObject containing string chunks.

stripSlashes() public method

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

stripStartingSlash() public method

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

stripTags() public method

Remove HTML tags from the string.
public stripTags ( string $whiteList = '' )
$whiteList string A list of allowed HTML tags that you don't want to strip. Example: '

'

stripTrailingSlash() public method

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

subString() public method

Returns a substring from the current string.
public subString ( integer $startPosition, integer $length )
$startPosition integer From which char position will the substring start.
$length integer Where will the substring end. If 0 - to the end of string.

trim() public method

Strip whitespace (or other characters) from the beginning and end of a string.
public trim ( string | null $char = null )
$char string | null Char you want to trim.

trimLeft() public method

Strip the $char from the start of the string.
public trimLeft ( string $char )
$char string Char you want to trim.

trimRight() public method

Strip the $char from the end of the string.
public trimRight ( string $char )
$char string Char you want to trim.

truncate() public method

Truncate the string to the given length without breaking words.
public truncate ( integer $length, string $ellipsis = '' )
$length integer Length to which you which to trim.
$ellipsis string Ellipsis is calculated in the string $length.

urlDecode() public method

Url decodes the current string.
public urlDecode ( )

urlEncode() public method

Url encodes the current string.
public urlEncode ( )

uuid() public static method

Generate a UUID (GUID)
public static uuid ( ) : string
return string

wordWrap() public method

Wraps a string to a given number of characters using a string break character.
public wordWrap ( integer $length, string $break = " ", boolean $cut = false )
$length integer The number of characters at which the string will be wrapped.
$break string The line is broken using the optional break parameter.
$cut boolean 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.