PHP Class Neos\Eel\Helper\StringHelper

Inheritance: implements Neos\Eel\ProtectedContextAwareInterface
Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Méthodes publiques

Méthode Description
allowsCallOfMethod ( string $methodName ) : boolean All methods are considered safe
charAt ( string $string, integer $index ) : string Get the character at a specific position
crop ( string $string, integer $maximumCharacters, string $suffix = '' ) : string Crop a string to maximumCharacters length, optionally appending suffix if cropping was necessary.
cropAtSentence ( string $string, integer $maximumCharacters, string $suffix = '' ) : string Crop a string to maximumCharacters length, taking sentences into account, optionally appending suffix if cropping was necessary.
cropAtWord ( string $string, integer $maximumCharacters, string $suffix = '' ) : string Crop a string to maximumCharacters length, taking words into account, optionally appending suffix if cropping was necessary.
endsWith ( string $string, string $search, integer $position = null ) : boolean Test if a string ends with the given search string
firstLetterToLowerCase ( string $string ) : string Lowercase the first letter of a string
firstLetterToUpperCase ( string $string ) : string Uppercase the first letter of a string
htmlSpecialChars ( string $string, boolean $preserveEntities = false ) : string Convert special characters to HTML entities
indexOf ( string $string, string $search, integer $fromIndex = null ) : integer Find the first position of a substring in the given string
isBlank ( string $string ) : boolean Test if the given string is blank (empty or consists of whitespace only)
lastIndexOf ( string $string, string $search, integer $toIndex = null ) : integer Find the last position of a substring in the given string
length ( string $string ) : integer Get the length of a string
md5 ( string $string ) : string Calculate the MD5 checksum of the given string
pregMatch ( string $string, string $pattern ) : array Match a string with a regular expression (PREG style)
pregReplace ( string $string, string $pattern, string $replace ) : string Replace occurrences of a search string inside the string using regular expression matching (PREG style)
pregSplit ( string $string, string $pattern, integer $limit = null ) : array Split a string by a separator using regular expression matching (PREG style)
rawUrlDecode ( string $string ) : string Decode the string from URLs according to RFC 3986
rawUrlEncode ( string $string ) : string Encode the string for URLs according to RFC 3986
replace ( string $string, string $search, string $replace ) : string Replace occurrences of a search string inside the string
split ( string $string, string $separator = null, integer $limit = null ) : array Split a string by a separator
startsWith ( string $string, string $search, integer $position = null ) : boolean Test if a string starts with the given search string
stripTags ( string $string, string $allowableTags = null ) : string Strip all HTML tags from the given string
substr ( string $string, integer $start, integer $length = null ) : string Return the characters in a string from start up to the given length
substring ( string $string, integer $start, integer $end = null ) : string Return the characters in a string from a start index to an end index
toBoolean ( string $string ) : boolean Convert a string to boolean
toFloat ( string $string ) : float Convert a string to float
toInteger ( string $string ) : integer Convert a string to integer
toLowerCase ( string $string ) : string Lowercase a string
toString ( mixed $value ) : string Convert the given value to a string
toUpperCase ( string $string ) : string Uppercase a string
trim ( string $string, string $charlist = null ) : string Trim whitespace at the beginning and end of a string

Method Details

allowsCallOfMethod() public méthode

All methods are considered safe
public allowsCallOfMethod ( string $methodName ) : boolean
$methodName string
Résultat boolean

charAt() public méthode

Example:: String.charAt("abcdefg", 5) == "f"
public charAt ( string $string, integer $index ) : string
$string string The input string
$index integer The index to get
Résultat string The character at the given index

crop() public méthode

Crop a string to maximumCharacters length, optionally appending suffix if cropping was necessary.
public crop ( string $string, integer $maximumCharacters, string $suffix = '' ) : string
$string string The input string
$maximumCharacters integer Number of characters where cropping should happen
$suffix string Suffix to be appended if cropping was necessary
Résultat string The cropped string

cropAtSentence() public méthode

Crop a string to maximumCharacters length, taking sentences into account, optionally appending suffix if cropping was necessary.
public cropAtSentence ( string $string, integer $maximumCharacters, string $suffix = '' ) : string
$string string The input string
$maximumCharacters integer Number of characters where cropping should happen
$suffix string Suffix to be appended if cropping was necessary
Résultat string The cropped string

cropAtWord() public méthode

Crop a string to maximumCharacters length, taking words into account, optionally appending suffix if cropping was necessary.
public cropAtWord ( string $string, integer $maximumCharacters, string $suffix = '' ) : string
$string string The input string
$maximumCharacters integer Number of characters where cropping should happen
$suffix string Suffix to be appended if cropping was necessary
Résultat string The cropped string

endsWith() public méthode

Example:: String.endsWith('Hello, World!', 'World!') == true
public endsWith ( string $string, string $search, integer $position = null ) : boolean
$string string The string
$search string A string to search
$position integer Optional position for limiting the string
Résultat boolean TRUE if the string ends with the given search

firstLetterToLowerCase() public méthode

Example:: String.firstLetterToLowerCase('CamelCase') == 'camelCase'
public firstLetterToLowerCase ( string $string ) : string
$string string The input string
Résultat string The string with the first letter in lowercase

firstLetterToUpperCase() public méthode

Example:: String.firstLetterToUpperCase('hello world') == 'Hello world'
public firstLetterToUpperCase ( string $string ) : string
$string string The input string
Résultat string The string with the first letter in uppercase

htmlSpecialChars() public méthode

Convert special characters to HTML entities
public htmlSpecialChars ( string $string, boolean $preserveEntities = false ) : string
$string string The string to convert
$preserveEntities boolean ``true`` if entities should not be double encoded
Résultat string The converted string

indexOf() public méthode

Example:: String.indexOf("Blue Whale", "Blue") == 0
public indexOf ( string $string, string $search, integer $fromIndex = null ) : integer
$string string The input string
$search string The substring to search for
$fromIndex integer The index where the search should start, defaults to the beginning
Résultat integer The index of the substring (>= 0) or -1 if the substring was not found

isBlank() public méthode

Examples:: String.isBlank('') == true String.isBlank(' ') == true
public isBlank ( string $string ) : boolean
$string string The string to test
Résultat boolean ``true`` if the given string is blank

lastIndexOf() public méthode

Example:: String.lastIndexOf("Developers Developers Developers!", "Developers") == 22
public lastIndexOf ( string $string, string $search, integer $toIndex = null ) : integer
$string string The input string
$search string The substring to search for
$toIndex integer The position where the backwards search should start, defaults to the end
Résultat integer The last index of the substring (>=0) or -1 if the substring was not found

length() public méthode

Get the length of a string
public length ( string $string ) : integer
$string string The input string
Résultat integer Length of the string

md5() public méthode

Calculate the MD5 checksum of the given string
public md5 ( string $string ) : string
$string string The string to hash
Résultat string The MD5 hash of ``string``

pregMatch() public méthode

Example:: String.pregMatch("For more information, see Chapter 3.4.5.1", "/(chapter \d+(\.\d)*)/i") == ['Chapter 3.4.5.1', 'Chapter 3.4.5.1', '.1']
public pregMatch ( string $string, string $pattern ) : array
$string string The input string
$pattern string A PREG pattern
Résultat array The matches as array or NULL if not matched

pregReplace() public méthode

Examples:: String.pregReplace("Some.String with sp:cial characters", "/[[:^alnum:]]/", "-") == "Some-String-with-sp-cial-characters" String.pregReplace("2016-08-31", "/([0-9]+)-([0-9]+)-([0-9]+)/", "$3.$2.$1") == "31.08.2016"
public pregReplace ( string $string, string $pattern, string $replace ) : string
$string string The input string
$pattern string A PREG pattern
$replace string A replacement string, can contain references to capture groups with "\\n" or "$n"
Résultat string The string with all occurrences replaced

pregSplit() public méthode

Examples:: String.pregSplit("foo bar baz", "/\s+/") == ['foo', 'bar', 'baz'] String.pregSplit("first second third", "/\s+/", 2) == ['first', 'second third']
public pregSplit ( string $string, string $pattern, integer $limit = null ) : array
$string string The input string
$pattern string A PREG pattern
$limit integer The maximum amount of items to return, in contrast to split() this will return all remaining characters in the last item (see example)
Résultat array An array of the splitted parts, excluding the matched pattern

rawUrlDecode() public méthode

Decode the string from URLs according to RFC 3986
public rawUrlDecode ( string $string ) : string
$string string The string to decode
Résultat string The decoded string

rawUrlEncode() public méthode

Encode the string for URLs according to RFC 3986
public rawUrlEncode ( string $string ) : string
$string string The string to encode
Résultat string The encoded string

replace() public méthode

Example:: String.replace("canal", "ana", "oo") == "cool" Note: this method does not perform regular expression matching, @see pregReplace().
public replace ( string $string, string $search, string $replace ) : string
$string string The input string
$search string A search string
$replace string A replacement string
Résultat string The string with all occurrences replaced

split() public méthode

Example:: String.split("My hovercraft is full of eels", " ") == ['My', 'hovercraft', 'is', 'full', 'of', 'eels'] String.split("Foo", "", 2) == ['F', 'o'] Node: This implementation follows JavaScript semantics without support of regular expressions.
public split ( string $string, string $separator = null, integer $limit = null ) : array
$string string The string to split
$separator string The separator where the string should be splitted
$limit integer The maximum amount of items to split (exceeding items will be discarded)
Résultat array An array of the splitted parts, excluding the separators

startsWith() public méthode

Examples:: String.startsWith('Hello world!', 'Hello') == true String.startsWith('My hovercraft is full of...', 'Hello') == false String.startsWith('My hovercraft is full of...', 'hovercraft', 3) == true
public startsWith ( string $string, string $search, integer $position = null ) : boolean
$string string The input string
$search string The string to search for
$position integer The position to test (defaults to the beginning of the string)
Résultat boolean

stripTags() public méthode

Example:: String.stripTags('Some link') == 'Some link' This is a wrapper for the strip_tags() PHP function.
public stripTags ( string $string, string $allowableTags = null ) : string
$string string The string to strip
$allowableTags string Specify tags which should not be stripped
Résultat string The string with tags stripped

substr() public méthode

This implementation follows the JavaScript specification for "substr". Examples:: String.substr('Hello, World!', 7, 5) == 'World' String.substr('Hello, World!', 7) == 'World!' String.substr('Hello, World!', -6) == 'World!'
public substr ( string $string, integer $start, integer $length = null ) : string
$string string A string
$start integer Start offset
$length integer Maximum length of the substring that is returned
Résultat string The substring

substring() public méthode

This implementation follows the JavaScript specification for "substring". Examples:: String.substring('Hello, World!', 7, 12) == 'World' String.substring('Hello, World!', 7) == 'World!'
public substring ( string $string, integer $start, integer $end = null ) : string
$string string
$start integer Start index
$end integer End index
Résultat string The substring

toBoolean() public méthode

A value is true, if it is either the string "TRUE" or "true" or the number 1.
public toBoolean ( string $string ) : boolean
$string string The string to convert
Résultat boolean The boolean value of the string (``true`` or ``false``)

toFloat() public méthode

Convert a string to float
public toFloat ( string $string ) : float
$string string The string to convert
Résultat float The float value of the string

toInteger() public méthode

Convert a string to integer
public toInteger ( string $string ) : integer
$string string The string to convert
Résultat integer The converted string

toLowerCase() public méthode

Lowercase a string
public toLowerCase ( string $string ) : string
$string string The input string
Résultat string The string in lowercase

toString() public méthode

Convert the given value to a string
public toString ( mixed $value ) : string
$value mixed The value to convert (must be convertible to string)
Résultat string The string value

toUpperCase() public méthode

Uppercase a string
public toUpperCase ( string $string ) : string
$string string The input string
Résultat string The string in uppercase

trim() public méthode

Trim whitespace at the beginning and end of a string
public trim ( string $string, string $charlist = null ) : string
$string string The string to trim
$charlist string List of characters that should be trimmed, defaults to whitespace
Résultat string The trimmed string