PHP Класс Neos\Eel\Helper\StringHelper

Наследование: implements Neos\Eel\ProtectedContextAwareInterface
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Описание методов

allowsCallOfMethod() публичный Метод

All methods are considered safe
public allowsCallOfMethod ( string $methodName ) : boolean
$methodName string
Результат boolean

charAt() публичный Метод

Example:: String.charAt("abcdefg", 5) == "f"
public charAt ( string $string, integer $index ) : string
$string string The input string
$index integer The index to get
Результат string The character at the given index

crop() публичный Метод

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
Результат string The cropped string

cropAtSentence() публичный Метод

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
Результат string The cropped string

cropAtWord() публичный Метод

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
Результат string The cropped string

endsWith() публичный Метод

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
Результат boolean TRUE if the string ends with the given search

firstLetterToLowerCase() публичный Метод

Example:: String.firstLetterToLowerCase('CamelCase') == 'camelCase'
public firstLetterToLowerCase ( string $string ) : string
$string string The input string
Результат string The string with the first letter in lowercase

firstLetterToUpperCase() публичный Метод

Example:: String.firstLetterToUpperCase('hello world') == 'Hello world'
public firstLetterToUpperCase ( string $string ) : string
$string string The input string
Результат string The string with the first letter in uppercase

htmlSpecialChars() публичный Метод

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
Результат string The converted string

indexOf() публичный Метод

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
Результат integer The index of the substring (>= 0) or -1 if the substring was not found

isBlank() публичный Метод

Examples:: String.isBlank('') == true String.isBlank(' ') == true
public isBlank ( string $string ) : boolean
$string string The string to test
Результат boolean ``true`` if the given string is blank

lastIndexOf() публичный Метод

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
Результат integer The last index of the substring (>=0) or -1 if the substring was not found

length() публичный Метод

Get the length of a string
public length ( string $string ) : integer
$string string The input string
Результат integer Length of the string

md5() публичный Метод

Calculate the MD5 checksum of the given string
public md5 ( string $string ) : string
$string string The string to hash
Результат string The MD5 hash of ``string``

pregMatch() публичный Метод

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
Результат array The matches as array or NULL if not matched

pregReplace() публичный Метод

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"
Результат string The string with all occurrences replaced

pregSplit() публичный Метод

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)
Результат array An array of the splitted parts, excluding the matched pattern

rawUrlDecode() публичный Метод

Decode the string from URLs according to RFC 3986
public rawUrlDecode ( string $string ) : string
$string string The string to decode
Результат string The decoded string

rawUrlEncode() публичный Метод

Encode the string for URLs according to RFC 3986
public rawUrlEncode ( string $string ) : string
$string string The string to encode
Результат string The encoded string

replace() публичный Метод

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
Результат string The string with all occurrences replaced

split() публичный Метод

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)
Результат array An array of the splitted parts, excluding the separators

startsWith() публичный Метод

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)
Результат boolean

stripTags() публичный Метод

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
Результат string The string with tags stripped

substr() публичный Метод

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
Результат string The substring

substring() публичный Метод

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
Результат string The substring

toBoolean() публичный Метод

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
Результат boolean The boolean value of the string (``true`` or ``false``)

toFloat() публичный Метод

Convert a string to float
public toFloat ( string $string ) : float
$string string The string to convert
Результат float The float value of the string

toInteger() публичный Метод

Convert a string to integer
public toInteger ( string $string ) : integer
$string string The string to convert
Результат integer The converted string

toLowerCase() публичный Метод

Lowercase a string
public toLowerCase ( string $string ) : string
$string string The input string
Результат string The string in lowercase

toString() публичный Метод

Convert the given value to a string
public toString ( mixed $value ) : string
$value mixed The value to convert (must be convertible to string)
Результат string The string value

toUpperCase() публичный Метод

Uppercase a string
public toUpperCase ( string $string ) : string
$string string The input string
Результат string The string in uppercase

trim() публичный Метод

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
Результат string The trimmed string