PHP 클래스 Neos\Eel\Helper\StringHelper

상속: implements Neos\Eel\ProtectedContextAwareInterface
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

공개 메소드들

메소드 설명
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