PHP 클래스 Stringy\Stringy

상속: implements Countable, implements IteratorAggregate, implements ArrayAccess
파일 보기 프로젝트 열기: danielstjules/stringy 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$encoding string The string's encoding, which should be one of the mbstring module's supported encodings.
$str string An instance's string.

공개 메소드들

메소드 설명
__construct ( mixed $str = '', string $encoding = null ) Initializes a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.
__toString ( ) : string Returns the value in $str.
append ( string $string ) : Stringy Returns a new string with $string appended.
at ( integer $index ) : Stringy Returns the character at $index, with indexes starting at 0.
between ( string $start, string $end, integer $offset ) : Stringy Returns the substring between $start and $end, if found, or an empty string. An optional offset may be supplied from which to begin the search for the start string.
camelize ( ) : Stringy Returns a camelCase version of the string. Trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, as well as underscores.
chars ( ) : array Returns an array consisting of the characters in the string.
collapseWhitespace ( ) : Stringy Trims the string and replaces consecutive whitespace characters with a single space. This includes tabs and newline characters, as well as multibyte whitespace such as the thin space and ideographic space.
contains ( string $needle, boolean $caseSensitive = true ) : boolean Returns true if the string contains $needle, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
containsAll ( array $needles, boolean $caseSensitive = true ) : boolean Returns true if the string contains all $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
containsAny ( array $needles, boolean $caseSensitive = true ) : boolean Returns true if the string contains any $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
count ( ) : integer Returns the length of the string, implementing the countable interface.
countSubstr ( string $substring, boolean $caseSensitive = true ) : integer Returns the number of occurrences of $substring in the given string.
create ( mixed $str = '', string $encoding = null ) : Stringy Creates a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). It then returns the initialized object. Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.
dasherize ( ) : Stringy Returns a lowercase and trimmed string separated by dashes. Dashes are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces as well as underscores.
delimit ( string $delimiter ) : Stringy Returns a lowercase and trimmed string separated by the given delimiter.
endsWith ( string $substring, boolean $caseSensitive = true ) : boolean Returns true if the string ends with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
ensureLeft ( string $substring ) : Stringy Ensures that the string begins with $substring. If it doesn't, it's prepended.
ensureRight ( string $substring ) : Stringy Ensures that the string ends with $substring. If it doesn't, it's appended.
first ( integer $n ) : Stringy Returns the first $n characters of the string.
getEncoding ( ) : string Returns the encoding used by the Stringy object.
getIterator ( ) : ArrayIterator Returns a new ArrayIterator, thus implementing the IteratorAggregate interface. The ArrayIterator's constructor is passed an array of chars in the multibyte string. This enables the use of foreach with instances of Stringy\Stringy.
hasLowerCase ( ) : boolean Returns true if the string contains a lower case char, false otherwise.
hasUpperCase ( ) : boolean Returns true if the string contains an upper case char, false otherwise.
htmlDecode ( integer | null $flags = ENT_COMPAT ) : Stringy Convert all HTML entities to their applicable characters. An alias of html_entity_decode. For a list of flags, refer to http://php.net/manual/en/function.html-entity-decode.php
htmlEncode ( integer | null $flags = ENT_COMPAT ) : Stringy Convert all applicable characters to HTML entities. An alias of htmlentities. Refer to http://php.net/manual/en/function.htmlentities.php for a list of flags.
humanize ( ) : Stringy Capitalizes the first word of the string, replaces underscores with spaces, and strips '_id'.
indexOf ( string $needle, integer $offset ) : integer | boolean Returns the index of the first occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search.
indexOfLast ( string $needle, integer $offset ) : integer | boolean Returns the index of the last occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search. Offsets may be negative to count from the last character in the string.
insert ( string $substring, integer $index ) : Stringy Inserts $substring into the string at the $index provided.
isAlpha ( ) : boolean Returns true if the string contains only alphabetic chars, false otherwise.
isAlphanumeric ( ) : boolean Returns true if the string contains only alphabetic and numeric chars, false otherwise.
isBase64 ( ) : boolean Returns true if the string is base64 encoded, false otherwise.
isBlank ( ) : boolean Returns true if the string contains only whitespace chars, false otherwise.
isHexadecimal ( ) : boolean Returns true if the string contains only hexadecimal chars, false otherwise.
isJson ( ) : boolean Returns true if the string is JSON, false otherwise. Unlike json_decode in PHP 5.x, this method is consistent with PHP 7 and other JSON parsers, in that an empty string is not considered valid JSON.
isLowerCase ( ) : boolean Returns true if the string contains only lower case chars, false otherwise.
isSerialized ( ) : boolean Returns true if the string is serialized, false otherwise.
isUpperCase ( ) : boolean Returns true if the string contains only lower case chars, false otherwise.
last ( integer $n ) : Stringy Returns the last $n characters of the string.
length ( ) : integer Returns the length of the string. An alias for PHP's mb_strlen() function.
lines ( ) : Stringy[] Splits on newlines and carriage returns, returning an array of Stringy objects corresponding to the lines in the string.
longestCommonPrefix ( string $otherStr ) : Stringy Returns the longest common prefix between the string and $otherStr.
longestCommonSubstring ( string $otherStr ) : Stringy Returns the longest common substring between the string and $otherStr.
longestCommonSuffix ( string $otherStr ) : Stringy Returns the longest common suffix between the string and $otherStr.
lowerCaseFirst ( ) : Stringy Converts the first character of the string to lower case.
offsetExists ( mixed $offset ) : boolean Returns whether or not a character exists at an index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface.
offsetGet ( mixed $offset ) : mixed Returns the character at the given index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface, and throws an OutOfBoundsException if the index does not exist.
offsetSet ( mixed $offset, mixed $value ) Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.
offsetUnset ( mixed $offset ) Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.
pad ( integer $length, string $padStr = ' ', string $padType = 'right' ) : Stringy Pads the string to a given length with $padStr. If length is less than or equal to the length of the string, no padding takes places. The default string used for padding is a space, and the default type (one of 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException if $padType isn't one of those 3 values.
padBoth ( integer $length, string $padStr = ' ' ) : Stringy Returns a new string of a given length such that both sides of the string are padded. Alias for pad() with a $padType of 'both'.
padLeft ( integer $length, string $padStr = ' ' ) : Stringy Returns a new string of a given length such that the beginning of the string is padded. Alias for pad() with a $padType of 'left'.
padRight ( integer $length, string $padStr = ' ' ) : Stringy Returns a new string of a given length such that the end of the string is padded. Alias for pad() with a $padType of 'right'.
prepend ( string $string ) : Stringy Returns a new string starting with $string.
regexReplace ( string $pattern, string $replacement, string $options = 'msr' ) : Stringy Replaces all occurrences of $pattern in $str by $replacement. An alias for mb_ereg_replace(). Note that the 'i' option with multibyte patterns in mb_ereg_replace() requires PHP 5.6+ for correct results. This is due to a lack of support in the bundled version of Oniguruma in PHP < 5.6, and current versions of HHVM (3.8 and below).
removeLeft ( string $substring ) : Stringy Returns a new string with the prefix $substring removed, if present.
removeRight ( string $substring ) : Stringy Returns a new string with the suffix $substring removed, if present.
repeat ( integer $multiplier ) : Stringy Returns a repeated string given a multiplier. An alias for str_repeat.
replace ( string $search, string $replacement ) : Stringy Replaces all occurrences of $search in $str by $replacement.
reverse ( ) : Stringy Returns a reversed string. A multibyte version of strrev().
safeTruncate ( integer $length, string $substring = '' ) : Stringy Truncates the string to a given length, while ensuring that it does not split words. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.
shuffle ( ) * A multibyte str_shuffle() function. It returns a string with its characters in random order.
slice ( integer $start, integer $end = null ) : Stringy Returns the substring beginning at $start, and up to, but not including the index specified by $end. If $end is omitted, the function extracts the remaining string. If $end is negative, it is computed from the end of the string.
slugify ( string $replacement = '-' ) : Stringy Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $replacement. The replacement defaults to a single dash, and the string is also converted to lowercase.
split ( string $pattern, integer $limit = null ) : Stringy[] Splits the string with the provided regular expression, returning an array of Stringy objects. An optional integer $limit will truncate the results.
startsWith ( string $substring, boolean $caseSensitive = true ) : boolean Returns true if the string begins with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
substr ( integer $start, integer $length = null ) : Stringy Returns the substring beginning at $start with the specified $length.
surround ( string $substring ) : Stringy Surrounds $str with the given substring.
swapCase ( ) : Stringy Returns a case swapped version of the string.
tidy ( ) : Stringy Returns a string with smart quotes, ellipsis characters, and dashes from Windows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.
titleize ( array $ignore = null ) : Stringy Returns a trimmed string with the first letter of each word capitalized.
toAscii ( boolean $removeUnsupported = true ) : Stringy Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed unless instructed otherwise.
toBoolean ( ) : boolean Returns a boolean representation of the given logical string value.
toLowerCase ( ) : Stringy Converts all characters in the string to lowercase. An alias for PHP's mb_strtolower().
toSpaces ( integer $tabLength = 4 ) : Stringy Converts each tab in the string to some number of spaces, as defined by $tabLength. By default, each tab is converted to 4 consecutive spaces.
toTabs ( integer $tabLength = 4 ) : Stringy Converts each occurrence of some consecutive number of spaces, as defined by $tabLength, to a tab. By default, each 4 consecutive spaces are converted to a tab.
toTitleCase ( ) : Stringy Converts the first character of each word in the string to uppercase.
toUpperCase ( ) : Stringy Converts all characters in the string to uppercase. An alias for PHP's mb_strtoupper().
trim ( string $chars = null ) : Stringy Returns a string with whitespace removed from the start and end of the string. Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.
trimLeft ( string $chars = null ) : Stringy Returns a string with whitespace removed from the start of the string.
trimRight ( string $chars = null ) : Stringy Returns a string with whitespace removed from the end of the string.
truncate ( integer $length, string $substring = '' ) : Stringy Truncates the string to a given length. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.
underscored ( ) : Stringy Returns a lowercase and trimmed string separated by underscores.
upperCamelize ( ) : Stringy Returns an UpperCamelCase version of the supplied string. It trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, underscores.
upperCaseFirst ( ) : Stringy Converts the first character of the supplied string to upper case.

보호된 메소드들

메소드 설명
charsArray ( ) : array Returns the replacements for the toAscii() method.

비공개 메소드들

메소드 설명
applyPadding ( integer $left, integer $right, string $padStr = ' ' ) : Stringy Adds the specified amount of left and right padding to the given string.
eregReplace ( $pattern, $replacement, $string, $option = 'msr' ) Alias for mb_ereg_replace with a fallback to preg_replace if the mbstring module is not installed.
matchesPattern ( string $pattern ) : boolean Returns true if $str matches the supplied pattern, false otherwise.
regexEncoding ( ) Alias for mb_regex_encoding which default to a noop if the mbstring module is not installed.
supportsEncoding ( )

메소드 상세

__construct() 공개 메소드

Initializes a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.
public __construct ( mixed $str = '', string $encoding = null )
$str mixed Value to modify, after being cast to string
$encoding string The character encoding

__toString() 공개 메소드

Returns the value in $str.
public __toString ( ) : string
리턴 string The current value of the $str property

append() 공개 메소드

Returns a new string with $string appended.
public append ( string $string ) : Stringy
$string string The string to append
리턴 Stringy Object with appended $string

at() 공개 메소드

Returns the character at $index, with indexes starting at 0.
public at ( integer $index ) : Stringy
$index integer Position of the character
리턴 Stringy The character at $index

between() 공개 메소드

Returns the substring between $start and $end, if found, or an empty string. An optional offset may be supplied from which to begin the search for the start string.
public between ( string $start, string $end, integer $offset ) : Stringy
$start string Delimiter marking the start of the substring
$end string Delimiter marking the end of the substring
$offset integer Index from which to begin the search
리턴 Stringy Object whose $str is a substring between $start and $end

camelize() 공개 메소드

Returns a camelCase version of the string. Trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, as well as underscores.
public camelize ( ) : Stringy
리턴 Stringy Object with $str in camelCase

chars() 공개 메소드

Returns an array consisting of the characters in the string.
public chars ( ) : array
리턴 array An array of string chars

charsArray() 보호된 메소드

Returns the replacements for the toAscii() method.
protected charsArray ( ) : array
리턴 array An array of replacements.

collapseWhitespace() 공개 메소드

Trims the string and replaces consecutive whitespace characters with a single space. This includes tabs and newline characters, as well as multibyte whitespace such as the thin space and ideographic space.
public collapseWhitespace ( ) : Stringy
리턴 Stringy Object with a trimmed $str and condensed whitespace

contains() 공개 메소드

Returns true if the string contains $needle, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public contains ( string $needle, boolean $caseSensitive = true ) : boolean
$needle string Substring to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 boolean Whether or not $str contains $needle

containsAll() 공개 메소드

Returns true if the string contains all $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public containsAll ( array $needles, boolean $caseSensitive = true ) : boolean
$needles array Substrings to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 boolean Whether or not $str contains $needle

containsAny() 공개 메소드

Returns true if the string contains any $needles, false otherwise. By default the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public containsAny ( array $needles, boolean $caseSensitive = true ) : boolean
$needles array Substrings to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 boolean Whether or not $str contains $needle

count() 공개 메소드

Returns the length of the string, implementing the countable interface.
public count ( ) : integer
리턴 integer The number of characters in the string, given the encoding

countSubstr() 공개 메소드

By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public countSubstr ( string $substring, boolean $caseSensitive = true ) : integer
$substring string The substring to search for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 integer The number of $substring occurrences

create() 공개 정적인 메소드

Creates a Stringy object and assigns both str and encoding properties the supplied values. $str is cast to a string prior to assignment, and if $encoding is not specified, it defaults to mb_internal_encoding(). It then returns the initialized object. Throws an InvalidArgumentException if the first argument is an array or object without a __toString method.
public static create ( mixed $str = '', string $encoding = null ) : Stringy
$str mixed Value to modify, after being cast to string
$encoding string The character encoding
리턴 Stringy A Stringy object

dasherize() 공개 메소드

Returns a lowercase and trimmed string separated by dashes. Dashes are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces as well as underscores.
public dasherize ( ) : Stringy
리턴 Stringy Object with a dasherized $str

delimit() 공개 메소드

Delimiters are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces, dashes, and underscores. Alpha delimiters are not converted to lowercase.
public delimit ( string $delimiter ) : Stringy
$delimiter string Sequence used to separate parts of the string
리턴 Stringy Object with a delimited $str

endsWith() 공개 메소드

Returns true if the string ends with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public endsWith ( string $substring, boolean $caseSensitive = true ) : boolean
$substring string The substring to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 boolean Whether or not $str ends with $substring

ensureLeft() 공개 메소드

Ensures that the string begins with $substring. If it doesn't, it's prepended.
public ensureLeft ( string $substring ) : Stringy
$substring string The substring to add if not present
리턴 Stringy Object with its $str prefixed by the $substring

ensureRight() 공개 메소드

Ensures that the string ends with $substring. If it doesn't, it's appended.
public ensureRight ( string $substring ) : Stringy
$substring string The substring to add if not present
리턴 Stringy Object with its $str suffixed by the $substring

first() 공개 메소드

Returns the first $n characters of the string.
public first ( integer $n ) : Stringy
$n integer Number of characters to retrieve from the start
리턴 Stringy Object with its $str being the first $n chars

getEncoding() 공개 메소드

Returns the encoding used by the Stringy object.
public getEncoding ( ) : string
리턴 string The current value of the $encoding property

getIterator() 공개 메소드

Returns a new ArrayIterator, thus implementing the IteratorAggregate interface. The ArrayIterator's constructor is passed an array of chars in the multibyte string. This enables the use of foreach with instances of Stringy\Stringy.
public getIterator ( ) : ArrayIterator
리턴 ArrayIterator An iterator for the characters in the string

hasLowerCase() 공개 메소드

Returns true if the string contains a lower case char, false otherwise.
public hasLowerCase ( ) : boolean
리턴 boolean Whether or not the string contains a lower case character.

hasUpperCase() 공개 메소드

Returns true if the string contains an upper case char, false otherwise.
public hasUpperCase ( ) : boolean
리턴 boolean Whether or not the string contains an upper case character.

htmlDecode() 공개 메소드

Convert all HTML entities to their applicable characters. An alias of html_entity_decode. For a list of flags, refer to http://php.net/manual/en/function.html-entity-decode.php
public htmlDecode ( integer | null $flags = ENT_COMPAT ) : Stringy
$flags integer | null Optional flags
리턴 Stringy Object with the resulting $str after being html decoded.

htmlEncode() 공개 메소드

Convert all applicable characters to HTML entities. An alias of htmlentities. Refer to http://php.net/manual/en/function.htmlentities.php for a list of flags.
public htmlEncode ( integer | null $flags = ENT_COMPAT ) : Stringy
$flags integer | null Optional flags
리턴 Stringy Object with the resulting $str after being html encoded.

humanize() 공개 메소드

Capitalizes the first word of the string, replaces underscores with spaces, and strips '_id'.
public humanize ( ) : Stringy
리턴 Stringy Object with a humanized $str

indexOf() 공개 메소드

Returns the index of the first occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search.
public indexOf ( string $needle, integer $offset ) : integer | boolean
$needle string Substring to look for
$offset integer Offset from which to search
리턴 integer | boolean The occurrence's index if found, otherwise false

indexOfLast() 공개 메소드

Returns the index of the last occurrence of $needle in the string, and false if not found. Accepts an optional offset from which to begin the search. Offsets may be negative to count from the last character in the string.
public indexOfLast ( string $needle, integer $offset ) : integer | boolean
$needle string Substring to look for
$offset integer Offset from which to search
리턴 integer | boolean The last occurrence's index if found, otherwise false

insert() 공개 메소드

Inserts $substring into the string at the $index provided.
public insert ( string $substring, integer $index ) : Stringy
$substring string String to be inserted
$index integer The index at which to insert the substring
리턴 Stringy Object with the resulting $str after the insertion

isAlpha() 공개 메소드

Returns true if the string contains only alphabetic chars, false otherwise.
public isAlpha ( ) : boolean
리턴 boolean Whether or not $str contains only alphabetic chars

isAlphanumeric() 공개 메소드

Returns true if the string contains only alphabetic and numeric chars, false otherwise.
public isAlphanumeric ( ) : boolean
리턴 boolean Whether or not $str contains only alphanumeric chars

isBase64() 공개 메소드

Returns true if the string is base64 encoded, false otherwise.
public isBase64 ( ) : boolean
리턴 boolean Whether or not $str is base64 encoded

isBlank() 공개 메소드

Returns true if the string contains only whitespace chars, false otherwise.
public isBlank ( ) : boolean
리턴 boolean Whether or not $str contains only whitespace characters

isHexadecimal() 공개 메소드

Returns true if the string contains only hexadecimal chars, false otherwise.
public isHexadecimal ( ) : boolean
리턴 boolean Whether or not $str contains only hexadecimal chars

isJson() 공개 메소드

Returns true if the string is JSON, false otherwise. Unlike json_decode in PHP 5.x, this method is consistent with PHP 7 and other JSON parsers, in that an empty string is not considered valid JSON.
public isJson ( ) : boolean
리턴 boolean Whether or not $str is JSON

isLowerCase() 공개 메소드

Returns true if the string contains only lower case chars, false otherwise.
public isLowerCase ( ) : boolean
리턴 boolean Whether or not $str contains only lower case characters

isSerialized() 공개 메소드

Returns true if the string is serialized, false otherwise.
public isSerialized ( ) : boolean
리턴 boolean Whether or not $str is serialized

isUpperCase() 공개 메소드

Returns true if the string contains only lower case chars, false otherwise.
public isUpperCase ( ) : boolean
리턴 boolean Whether or not $str contains only lower case characters

last() 공개 메소드

Returns the last $n characters of the string.
public last ( integer $n ) : Stringy
$n integer Number of characters to retrieve from the end
리턴 Stringy Object with its $str being the last $n chars

length() 공개 메소드

Returns the length of the string. An alias for PHP's mb_strlen() function.
public length ( ) : integer
리턴 integer The number of characters in $str given the encoding

lines() 공개 메소드

Splits on newlines and carriage returns, returning an array of Stringy objects corresponding to the lines in the string.
public lines ( ) : Stringy[]
리턴 Stringy[] An array of Stringy objects

longestCommonPrefix() 공개 메소드

Returns the longest common prefix between the string and $otherStr.
public longestCommonPrefix ( string $otherStr ) : Stringy
$otherStr string Second string for comparison
리턴 Stringy Object with its $str being the longest common prefix

longestCommonSubstring() 공개 메소드

In the case of ties, it returns that which occurs first.
public longestCommonSubstring ( string $otherStr ) : Stringy
$otherStr string Second string for comparison
리턴 Stringy Object with its $str being the longest common substring

longestCommonSuffix() 공개 메소드

Returns the longest common suffix between the string and $otherStr.
public longestCommonSuffix ( string $otherStr ) : Stringy
$otherStr string Second string for comparison
리턴 Stringy Object with its $str being the longest common suffix

lowerCaseFirst() 공개 메소드

Converts the first character of the string to lower case.
public lowerCaseFirst ( ) : Stringy
리턴 Stringy Object with the first character of $str being lower case

offsetExists() 공개 메소드

Returns whether or not a character exists at an index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface.
public offsetExists ( mixed $offset ) : boolean
$offset mixed The index to check
리턴 boolean Whether or not the index exists

offsetGet() 공개 메소드

Returns the character at the given index. Offsets may be negative to count from the last character in the string. Implements part of the ArrayAccess interface, and throws an OutOfBoundsException if the index does not exist.
public offsetGet ( mixed $offset ) : mixed
$offset mixed The index from which to retrieve the char
리턴 mixed The character at the specified index

offsetSet() 공개 메소드

Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.
public offsetSet ( mixed $offset, mixed $value )
$offset mixed The index of the character
$value mixed Value to set

offsetUnset() 공개 메소드

Implements part of the ArrayAccess interface, but throws an exception when called. This maintains the immutability of Stringy objects.
public offsetUnset ( mixed $offset )
$offset mixed The index of the character

pad() 공개 메소드

Pads the string to a given length with $padStr. If length is less than or equal to the length of the string, no padding takes places. The default string used for padding is a space, and the default type (one of 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException if $padType isn't one of those 3 values.
public pad ( integer $length, string $padStr = ' ', string $padType = 'right' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
$padType string One of 'left', 'right', 'both'
리턴 Stringy Object with a padded $str

padBoth() 공개 메소드

Returns a new string of a given length such that both sides of the string are padded. Alias for pad() with a $padType of 'both'.
public padBoth ( integer $length, string $padStr = ' ' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
리턴 Stringy String with padding applied

padLeft() 공개 메소드

Returns a new string of a given length such that the beginning of the string is padded. Alias for pad() with a $padType of 'left'.
public padLeft ( integer $length, string $padStr = ' ' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
리턴 Stringy String with left padding

padRight() 공개 메소드

Returns a new string of a given length such that the end of the string is padded. Alias for pad() with a $padType of 'right'.
public padRight ( integer $length, string $padStr = ' ' ) : Stringy
$length integer Desired string length after padding
$padStr string String used to pad, defaults to space
리턴 Stringy String with right padding

prepend() 공개 메소드

Returns a new string starting with $string.
public prepend ( string $string ) : Stringy
$string string The string to append
리턴 Stringy Object with appended $string

regexReplace() 공개 메소드

Replaces all occurrences of $pattern in $str by $replacement. An alias for mb_ereg_replace(). Note that the 'i' option with multibyte patterns in mb_ereg_replace() requires PHP 5.6+ for correct results. This is due to a lack of support in the bundled version of Oniguruma in PHP < 5.6, and current versions of HHVM (3.8 and below).
public regexReplace ( string $pattern, string $replacement, string $options = 'msr' ) : Stringy
$pattern string The regular expression pattern
$replacement string The string to replace with
$options string Matching conditions to be used
리턴 Stringy Object with the resulting $str after the replacements

removeLeft() 공개 메소드

Returns a new string with the prefix $substring removed, if present.
public removeLeft ( string $substring ) : Stringy
$substring string The prefix to remove
리턴 Stringy Object having a $str without the prefix $substring

removeRight() 공개 메소드

Returns a new string with the suffix $substring removed, if present.
public removeRight ( string $substring ) : Stringy
$substring string The suffix to remove
리턴 Stringy Object having a $str without the suffix $substring

repeat() 공개 메소드

Returns a repeated string given a multiplier. An alias for str_repeat.
public repeat ( integer $multiplier ) : Stringy
$multiplier integer The number of times to repeat the string
리턴 Stringy Object with a repeated str

replace() 공개 메소드

Replaces all occurrences of $search in $str by $replacement.
public replace ( string $search, string $replacement ) : Stringy
$search string The needle to search for
$replacement string The string to replace with
리턴 Stringy Object with the resulting $str after the replacements

reverse() 공개 메소드

Returns a reversed string. A multibyte version of strrev().
public reverse ( ) : Stringy
리턴 Stringy Object with a reversed $str

safeTruncate() 공개 메소드

Truncates the string to a given length, while ensuring that it does not split words. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.
public safeTruncate ( integer $length, string $substring = '' ) : Stringy
$length integer Desired length of the truncated string
$substring string The substring to append if it can fit
리턴 Stringy Object with the resulting $str after truncating

shuffle() 공개 메소드

* A multibyte str_shuffle() function. It returns a string with its characters in random order.
public shuffle ( )

slice() 공개 메소드

Returns the substring beginning at $start, and up to, but not including the index specified by $end. If $end is omitted, the function extracts the remaining string. If $end is negative, it is computed from the end of the string.
public slice ( integer $start, integer $end = null ) : Stringy
$start integer Initial index from which to begin extraction
$end integer Optional index at which to end extraction
리턴 Stringy Object with its $str being the extracted substring

slugify() 공개 메소드

Converts the string into an URL slug. This includes replacing non-ASCII characters with their closest ASCII equivalents, removing remaining non-ASCII and non-alphanumeric characters, and replacing whitespace with $replacement. The replacement defaults to a single dash, and the string is also converted to lowercase.
public slugify ( string $replacement = '-' ) : Stringy
$replacement string The string used to replace whitespace
리턴 Stringy Object whose $str has been converted to an URL slug

split() 공개 메소드

Splits the string with the provided regular expression, returning an array of Stringy objects. An optional integer $limit will truncate the results.
public split ( string $pattern, integer $limit = null ) : Stringy[]
$pattern string The regex with which to split the string
$limit integer Optional maximum number of results to return
리턴 Stringy[] An array of Stringy objects

startsWith() 공개 메소드

Returns true if the string begins with $substring, false otherwise. By default, the comparison is case-sensitive, but can be made insensitive by setting $caseSensitive to false.
public startsWith ( string $substring, boolean $caseSensitive = true ) : boolean
$substring string The substring to look for
$caseSensitive boolean Whether or not to enforce case-sensitivity
리턴 boolean Whether or not $str starts with $substring

substr() 공개 메소드

It differs from the mb_substr() function in that providing a $length of null will return the rest of the string, rather than an empty string.
public substr ( integer $start, integer $length = null ) : Stringy
$start integer Position of the first character to use
$length integer Maximum number of characters used
리턴 Stringy Object with its $str being the substring

surround() 공개 메소드

Surrounds $str with the given substring.
public surround ( string $substring ) : Stringy
$substring string The substring to add to both sides
리턴 Stringy Object whose $str had the substring both prepended and appended

swapCase() 공개 메소드

Returns a case swapped version of the string.
public swapCase ( ) : Stringy
리턴 Stringy Object whose $str has each character's case swapped

tidy() 공개 메소드

Returns a string with smart quotes, ellipsis characters, and dashes from Windows-1252 (commonly used in Word documents) replaced by their ASCII equivalents.
public tidy ( ) : Stringy
리턴 Stringy Object whose $str has those characters removed

titleize() 공개 메소드

Also accepts an array, $ignore, allowing you to list words not to be capitalized.
public titleize ( array $ignore = null ) : Stringy
$ignore array An array of words not to capitalize
리턴 Stringy Object with a titleized $str

toAscii() 공개 메소드

Returns an ASCII version of the string. A set of non-ASCII characters are replaced with their closest ASCII counterparts, and the rest are removed unless instructed otherwise.
public toAscii ( boolean $removeUnsupported = true ) : Stringy
$removeUnsupported boolean Whether or not to remove the unsupported characters
리턴 Stringy Object whose $str contains only ASCII characters

toBoolean() 공개 메소드

For example, 'true', '1', 'on' and 'yes' will return true. 'false', '0', 'off', and 'no' will return false. In all instances, case is ignored. For other numeric strings, their sign will determine the return value. In addition, blank strings consisting of only whitespace will return false. For all other strings, the return value is a result of a boolean cast.
public toBoolean ( ) : boolean
리턴 boolean A boolean value for the string

toLowerCase() 공개 메소드

Converts all characters in the string to lowercase. An alias for PHP's mb_strtolower().
public toLowerCase ( ) : Stringy
리턴 Stringy Object with all characters of $str being lowercase

toSpaces() 공개 메소드

Converts each tab in the string to some number of spaces, as defined by $tabLength. By default, each tab is converted to 4 consecutive spaces.
public toSpaces ( integer $tabLength = 4 ) : Stringy
$tabLength integer Number of spaces to replace each tab with
리턴 Stringy Object whose $str has had tabs switched to spaces

toTabs() 공개 메소드

Converts each occurrence of some consecutive number of spaces, as defined by $tabLength, to a tab. By default, each 4 consecutive spaces are converted to a tab.
public toTabs ( integer $tabLength = 4 ) : Stringy
$tabLength integer Number of spaces to replace with a tab
리턴 Stringy Object whose $str has had spaces switched to tabs

toTitleCase() 공개 메소드

Converts the first character of each word in the string to uppercase.
public toTitleCase ( ) : Stringy
리턴 Stringy Object with all characters of $str being title-cased

toUpperCase() 공개 메소드

Converts all characters in the string to uppercase. An alias for PHP's mb_strtoupper().
public toUpperCase ( ) : Stringy
리턴 Stringy Object with all characters of $str being uppercase

trim() 공개 메소드

Returns a string with whitespace removed from the start and end of the string. Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.
public trim ( string $chars = null ) : Stringy
$chars string Optional string of characters to strip
리턴 Stringy Object with a trimmed $str

trimLeft() 공개 메소드

Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.
public trimLeft ( string $chars = null ) : Stringy
$chars string Optional string of characters to strip
리턴 Stringy Object with a trimmed $str

trimRight() 공개 메소드

Supports the removal of unicode whitespace. Accepts an optional string of characters to strip instead of the defaults.
public trimRight ( string $chars = null ) : Stringy
$chars string Optional string of characters to strip
리턴 Stringy Object with a trimmed $str

truncate() 공개 메소드

Truncates the string to a given length. If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.
public truncate ( integer $length, string $substring = '' ) : Stringy
$length integer Desired length of the truncated string
$substring string The substring to append if it can fit
리턴 Stringy Object with the resulting $str after truncating

underscored() 공개 메소드

Underscores are inserted before uppercase characters (with the exception of the first character of the string), and in place of spaces as well as dashes.
public underscored ( ) : Stringy
리턴 Stringy Object with an underscored $str

upperCamelize() 공개 메소드

Returns an UpperCamelCase version of the supplied string. It trims surrounding spaces, capitalizes letters following digits, spaces, dashes and underscores, and removes spaces, dashes, underscores.
public upperCamelize ( ) : Stringy
리턴 Stringy Object with $str in UpperCamelCase

upperCaseFirst() 공개 메소드

Converts the first character of the supplied string to upper case.
public upperCaseFirst ( ) : Stringy
리턴 Stringy Object with the first character of $str being upper case

프로퍼티 상세

$encoding 보호되어 있는 프로퍼티

The string's encoding, which should be one of the mbstring module's supported encodings.
protected string $encoding
리턴 string

$str 보호되어 있는 프로퍼티

An instance's string.
protected string $str
리턴 string