1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-14 09:14:05 +02:00

Code comments and documentation cleanup

This commit is contained in:
Daniel St. Jules
2014-02-10 00:46:34 -05:00
parent ffe6c2575a
commit 1d186ca79f
3 changed files with 448 additions and 435 deletions

View File

@@ -167,7 +167,7 @@ $stringy[2] = 'a'; // Exception
In the list below, any static method other than S::create refers to a method in In the list below, any static method other than S::create refers to a method in
`Stringy\StaticStringy`. For all others, they're found in `Stringy\Stringy`. `Stringy\StaticStringy`. For all others, they're found in `Stringy\Stringy`.
Furthermore, all methods that return a Stringy object or string do not modify Furthermore, all methods that return a Stringy object or string do not modify
the original. the original. Stringy objects are immutable.
*Note: If `$encoding` is not given, it defaults to `mb_internal_encoding()`.* *Note: If `$encoding` is not given, it defaults to `mb_internal_encoding()`.*
@@ -177,7 +177,7 @@ $stringy->at(int $index)
S::at(int $index [, string $encoding ]) S::at(int $index [, string $encoding ])
Returns the character of the string at $index, with indexes starting at 0. Returns the character at $index, with indexes starting at 0.
```php ```php
S::create('fòô bàř', 'UTF-8')->at(6); S::create('fòô bàř', 'UTF-8')->at(6);
@@ -190,9 +190,9 @@ $stringy->camelize();
S::camelize(string $str [, string $encoding ]) S::camelize(string $str [, string $encoding ])
Returns a camelCase version of the supplied string. Trims surrounding Returns a camelCase version of the string. Trims surrounding spaces,
spaces, capitalizes letters following digits, spaces, dashes and capitalizes letters following digits, spaces, dashes and underscores,
underscores, and removes spaces, dashes, underscores. and removes spaces, dashes, as well as underscores.
```php ```php
S::create('Camel-Case')->camelize(); S::create('Camel-Case')->camelize();
@@ -632,7 +632,7 @@ $stringy->removeLeft(string $substring)
S::removeLeft(string $str, string $substring [, string $encoding ]) S::removeLeft(string $str, string $substring [, string $encoding ])
Returns a new string with the prefix $substring removed, if it was present. Returns a new string with the prefix $substring removed, if present.
```php ```php
S::create('fòô bàř', 'UTF-8')->removeLeft('fòô '); S::create('fòô bàř', 'UTF-8')->removeLeft('fòô ');
@@ -645,7 +645,7 @@ $stringy->removeRight(string $substring)
S::removeRight(string $str, string $substring [, string $encoding ]) S::removeRight(string $str, string $substring [, string $encoding ])
Returns a new string with the suffix $substring removed, if it was present. Returns a new string with the suffix $substring removed, if present.
```php ```php
S::create('fòô bàř', 'UTF-8')->removeRight(' bàř'); S::create('fòô bàř', 'UTF-8')->removeRight(' bàř');
@@ -685,8 +685,8 @@ $stringy->safeTruncate(int $length, [, string $substring = '' ])
S::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]]) S::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])
Truncates the string to a given length, while ensuring that it does not Truncates the string to a given length, while ensuring that it does not
chop words. If $substring is provided, and truncating occurs, the string split words. If $substring is provided, and truncating occurs, the
is further truncated so that the substring may be appended without string is further truncated so that the substring may be appended without
exceeding the desired length. exceeding the desired length.
```php ```php
@@ -715,10 +715,10 @@ $stringy->slugify([ string $replacement = '-' ])
S::slugify(string $str [, string $replacement = '-' ]) S::slugify(string $str [, string $replacement = '-' ])
Converts the string into an URL slug. This includes replacing non-ASCII Converts the string into an URL slug. This includes replacing non-ASCII
characters with their closest ASCII equivalents, removing non-alphanumeric characters with their closest ASCII equivalents, removing remaining
and non-ASCII characters, and replacing whitespace with $replacement. non-ASCII and non-alphanumeric characters, and replacing whitespace with
The replacement defaults to a single dash, and the string is also $replacement. The replacement defaults to a single dash, and the string
converted to lowercase. is also converted to lowercase.
```php ```php
S::create('Using strings like fòô bàř')->slugify(); S::create('Using strings like fòô bàř')->slugify();
@@ -802,9 +802,8 @@ $stringy->titleize([ string $encoding ])
S::titleize(string $str [, array $ignore [, string $encoding ]]) S::titleize(string $str [, array $ignore [, string $encoding ]])
Returns a trimmed string with the first letter of each word capitalized. Returns a trimmed string with the first letter of each word capitalized.
Ignores the case of other letters, allowing for the use of acronyms. Ignores the case of other letters, preserving any acronyms. Also accepts
Also accepts an array, $ignore, allowing you to list words not to be an array, $ignore, allowing you to list words not to be capitalized.
capitalized.
```php ```php
$ignore = array('at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the'); $ignore = array('at', 'by', 'for', 'in', 'of', 'on', 'out', 'to', 'the');
@@ -908,8 +907,8 @@ truncating occurs, the string is further truncated so that the substring
may be appended without exceeding the desired length. may be appended without exceeding the desired length.
```php ```php
S::create('What are your plans today?')->safeTruncate(19, '...'); S::create('What are your plans today?')->truncate(19, '...');
S::safeTruncate('What are your plans today?', 19, '...'); // 'What are your pl...' S::truncate('What are your plans today?', 19, '...'); // 'What are your pl...'
``` ```
#### underscored #### underscored

View File

@@ -7,9 +7,9 @@ class StaticStringy
/** /**
* Returns an array consisting of the characters in the string. * Returns an array consisting of the characters in the string.
* *
* @param string $str String for which to return the chars * @param string $str String for which to return the chars
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return array An array of string chars * @return array An array of string chars
*/ */
public static function chars($str, $encoding = null) public static function chars($str, $encoding = null)
{ {
@@ -19,9 +19,9 @@ class StaticStringy
/** /**
* Converts the first character of the supplied string to upper case. * Converts the first character of the supplied string to upper case.
* *
* @param string $str String to modify * @param string $str String to modify
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string String with the first character being upper case * @return string String with the first character being upper case
*/ */
public static function upperCaseFirst($str, $encoding = null) public static function upperCaseFirst($str, $encoding = null)
{ {
@@ -31,9 +31,9 @@ class StaticStringy
/** /**
* Converts the first character of the supplied string to lower case. * Converts the first character of the supplied string to lower case.
* *
* @param string $str String to modify * @param string $str String to modify
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string String with the first character being lower case * @return string String with the first character being lower case
*/ */
public static function lowerCaseFirst($str, $encoding = null) public static function lowerCaseFirst($str, $encoding = null)
{ {
@@ -41,13 +41,13 @@ class StaticStringy
} }
/** /**
* Returns a camelCase version of the supplied string. Trims surrounding * Returns a camelCase version of the string. Trims surrounding spaces,
* spaces, capitalizes letters following digits, spaces, dashes and * capitalizes letters following digits, spaces, dashes and underscores,
* underscores, and removes spaces, dashes, underscores. * and removes spaces, dashes, as well as underscores.
* *
* @param string $str String to convert to camelCase * @param string $str String to convert to camelCase
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string String in camelCase * @return string String in camelCase
*/ */
public static function camelize($str, $encoding = null) public static function camelize($str, $encoding = null)
{ {
@@ -59,9 +59,9 @@ class StaticStringy
* surrounding spaces, capitalizes letters following digits, spaces, dashes * surrounding spaces, capitalizes letters following digits, spaces, dashes
* and underscores, and removes spaces, dashes, underscores. * and underscores, and removes spaces, dashes, underscores.
* *
* @param string $str String to convert to UpperCamelCase * @param string $str String to convert to UpperCamelCase
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string String in UpperCamelCase * @return string String in UpperCamelCase
*/ */
public static function upperCamelize($str, $encoding = null) public static function upperCamelize($str, $encoding = null)
{ {
@@ -73,9 +73,9 @@ class StaticStringy
* inserted before uppercase characters (with the exception of the first * inserted before uppercase characters (with the exception of the first
* character of the string), and in place of spaces as well as underscores. * character of the string), and in place of spaces as well as underscores.
* *
* @param string $str String to convert * @param string $str String to convert
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string Dasherized string * @return string Dasherized string
*/ */
public static function dasherize($str, $encoding = null) public static function dasherize($str, $encoding = null)
{ {
@@ -88,9 +88,9 @@ class StaticStringy
* of the first character of the string), and in place of spaces as well as * of the first character of the string), and in place of spaces as well as
* dashes. * dashes.
* *
* @param string $str String to convert * @param string $str String to convert
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string Underscored string * @return string Underscored string
*/ */
public static function underscored($str, $encoding = null) public static function underscored($str, $encoding = null)
{ {
@@ -100,9 +100,9 @@ class StaticStringy
/** /**
* Returns a case swapped version of the string. * Returns a case swapped version of the string.
* *
* @param string $str String to swap case * @param string $str String to swap case
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string String with each character's case swapped * @return string String with each character's case swapped
*/ */
public static function swapCase($str, $encoding = null) public static function swapCase($str, $encoding = null)
{ {
@@ -111,14 +111,13 @@ class StaticStringy
/** /**
* Returns a trimmed string with the first letter of each word capitalized. * Returns a trimmed string with the first letter of each word capitalized.
* Ignores the case of other letters, allowing for the use of acronyms. * Ignores the case of other letters, preserving any acronyms. Also accepts
* Also accepts an array, $ignore, allowing you to list words not to be * an array, $ignore, allowing you to list words not to be capitalized.
* capitalized.
* *
* @param string $str String to titleize * @param string $str String to titleize
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @param array $ignore An array of words not to capitalize * @param array $ignore An array of words not to capitalize
* @return string Titleized string * @return string Titleized string
*/ */
public static function titleize($str, $ignore = null, $encoding = null) public static function titleize($str, $ignore = null, $encoding = null)
{ {
@@ -129,9 +128,9 @@ class StaticStringy
* Capitalizes the first word of the string, replaces underscores with * Capitalizes the first word of the string, replaces underscores with
* spaces, and strips '_id'. * spaces, and strips '_id'.
* *
* @param string $str String to humanize * @param string $str String to humanize
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string A humanized string * @return string A humanized string
*/ */
public static function humanize($str, $encoding = null) public static function humanize($str, $encoding = null)
{ {
@@ -143,8 +142,8 @@ class StaticStringy
* Windows-1252 (commonly used in Word documents) replaced by their ASCII * Windows-1252 (commonly used in Word documents) replaced by their ASCII
* equivalents. * equivalents.
* *
* @param string $str String to remove special chars * @param string $str String to remove special chars
* @return string String with those characters removed * @return string String with those characters removed
*/ */
public static function tidy($str) public static function tidy($str)
{ {
@@ -156,9 +155,9 @@ class StaticStringy
* single space. This includes tabs and newline characters, as well as * single space. This includes tabs and newline characters, as well as
* multibyte whitespace such as the thin space and ideographic space. * multibyte whitespace such as the thin space and ideographic space.
* *
* @param string $str The string to cleanup whitespace * @param string $str The string to cleanup whitespace
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The trimmed string with condensed whitespace * @return string The trimmed string with condensed whitespace
*/ */
public static function collapseWhitespace($str, $encoding = null) public static function collapseWhitespace($str, $encoding = null)
{ {
@@ -169,8 +168,8 @@ class StaticStringy
* Returns an ASCII version of the string. A set of non-ASCII characters are * 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. * replaced with their closest ASCII counterparts, and the rest are removed.
* *
* @param string $str A string with non-ASCII characters * @param string $str A string with non-ASCII characters
* @return string A string containing only ASCII characters * @return string A string containing only ASCII characters
*/ */
public static function toAscii($str) public static function toAscii($str)
{ {
@@ -179,115 +178,118 @@ class StaticStringy
/** /**
* Pads the string to a given length with $padStr. If length is less than * 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 * or equal to the length of the string, no padding takes places. The
* string used for padding is a space, and the default type (one of 'left', * default string used for padding is a space, and the default type (one of
* 'right', 'both') is 'right'. Throws an InvalidArgumentException if * 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException
* $padType isn't one of those 3 values. * if $padType isn't one of those 3 values.
* *
* @param string $str String to pad * @param string $str String to pad
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @param string $padType One of 'left', 'right', 'both' * @param string $padType One of 'left', 'right', 'both'
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The padded string * @return string The padded string
* @throws \InvalidArgumentException If $padType isn't one of 'right', * @throws \InvalidArgumentException If $padType isn't one of 'right',
* 'left' or 'both' * 'left' or 'both'
*/ */
public static function pad($str, $length, $padStr = ' ', $padType = 'right', public static function pad($str, $length, $padStr = ' ', $padType = 'right',
$encoding = null) $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->pad($length, $padStr, $padType); ->pad($length, $padStr, $padType);
} }
/** /**
* Returns a new string of a given length such that the beginning of the * 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'. * string is padded. Alias for pad() with a $padType of 'left'.
* *
* @param string $str String to pad * @param string $str String to pad
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The padded string * @return string The padded string
*/ */
public static function padLeft($str, $length, $padStr = ' ', $encoding = null) public static function padLeft($str, $length, $padStr = ' ', $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->padLeft($length, $padStr); return (string) Stringy::create($str, $encoding)
->padLeft($length, $padStr);
} }
/** /**
* Returns a new string of a given length such that the end of the string is * Returns a new string of a given length such that the end of the string
* padded. Alias for pad() with a $padType of 'right'. * is padded. Alias for pad() with a $padType of 'right'.
* *
* @param string $str String to pad * @param string $str String to pad
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The padded string * @return string The padded string
*/ */
public static function padRight($str, $length, $padStr = ' ', $encoding = null) public static function padRight($str, $length, $padStr = ' ', $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->padRight($length, $padStr); return (string) Stringy::create($str, $encoding)
->padRight($length, $padStr);
} }
/** /**
* Returns a new string of a given length such that both sides of the string * 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'. * string are padded. Alias for pad() with a $padType of 'both'.
* *
* @param string $str String to pad * @param string $str String to pad
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The padded string * @return string The padded string
*/ */
public static function padBoth($str, $length, $padStr = ' ', $encoding = null) public static function padBoth($str, $length, $padStr = ' ', $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->padBoth($length, $padStr); return (string) Stringy::create($str, $encoding)
->padBoth($length, $padStr);
} }
/** /**
* Returns true if the string begins with $substring, false otherwise. * Returns true if the string begins with $substring, false otherwise. By
* By default, the comparison is case-sensitive, but can be made insensitive * default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $str String to check the start of * @param string $str String to check the start of
* @param string $substring The substring to look for * @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str starts with $substring * @return bool Whether or not $str starts with $substring
*/ */
public static function startsWith($str, $substring, $caseSensitive = true, public static function startsWith($str, $substring, $caseSensitive = true,
$encoding = null) $encoding = null)
{ {
return Stringy::create($str, $encoding) return Stringy::create($str, $encoding)
->startsWith($substring, $caseSensitive); ->startsWith($substring, $caseSensitive);
} }
/** /**
* Returns true if the string ends with $substring, false otherwise. By * Returns true if the string ends with $substring, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive by * default, the comparison is case-sensitive, but can be made insensitive
* setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $str String to check the end of * @param string $str String to check the end of
* @param string $substring The substring to look for * @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str ends with $substring * @return bool Whether or not $str ends with $substring
*/ */
public static function endsWith($str, $substring, $caseSensitive = true, public static function endsWith($str, $substring, $caseSensitive = true,
$encoding = null) $encoding = null)
{ {
return Stringy::create($str, $encoding) return Stringy::create($str, $encoding)
->endsWith($substring, $caseSensitive); ->endsWith($substring, $caseSensitive);
} }
/** /**
* Converts each tab in the string to some number of spaces, as defined by * 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. * $tabLength. By default, each tab is converted to 4 consecutive spaces.
* *
* @param string $str String to convert tabs to spaces * @param string $str String to convert tabs to spaces
* @param int $tabLength Number of spaces to replace each tab with * @param int $tabLength Number of spaces to replace each tab with
* @return string String with tabs switched to spaces * @return string String with tabs switched to spaces
*/ */
public static function toSpaces($str, $tabLength = 4) public static function toSpaces($str, $tabLength = 4)
{ {
@@ -295,13 +297,13 @@ class StaticStringy
} }
/** /**
* Converts each occurrence of some consecutive number of spaces, as defined * Converts each occurrence of some consecutive number of spaces, as
* by $tabLength, to a tab. By default, each 4 consecutive spaces are * defined by $tabLength, to a tab. By default, each 4 consecutive spaces
* converted to a tab. * are converted to a tab.
* *
* @param string $str String to convert spaces to tabs * @param string $str String to convert spaces to tabs
* @param int $tabLength Number of spaces to replace with a tab * @param int $tabLength Number of spaces to replace with a tab
* @return string String with spaces switched to tabs * @return string String with spaces switched to tabs
*/ */
public static function toTabs($str, $tabLength = 4) public static function toTabs($str, $tabLength = 4)
{ {
@@ -312,9 +314,9 @@ class StaticStringy
* Converts all characters in the string to lowercase. An alias for PHP's * Converts all characters in the string to lowercase. An alias for PHP's
* mb_strtolower(). * mb_strtolower().
* *
* @param string $str String to convert case * @param string $str String to convert case
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The lowercase string * @return string The lowercase string
*/ */
public static function toLowerCase($str, $encoding = null) public static function toLowerCase($str, $encoding = null)
{ {
@@ -325,9 +327,9 @@ class StaticStringy
* Converts all characters in the string to uppercase. An alias for PHP's * Converts all characters in the string to uppercase. An alias for PHP's
* mb_strtoupper(). * mb_strtoupper().
* *
* @param string $str String to convert case * @param string $str String to convert case
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The uppercase string * @return string The uppercase string
*/ */
public static function toUpperCase($str, $encoding = null) public static function toUpperCase($str, $encoding = null)
{ {
@@ -336,14 +338,14 @@ class StaticStringy
/** /**
* Converts the string into an URL slug. This includes replacing non-ASCII * Converts the string into an URL slug. This includes replacing non-ASCII
* characters with their closest ASCII equivalents, removing non-alphanumeric * characters with their closest ASCII equivalents, removing remaining
* and non-ASCII characters, and replacing whitespace with $replacement. * non-ASCII and non-alphanumeric characters, and replacing whitespace with
* The replacement defaults to a single dash, and the string is also * $replacement. The replacement defaults to a single dash, and the string
* converted to lowercase. * is also converted to lowercase.
* *
* @param string $str Text to transform into an URL slug * @param string $str Text to transform into an URL slug
* @param string $replacement The string used to replace whitespace * @param string $replacement The string used to replace whitespace
* @return string The corresponding URL slug * @return string The corresponding URL slug
*/ */
public static function slugify($str, $replacement = '-') public static function slugify($str, $replacement = '-')
{ {
@@ -355,24 +357,25 @@ class StaticStringy
* the comparison is case-sensitive, but can be made insensitive by setting * the comparison is case-sensitive, but can be made insensitive by setting
* $caseSensitive to false. * $caseSensitive to false.
* *
* @param string $haystack String being checked * @param string $haystack String being checked
* @param string $needle Substring to look for * @param string $needle Substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $haystack contains $needle * @return bool Whether or not $haystack contains $needle
*/ */
public static function contains($haystack, $needle, $caseSensitive = true, public static function contains($haystack, $needle, $caseSensitive = true,
$encoding = null) $encoding = null)
{ {
return Stringy::create($haystack, $encoding)->contains($needle, $caseSensitive); return Stringy::create($haystack, $encoding)
->contains($needle, $caseSensitive);
} }
/** /**
* Surrounds a string with the given substring. * Surrounds a string with the given substring.
* *
* @param string $str The string to surround * @param string $str The string to surround
* @param string $substring The substring to add to both sides * @param string $substring The substring to add to both sides
* @return string The string with the substring prepended and appended * @return string The string with the substring prepended and appended
*/ */
public static function surround($str, $substring) public static function surround($str, $substring)
{ {
@@ -382,15 +385,16 @@ class StaticStringy
/** /**
* Inserts $substring into the string at the $index provided. * Inserts $substring into the string at the $index provided.
* *
* @param string $str String to insert into * @param string $str String to insert into
* @param string $substring String to be inserted * @param string $substring String to be inserted
* @param int $index The index at which to insert the substring * @param int $index The index at which to insert the substring
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The resulting string after the insertion * @return string The resulting string after the insertion
*/ */
public static function insert($str, $substring, $index, $encoding = null) public static function insert($str, $substring, $index, $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->insert($substring, $index); return (string) Stringy::create($str, $encoding)
->insert($substring, $index);
} }
/** /**
@@ -398,44 +402,44 @@ class StaticStringy
* truncating occurs, the string is further truncated so that the substring * truncating occurs, the string is further truncated so that the substring
* may be appended without exceeding the desired length. * may be appended without exceeding the desired length.
* *
* @param string $str String to truncate * @param string $str String to truncate
* @param int $length Desired length of the truncated string * @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit * @param string $substring The substring to append if it can fit
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The resulting string after truncating * @return string The resulting string after truncating
*/ */
public static function truncate($str, $length, $substring = '', public static function truncate($str, $length, $substring = '',
$encoding = null) $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->truncate($length, $substring); ->truncate($length, $substring);
} }
/** /**
* Truncates the string to a given length, while ensuring that it does not * Truncates the string to a given length, while ensuring that it does not
* chop words. If $substring is provided, and truncating occurs, the string * split words. If $substring is provided, and truncating occurs, the
* is further truncated so that the substring may be appended without * string is further truncated so that the substring may be appended without
* exceeding the desired length. * exceeding the desired length.
* *
* @param string $str String to truncate * @param string $str String to truncate
* @param int $length Desired length of the truncated string * @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit * @param string $substring The substring to append if it can fit
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The resulting string after truncating * @return string The resulting string after truncating
*/ */
public static function safeTruncate($str, $length, $substring = '', public static function safeTruncate($str, $length, $substring = '',
$encoding = null) $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->safeTruncate($length, $substring); ->safeTruncate($length, $substring);
} }
/** /**
* Returns a reversed string. A multibyte version of strrev(). * Returns a reversed string. A multibyte version of strrev().
* *
* @param string $str String to reverse * @param string $str String to reverse
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The reversed string * @return string The reversed string
*/ */
public static function reverse($str, $encoding = null) public static function reverse($str, $encoding = null)
{ {
@@ -446,9 +450,9 @@ class StaticStringy
* A multibyte str_shuffle() function. It returns a string with its * A multibyte str_shuffle() function. It returns a string with its
* characters in random order. * characters in random order.
* *
* @param string $str String to shuffle * @param string $str String to shuffle
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The shuffled string * @return string The shuffled string
*/ */
public static function shuffle($str, $encoding = null) public static function shuffle($str, $encoding = null)
{ {
@@ -458,8 +462,8 @@ class StaticStringy
/** /**
* Returns the trimmed string. An alias for PHP's trim() function. * Returns the trimmed string. An alias for PHP's trim() function.
* *
* @param string $str String to trim * @param string $str String to trim
* @return string Trimmed $str * @return string Trimmed $str
*/ */
public static function trim($str) public static function trim($str)
{ {
@@ -469,53 +473,53 @@ class StaticStringy
/** /**
* Returns the longest common prefix between the string and $otherStr. * Returns the longest common prefix between the string and $otherStr.
* *
* @param string $str First string for comparison * @param string $str First string for comparison
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The longest common prefix * @return string The longest common prefix
*/ */
public static function longestCommonPrefix($str, $otherStr, $encoding = null) public static function longestCommonPrefix($str, $otherStr, $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->longestCommonPrefix($otherStr); ->longestCommonPrefix($otherStr);
} }
/** /**
* Returns the longest common suffix between the string and $otherStr. * Returns the longest common suffix between the string and $otherStr.
* *
* @param string $str First string for comparison * @param string $str First string for comparison
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The longest common suffix * @return string The longest common suffix
*/ */
public static function longestCommonSuffix($str, $otherStr, $encoding = null) public static function longestCommonSuffix($str, $otherStr, $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->longestCommonSuffix($otherStr); ->longestCommonSuffix($otherStr);
} }
/** /**
* Returns the longest common substring between the string and $otherStr. * Returns the longest common substring between the string and $otherStr.
* In the case of ties, it returns that which occurs first. * In the case of ties, it returns that which occurs first.
* *
* @param string $str First string for comparison * @param string $str First string for comparison
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The longest common substring * @return string The longest common substring
*/ */
public static function longestCommonSubstring($str, $otherStr, public static function longestCommonSubstring($str, $otherStr,
$encoding = null) $encoding = null)
{ {
return (string) Stringy::create($str, $encoding) return (string) Stringy::create($str, $encoding)
->longestCommonSubstring($otherStr); ->longestCommonSubstring($otherStr);
} }
/** /**
* Returns the length of the string. An alias for PHP's mb_strlen() function. * Returns the length of the string. An alias for PHP's mb_strlen() function.
* *
* @param string $str The string to get the length of * @param string $str The string to get the length of
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return int The number of characters in $str given the encoding * @return int The number of characters in $str given the encoding
*/ */
public static function length($str, $encoding = null) public static function length($str, $encoding = null)
{ {
@@ -527,11 +531,11 @@ class StaticStringy
* It differs from the mb_substr() function in that providing a $length of * 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. * null will return the rest of the string, rather than an empty string.
* *
* @param string $str The string to get the length of * @param string $str The string to get the length of
* @param int $start Position of the first character to use * @param int $start Position of the first character to use
* @param int $length Maximum number of characters used * @param int $length Maximum number of characters used
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The substring of $str * @return string The substring of $str
*/ */
public static function substr($str, $start, $length = null, $encoding = null) public static function substr($str, $start, $length = null, $encoding = null)
{ {
@@ -539,12 +543,12 @@ class StaticStringy
} }
/** /**
* Returns the character of the string at $index, with indexes starting at 0. * Returns the character at $index, with indexes starting at 0.
* *
* @param string $str The string from which to get the char * @param string $str The string from which to get the char
* @param int $index Position of the character * @param int $index Position of the character
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The character at $index * @return string The character at $index
*/ */
public static function at($str, $index, $encoding = null) public static function at($str, $index, $encoding = null)
{ {
@@ -554,10 +558,10 @@ class StaticStringy
/** /**
* Returns the first $n characters of the string. * Returns the first $n characters of the string.
* *
* @param string $str The string from which to get the substring * @param string $str The string from which to get the substring
* @param int $n Number of chars to retrieve from the start * @param int $n Number of chars to retrieve from the start
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The first $n characters * @return string The first $n characters
*/ */
public static function first($str, $n, $encoding = null) public static function first($str, $n, $encoding = null)
{ {
@@ -567,10 +571,10 @@ class StaticStringy
/** /**
* Returns the last $n characters of the string. * Returns the last $n characters of the string.
* *
* @param string $str The string from which to get the substring * @param string $str The string from which to get the substring
* @param int $n Number of chars to retrieve from the end * @param int $n Number of chars to retrieve from the end
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The last $n characters * @return string The last $n characters
*/ */
public static function last($str, $n, $encoding = null) public static function last($str, $n, $encoding = null)
{ {
@@ -581,10 +585,10 @@ class StaticStringy
* Ensures that the string begins with $substring. If it doesn't, it's * Ensures that the string begins with $substring. If it doesn't, it's
* prepended. * prepended.
* *
* @param string $str The string to modify * @param string $str The string to modify
* @param string $substring The substring to add if not present * @param string $substring The substring to add if not present
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The string prefixed by the $substring * @return string The string prefixed by the $substring
*/ */
public static function ensureLeft($str, $substring, $encoding = null) public static function ensureLeft($str, $substring, $encoding = null)
{ {
@@ -595,10 +599,10 @@ class StaticStringy
* Ensures that the string begins with $substring. If it doesn't, it's * Ensures that the string begins with $substring. If it doesn't, it's
* appended. * appended.
* *
* @param string $str The string to modify * @param string $str The string to modify
* @param string $substring The substring to add if not present * @param string $substring The substring to add if not present
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The string suffixed by the $substring * @return string The string suffixed by the $substring
*/ */
public static function ensureRight($str, $substring, $encoding = null) public static function ensureRight($str, $substring, $encoding = null)
{ {
@@ -606,12 +610,12 @@ class StaticStringy
} }
/** /**
* Returns a new string with the prefix $substring removed, if it was present. * Returns a new string with the prefix $substring removed, if present.
* *
* @param string $str String from which to remove the prefix * @param string $str String from which to remove the prefix
* @param string $substring The prefix to remove * @param string $substring The prefix to remove
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The string without the prefix $substring * @return string The string without the prefix $substring
*/ */
public static function removeLeft($str, $substring, $encoding = null) public static function removeLeft($str, $substring, $encoding = null)
{ {
@@ -619,12 +623,12 @@ class StaticStringy
} }
/** /**
* Returns a new string with the suffix $substring removed, if it was present. * Returns a new string with the suffix $substring removed, if present.
* *
* @param string $str String from which to remove the suffix * @param string $str String from which to remove the suffix
* @param string $substring The suffix to remove * @param string $substring The suffix to remove
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The string without the suffix $substring * @return string The string without the suffix $substring
*/ */
public static function removeRight($str, $substring, $encoding = null) public static function removeRight($str, $substring, $encoding = null)
{ {
@@ -632,11 +636,12 @@ class StaticStringy
} }
/** /**
* Returns true if the string contains only alphabetic chars, false otherwise. * Returns true if the string contains only alphabetic chars, false
* otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only alphabetic chars * @return bool Whether or not $str contains only alphabetic chars
*/ */
public static function isAlpha($str, $encoding = null) public static function isAlpha($str, $encoding = null)
{ {
@@ -647,9 +652,9 @@ class StaticStringy
* Returns true if the string contains only alphabetic and numeric chars, * Returns true if the string contains only alphabetic and numeric chars,
* false otherwise. * false otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only alphanumeric chars * @return bool Whether or not $str contains only alphanumeric chars
*/ */
public static function isAlphanumeric($str, $encoding = null) public static function isAlphanumeric($str, $encoding = null)
{ {
@@ -657,11 +662,12 @@ class StaticStringy
} }
/** /**
* Returns true if the string contains only whitespace chars, false otherwise. * Returns true if the string contains only whitespace chars, false
* otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only whitespace characters * @return bool Whether or not $str contains only whitespace characters
*/ */
public static function isBlank($str, $encoding = null) public static function isBlank($str, $encoding = null)
{ {
@@ -671,9 +677,9 @@ class StaticStringy
/** /**
* Returns true if the string is JSON, false otherwise. * Returns true if the string is JSON, false otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str is JSON * @return bool Whether or not $str is JSON
*/ */
public static function isJson($str, $encoding = null) public static function isJson($str, $encoding = null)
{ {
@@ -681,11 +687,12 @@ class StaticStringy
} }
/** /**
* Returns true if the string contains only lower case chars, false otherwise. * Returns true if the string contains only lower case chars, false
* otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only lower case characters * @return bool Whether or not $str contains only lower case characters
*/ */
public static function isLowerCase($str, $encoding = null) public static function isLowerCase($str, $encoding = null)
{ {
@@ -695,9 +702,9 @@ class StaticStringy
/** /**
* Returns true if the string is serialized, false otherwise. * Returns true if the string is serialized, false otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str is serialized * @return bool Whether or not $str is serialized
*/ */
public static function isSerialized($str, $encoding = null) public static function isSerialized($str, $encoding = null)
{ {
@@ -705,11 +712,12 @@ class StaticStringy
} }
/** /**
* Returns true if the string contains only upper case chars, false otherwise. * Returns true if the string contains only upper case chars, false
* otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only upper case characters * @return bool Whether or not $str contains only upper case characters
*/ */
public static function isUpperCase($str, $encoding = null) public static function isUpperCase($str, $encoding = null)
{ {
@@ -717,11 +725,12 @@ class StaticStringy
} }
/** /**
* Returns true if the string contains only hexadecimal chars, false otherwise. * Returns true if the string contains only hexadecimal chars, false
* otherwise.
* *
* @param string $str String to check * @param string $str String to check
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return bool Whether or not $str contains only hexadecimal characters * @return bool Whether or not $str contains only hexadecimal characters
*/ */
public static function isHexadecimal($str, $encoding = null) public static function isHexadecimal($str, $encoding = null)
{ {
@@ -733,31 +742,32 @@ class StaticStringy
* By default, the comparison is case-sensitive, but can be made insensitive * By default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $str The string to search through * @param string $str The string to search through
* @param string $substring The substring to search for * @param string $substring The substring to search for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return int The number of $substring occurrences * @return int The number of $substring occurrences
*/ */
public static function countSubstr($str, $substring, $caseSensitive = true, public static function countSubstr($str, $substring, $caseSensitive = true,
$encoding = null) $encoding = null)
{ {
return Stringy::create($str, $encoding) return Stringy::create($str, $encoding)
->countSubstr($substring, $caseSensitive); ->countSubstr($substring, $caseSensitive);
} }
/** /**
* Replaces all occurrences of $search in $str by $replacement. * Replaces all occurrences of $search in $str by $replacement.
* *
* @param string $str The haystack to search through * @param string $str The haystack to search through
* @param string $search The needle to search for * @param string $search The needle to search for
* @param string $replacement The string to replace with * @param string $replacement The string to replace with
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The resulting string after the replacements * @return string The resulting string after the replacements
*/ */
public static function replace($str, $search, $replacement, $encoding = null) public static function replace($str, $search, $replacement, $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->replace($search, $replacement); return (string) Stringy::create($str, $encoding)
->replace($search,$replacement);
} }
/** /**
@@ -766,17 +776,17 @@ class StaticStringy
* in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support * in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support
* in the bundled version of Oniguruma in PHP 5.3. * in the bundled version of Oniguruma in PHP 5.3.
* *
* @param string $str The haystack to search through * @param string $str The haystack to search through
* @param string $pattern The regular expression pattern * @param string $pattern The regular expression pattern
* @param string $replacement The string to replace with * @param string $replacement The string to replace with
* @param string $options Matching conditions to be used * @param string $options Matching conditions to be used
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return string The resulting string after the replacements * @return string The resulting string after the replacements
*/ */
public static function regexReplace($str, $pattern, $replacement, public static function regexReplace($str, $pattern, $replacement,
$options = 'msr', $encoding = null) $options = 'msr', $encoding = null)
{ {
return (string) Stringy::create($str, $encoding)->regexReplace($pattern, return (string) Stringy::create($str, $encoding)
$replacement, $options, $encoding); ->regexReplace($pattern, $replacement, $options, $encoding);
} }
} }

View File

@@ -15,10 +15,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* an InvalidArgumentException if the first argument is an array or object * an InvalidArgumentException if the first argument is an array or object
* without a __toString method. * without a __toString method.
* *
* @param mixed $str Value to modify, after being cast to string * @param mixed $str Value to modify, after being cast to string
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @throws \InvalidArgumentException if an array or object without a * @throws \InvalidArgumentException if an array or object without a
* __toString method is passed as the first argument * __toString method is passed as the first argument
*/ */
public function __construct($str, $encoding = null) public function __construct($str, $encoding = null)
{ {
@@ -43,11 +43,11 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* then returns the initialized object. Throws an InvalidArgumentException * then returns the initialized object. Throws an InvalidArgumentException
* if the first argument is an array or object without a __toString method. * if the first argument is an array or object without a __toString method.
* *
* @param mixed $str Value to modify, after being cast to string * @param mixed $str Value to modify, after being cast to string
* @param string $encoding The character encoding * @param string $encoding The character encoding
* @return Stringy A Stringy object * @return Stringy A Stringy object
* @throws \InvalidArgumentException if an array or object without a * @throws \InvalidArgumentException if an array or object without a
* __toString method is passed as the first argument * __toString method is passed as the first argument
*/ */
public static function create($str, $encoding = null) public static function create($str, $encoding = null)
{ {
@@ -57,7 +57,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the value in $str. * Returns the value in $str.
* *
* @return string The current value of the $str property * @return string The current value of the $str property
*/ */
public function __toString() public function __toString()
{ {
@@ -67,7 +67,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the length of the string, implementing the countable interface. * Returns the length of the string, implementing the countable interface.
* *
* @return int The number of characters in the string, given the encoding * @return int The number of characters in the string, given the encoding
*/ */
public function count() public function count()
{ {
@@ -77,10 +77,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns a new ArrayIterator, thus implementing the IteratorAggregate * Returns a new ArrayIterator, thus implementing the IteratorAggregate
* interface. The ArrayIterator's constructor is passed an array of chars * interface. The ArrayIterator's constructor is passed an array of chars
* in the multibyte string. This allows the use of foreach with instances * in the multibyte string. This enables the use of foreach with instances
* of Stringy\Stringy. * of Stringy\Stringy.
* *
* @return \ArrayIterator An iterator for the characters in the string * @return \ArrayIterator An iterator for the characters in the string
*/ */
public function getIterator() public function getIterator()
{ {
@@ -92,8 +92,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* negative to count from the last character in the string. Implements * negative to count from the last character in the string. Implements
* part of the ArrayAccess interface. * part of the ArrayAccess interface.
* *
* @param mixed $offset The index to check * @param mixed $offset The index to check
* @return boolean Whether or not the index exists * @return boolean Whether or not the index exists
*/ */
public function offsetExists($offset) { public function offsetExists($offset) {
$length = $this->length(); $length = $this->length();
@@ -112,10 +112,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* ArrayAccess interface, and throws an OutOfBoundsException if the index * ArrayAccess interface, and throws an OutOfBoundsException if the index
* does not exist. * does not exist.
* *
* @param mixed $offset The index from which to retrieve the char * @param mixed $offset The index from which to retrieve the char
* @return mixed The character at the specified index * @return mixed The character at the specified index
* @throws \OutOfBoundsException If the positive or negative offset does * @throws \OutOfBoundsException If the positive or negative offset does
* not exist * not exist
*/ */
public function offsetGet($offset) { public function offsetGet($offset) {
$offset = (int) $offset; $offset = (int) $offset;
@@ -132,9 +132,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Implements part of the ArrayAccess interface, but throws an exception * Implements part of the ArrayAccess interface, but throws an exception
* when called. This maintains the immutability of Stringy objects. * when called. This maintains the immutability of Stringy objects.
* *
* @param mixed $offset The index of the character * @param mixed $offset The index of the character
* @param mixed $value Value to set * @param mixed $value Value to set
* @throws \Exception When called * @throws \Exception When called
*/ */
public function offsetSet($offset, $value) { public function offsetSet($offset, $value) {
// Stringy is immutable, cannot directly set char // Stringy is immutable, cannot directly set char
@@ -145,8 +145,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Implements part of the ArrayAccess interface, but throws an exception * Implements part of the ArrayAccess interface, but throws an exception
* when called. This maintains the immutability of Stringy objects. * when called. This maintains the immutability of Stringy objects.
* *
* @param mixed $offset The index of the character * @param mixed $offset The index of the character
* @throws \Exception When called * @throws \Exception When called
*/ */
public function offsetUnset($offset) { public function offsetUnset($offset) {
// Don't allow directly modifying the string // Don't allow directly modifying the string
@@ -171,7 +171,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Converts the first character of the supplied string to upper case. * Converts the first character of the supplied string to upper case.
* *
* @return Stringy Object with the first character of $str being upper case * @return Stringy Object with the first character of $str being upper case
*/ */
public function upperCaseFirst() public function upperCaseFirst()
{ {
@@ -187,7 +187,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Converts the first character of the string to lower case. * Converts the first character of the string to lower case.
* *
* @return Stringy Object with the first character of $str being lower case * @return Stringy Object with the first character of $str being lower case
*/ */
public function lowerCaseFirst() public function lowerCaseFirst()
{ {
@@ -201,11 +201,11 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns a camelCase version of the supplied string. Trims surrounding * Returns a camelCase version of the string. Trims surrounding spaces,
* spaces, capitalizes letters following digits, spaces, dashes and * capitalizes letters following digits, spaces, dashes and underscores,
* underscores, and removes spaces, dashes, underscores. * and removes spaces, dashes, as well as underscores.
* *
* @return Stringy Object with $str in camelCase * @return Stringy Object with $str in camelCase
*/ */
public function camelize() public function camelize()
{ {
@@ -236,7 +236,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* surrounding spaces, capitalizes letters following digits, spaces, dashes * surrounding spaces, capitalizes letters following digits, spaces, dashes
* and underscores, and removes spaces, dashes, underscores. * and underscores, and removes spaces, dashes, underscores.
* *
* @return Stringy Object with $str in UpperCamelCase * @return Stringy Object with $str in UpperCamelCase
*/ */
public function upperCamelize() public function upperCamelize()
{ {
@@ -248,7 +248,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* inserted before uppercase characters (with the exception of the first * inserted before uppercase characters (with the exception of the first
* character of the string), and in place of spaces as well as underscores. * character of the string), and in place of spaces as well as underscores.
* *
* @return Stringy Object with a dasherized $str * @return Stringy Object with a dasherized $str
*/ */
public function dasherize() public function dasherize()
{ {
@@ -272,7 +272,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* of the first character of the string), and in place of spaces as well as * of the first character of the string), and in place of spaces as well as
* dashes. * dashes.
* *
* @return Stringy Object with an underscored $str * @return Stringy Object with an underscored $str
*/ */
public function underscored() public function underscored()
{ {
@@ -293,7 +293,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns a case swapped version of the string. * Returns a case swapped version of the string.
* *
* @return Stringy Object whose $str has each character's case swapped * @return Stringy Object whose $str has each character's case swapped
*/ */
public function swapCase() public function swapCase()
{ {
@@ -316,12 +316,11 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns a trimmed string with the first letter of each word capitalized. * Returns a trimmed string with the first letter of each word capitalized.
* Ignores the case of other letters, allowing for the use of acronyms. * Ignores the case of other letters, preserving any acronyms. Also accepts
* Also accepts an array, $ignore, allowing you to list words not to be * an array, $ignore, allowing you to list words not to be capitalized.
* capitalized.
* *
* @param array $ignore An array of words not to capitalize * @param array $ignore An array of words not to capitalize
* @return Stringy Object with a titleized $str * @return Stringy Object with a titleized $str
*/ */
public function titleize($ignore = null) public function titleize($ignore = null)
{ {
@@ -348,7 +347,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Capitalizes the first word of the string, replaces underscores with * Capitalizes the first word of the string, replaces underscores with
* spaces, and strips '_id'. * spaces, and strips '_id'.
* *
* @return Stringy Object with a humanized $str * @return Stringy Object with a humanized $str
*/ */
public function humanize() public function humanize()
{ {
@@ -365,7 +364,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Windows-1252 (commonly used in Word documents) replaced by their ASCII * Windows-1252 (commonly used in Word documents) replaced by their ASCII
* equivalents. * equivalents.
* *
* @return Stringy Object whose $str has those characters removed * @return Stringy Object whose $str has those characters removed
*/ */
public function tidy() public function tidy()
{ {
@@ -384,7 +383,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* single space. This includes tabs and newline characters, as well as * single space. This includes tabs and newline characters, as well as
* multibyte whitespace such as the thin space and ideographic space. * multibyte whitespace such as the thin space and ideographic space.
* *
* @return Stringy Object with a trimmed $str and condensed whitespace * @return Stringy Object with a trimmed $str and condensed whitespace
*/ */
public function collapseWhitespace() public function collapseWhitespace()
{ {
@@ -402,7 +401,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Returns an ASCII version of the string. A set of non-ASCII characters are * 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. * replaced with their closest ASCII counterparts, and the rest are removed.
* *
* @return Stringy Object whose $str contains only ASCII characters * @return Stringy Object whose $str contains only ASCII characters
*/ */
public function toAscii() public function toAscii()
{ {
@@ -494,17 +493,17 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Pads the string to a given length with $padStr. If length is less than * 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 * or equal to the length of the string, no padding takes places. The
* string used for padding is a space, and the default type (one of 'left', * default string used for padding is a space, and the default type (one of
* 'right', 'both') is 'right'. Throws an InvalidArgumentException if * 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException
* $padType isn't one of those 3 values. * if $padType isn't one of those 3 values.
* *
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @param string $padType One of 'left', 'right', 'both' * @param string $padType One of 'left', 'right', 'both'
* @return Stringy Object with a padded $str * @return Stringy Object with a padded $str
* @throws InvalidArgumentException If $padType isn't one of 'right', * @throws InvalidArgumentException If $padType isn't one of 'right',
* 'left' or 'both' * 'left' or 'both'
*/ */
public function pad($length, $padStr = ' ', $padType = 'right') public function pad($length, $padStr = ' ', $padType = 'right')
{ {
@@ -555,9 +554,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Returns a new string of a given length such that the beginning of the * 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'. * string is padded. Alias for pad() with a $padType of 'left'.
* *
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @return Stringy Object with a left padded $str * @return Stringy Object with a left padded $str
*/ */
public function padLeft($length, $padStr = ' ') public function padLeft($length, $padStr = ' ')
{ {
@@ -565,12 +564,12 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns a new string of a given length such that the end of the string is * Returns a new string of a given length such that the end of the string
* padded. Alias for pad() with a $padType of 'right'. * is padded. Alias for pad() with a $padType of 'right'.
* *
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @return Stringy Object with a right padded $str * @return Stringy Object with a right padded $str
*/ */
public function padRight($length, $padStr = ' ') public function padRight($length, $padStr = ' ')
{ {
@@ -578,12 +577,12 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns a new string of a given length such that both sides of the string * 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'. * string are padded. Alias for pad() with a $padType of 'both'.
* *
* @param int $length Desired string length after padding * @param int $length Desired string length after padding
* @param string $padStr String used to pad, defaults to space * @param string $padStr String used to pad, defaults to space
* @return Stringy The padded string * @return Stringy The padded string
*/ */
public function padBoth($length, $padStr = ' ') public function padBoth($length, $padStr = ' ')
{ {
@@ -591,13 +590,13 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns true if the string begins with $substring, false otherwise. * Returns true if the string begins with $substring, false otherwise. By
* By default, the comparison is case-sensitive, but can be made insensitive * default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $substring The substring to look for * @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return bool Whether or not $str starts with $substring * @return bool Whether or not $str starts with $substring
*/ */
public function startsWith($substring, $caseSensitive = true) public function startsWith($substring, $caseSensitive = true)
{ {
@@ -614,12 +613,12 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns true if the string ends with $substring, false otherwise. By * Returns true if the string ends with $substring, false otherwise. By
* default, the comparison is case-sensitive, but can be made insensitive by * default, the comparison is case-sensitive, but can be made insensitive
* setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $substring The substring to look for * @param string $substring The substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return bool Whether or not $str ends with $substring * @return bool Whether or not $str ends with $substring
*/ */
public function endsWith($substring, $caseSensitive = true) public function endsWith($substring, $caseSensitive = true)
{ {
@@ -641,8 +640,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Converts each tab in the string to some number of spaces, as defined by * 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. * $tabLength. By default, each tab is converted to 4 consecutive spaces.
* *
* @param int $tabLength Number of spaces to replace each tab with * @param int $tabLength Number of spaces to replace each tab with
* @return Stringy Object whose $str has had tabs switched to spaces * @return Stringy Object whose $str has had tabs switched to spaces
*/ */
public function toSpaces($tabLength = 4) public function toSpaces($tabLength = 4)
{ {
@@ -655,12 +654,12 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Converts each occurrence of some consecutive number of spaces, as defined * Converts each occurrence of some consecutive number of spaces, as
* by $tabLength, to a tab. By default, each 4 consecutive spaces are * defined by $tabLength, to a tab. By default, each 4 consecutive spaces
* converted to a tab. * are converted to a tab.
* *
* @param int $tabLength Number of spaces to replace with a tab * @param int $tabLength Number of spaces to replace with a tab
* @return Stringy Object whose $str has had spaces switched to tabs * @return Stringy Object whose $str has had spaces switched to tabs
*/ */
public function toTabs($tabLength = 4) public function toTabs($tabLength = 4)
{ {
@@ -676,7 +675,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Converts all characters in the string to lowercase. An alias for PHP's * Converts all characters in the string to lowercase. An alias for PHP's
* mb_strtolower(). * mb_strtolower().
* *
* @return Stringy Object with all characters of $str being lowercase * @return Stringy Object with all characters of $str being lowercase
*/ */
public function toLowerCase() public function toLowerCase()
{ {
@@ -689,7 +688,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Converts all characters in the string to uppercase. An alias for PHP's * Converts all characters in the string to uppercase. An alias for PHP's
* mb_strtoupper(). * mb_strtoupper().
* *
* @return Stringy Object with all characters of $str being uppercase * @return Stringy Object with all characters of $str being uppercase
*/ */
public function toUpperCase() public function toUpperCase()
{ {
@@ -700,13 +699,13 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Converts the string into an URL slug. This includes replacing non-ASCII * Converts the string into an URL slug. This includes replacing non-ASCII
* characters with their closest ASCII equivalents, removing non-alphanumeric * characters with their closest ASCII equivalents, removing remaining
* and non-ASCII characters, and replacing whitespace with $replacement. * non-ASCII and non-alphanumeric characters, and replacing whitespace with
* The replacement defaults to a single dash, and the string is also * $replacement. The replacement defaults to a single dash, and the string
* converted to lowercase. * is also converted to lowercase.
* *
* @param string $replacement The string used to replace whitespace * @param string $replacement The string used to replace whitespace
* @return Stringy Object whose $str has been converted to an URL slug * @return Stringy Object whose $str has been converted to an URL slug
*/ */
public function slugify($replacement = '-') public function slugify($replacement = '-')
{ {
@@ -724,9 +723,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* the comparison is case-sensitive, but can be made insensitive by setting * the comparison is case-sensitive, but can be made insensitive by setting
* $caseSensitive to false. * $caseSensitive to false.
* *
* @param string $needle Substring to look for * @param string $needle Substring to look for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return bool Whether or not $str contains $needle * @return bool Whether or not $str contains $needle
*/ */
public function contains($needle, $caseSensitive = true) public function contains($needle, $caseSensitive = true)
{ {
@@ -739,8 +738,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Surrounds $str with the given substring. * Surrounds $str with the given substring.
* *
* @param string $substring The substring to add to both sides * @param string $substring The substring to add to both sides
* @return Stringy Object whose $str had the substring prepended and appended * @return Stringy Object whose $str had the substring prepended and appended
*/ */
public function surround($substring) public function surround($substring)
{ {
@@ -753,9 +752,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Inserts $substring into the string at the $index provided. * Inserts $substring into the string at the $index provided.
* *
* @param string $substring String to be inserted * @param string $substring String to be inserted
* @param int $index The index at which to insert the substring * @param int $index The index at which to insert the substring
* @return Stringy Object with the resulting $str after the insertion * @return Stringy Object with the resulting $str after the insertion
*/ */
public function insert($substring, $index) public function insert($substring, $index)
{ {
@@ -776,9 +775,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* truncating occurs, the string is further truncated so that the substring * truncating occurs, the string is further truncated so that the substring
* may be appended without exceeding the desired length. * may be appended without exceeding the desired length.
* *
* @param int $length Desired length of the truncated string * @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit * @param string $substring The substring to append if it can fit
* @return Stringy Object with the resulting $str after truncating * @return Stringy Object with the resulting $str after truncating
*/ */
public function truncate($length, $substring = '') public function truncate($length, $substring = '')
{ {
@@ -798,13 +797,13 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Truncates the string to a given length, while ensuring that it does not * Truncates the string to a given length, while ensuring that it does not
* chop words. If $substring is provided, and truncating occurs, the string * split words. If $substring is provided, and truncating occurs, the
* is further truncated so that the substring may be appended without * string is further truncated so that the substring may be appended without
* exceeding the desired length. * exceeding the desired length.
* *
* @param int $length Desired length of the truncated string * @param int $length Desired length of the truncated string
* @param string $substring The substring to append if it can fit * @param string $substring The substring to append if it can fit
* @return Stringy Object with the resulting $str after truncating * @return Stringy Object with the resulting $str after truncating
*/ */
public function safeTruncate($length, $substring = '') public function safeTruncate($length, $substring = '')
{ {
@@ -833,7 +832,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns a reversed string. A multibyte version of strrev(). * Returns a reversed string. A multibyte version of strrev().
* *
* @return Stringy Object with a reversed $str * @return Stringy Object with a reversed $str
*/ */
public function reverse() public function reverse()
{ {
@@ -852,7 +851,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* A multibyte str_shuffle() function. It returns a string with its * A multibyte str_shuffle() function. It returns a string with its
* characters in random order. * characters in random order.
* *
* @return Stringy Object with a shuffled $str * @return Stringy Object with a shuffled $str
*/ */
public function shuffle() public function shuffle()
{ {
@@ -870,7 +869,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the trimmed string. An alias for PHP's trim() function. * Returns the trimmed string. An alias for PHP's trim() function.
* *
* @return Stringy Object with a trimmed $str * @return Stringy Object with a trimmed $str
*/ */
public function trim() public function trim()
{ {
@@ -880,8 +879,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the longest common prefix between the string and $otherStr. * Returns the longest common prefix between the string and $otherStr.
* *
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @return Stringy Object with its $str being the longest common prefix * @return Stringy Object with its $str being the longest common prefix
*/ */
public function longestCommonPrefix($otherStr) public function longestCommonPrefix($otherStr)
{ {
@@ -904,8 +903,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the longest common suffix between the string and $otherStr. * Returns the longest common suffix between the string and $otherStr.
* *
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @return Stringy Object with its $str being the longest common suffix * @return Stringy Object with its $str being the longest common suffix
*/ */
public function longestCommonSuffix($otherStr) public function longestCommonSuffix($otherStr)
{ {
@@ -929,8 +928,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Returns the longest common substring between the string and $otherStr. * Returns the longest common substring between the string and $otherStr.
* In the case of ties, it returns that which occurs first. * In the case of ties, it returns that which occurs first.
* *
* @param string $otherStr Second string for comparison * @param string $otherStr Second string for comparison
* @return Stringy Object with its $str being the longest common substring * @return Stringy Object with its $str being the longest common substring
*/ */
public function longestCommonSubstring($otherStr) public function longestCommonSubstring($otherStr)
{ {
@@ -975,7 +974,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the length of the string. An alias for PHP's mb_strlen() function. * Returns the length of the string. An alias for PHP's mb_strlen() function.
* *
* @return int The number of characters in $str given the encoding * @return int The number of characters in $str given the encoding
*/ */
public function length() public function length()
{ {
@@ -987,9 +986,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* It differs from the mb_substr() function in that providing a $length of * 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. * null will return the rest of the string, rather than an empty string.
* *
* @param int $start Position of the first character to use * @param int $start Position of the first character to use
* @param int $length Maximum number of characters used * @param int $length Maximum number of characters used
* @return Stringy Object with its $str being the substring * @return Stringy Object with its $str being the substring
*/ */
public function substr($start, $length = null) public function substr($start, $length = null)
{ {
@@ -1007,10 +1006,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns the character of the string at $index, with indexes starting at 0. * Returns the character at $index, with indexes starting at 0.
* *
* @param int $index Position of the character * @param int $index Position of the character
* @return Stringy The character at $index * @return Stringy The character at $index
*/ */
public function at($index) public function at($index)
{ {
@@ -1020,8 +1019,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the first $n characters of the string. * Returns the first $n characters of the string.
* *
* @param int $n Number of characters to retrieve from the start * @param int $n Number of characters to retrieve from the start
* @return Stringy Object with its $str being the first $n chars * @return Stringy Object with its $str being the first $n chars
*/ */
public function first($n) public function first($n)
{ {
@@ -1039,8 +1038,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns the last $n characters of the string. * Returns the last $n characters of the string.
* *
* @param int $n Number of characters to retrieve from the end * @param int $n Number of characters to retrieve from the end
* @return Stringy Object with its $str being the last $n chars * @return Stringy Object with its $str being the last $n chars
*/ */
public function last($n) public function last($n)
{ {
@@ -1059,8 +1058,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Ensures that the string begins with $substring. If it doesn't, it's * Ensures that the string begins with $substring. If it doesn't, it's
* prepended. * prepended.
* *
* @param string $substring The substring to add if not present * @param string $substring The substring to add if not present
* @return Stringy Object with its $str prefixed by the $substring * @return Stringy Object with its $str prefixed by the $substring
*/ */
public function ensureLeft($substring) public function ensureLeft($substring)
{ {
@@ -1076,8 +1075,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Ensures that the string begins with $substring. If it doesn't, it's * Ensures that the string begins with $substring. If it doesn't, it's
* appended. * appended.
* *
* @param string $substring The substring to add if not present * @param string $substring The substring to add if not present
* @return Stringy Object with its $str suffixed by the $substring * @return Stringy Object with its $str suffixed by the $substring
*/ */
public function ensureRight($substring) public function ensureRight($substring)
{ {
@@ -1090,10 +1089,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns a new string with the prefix $substring removed, if it was present. * Returns a new string with the prefix $substring removed, if present.
* *
* @param string $substring The prefix to remove * @param string $substring The prefix to remove
* @return Stringy Object having a $str without the prefix $substring * @return Stringy Object having a $str without the prefix $substring
*/ */
public function removeLeft($substring) public function removeLeft($substring)
{ {
@@ -1108,10 +1107,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns a new string with the suffix $substring removed, if it was present. * Returns a new string with the suffix $substring removed, if present.
* *
* @param string $substring The suffix to remove * @param string $substring The suffix to remove
* @return Stringy Object having a $str without the suffix $substring * @return Stringy Object having a $str without the suffix $substring
*/ */
public function removeRight($substring) public function removeRight($substring)
{ {
@@ -1128,8 +1127,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns true if $str matches the supplied pattern, false otherwise. * Returns true if $str matches the supplied pattern, false otherwise.
* *
* @param string $pattern Regex pattern to match against * @param string $pattern Regex pattern to match against
* @return bool Whether or not $str matches the pattern * @return bool Whether or not $str matches the pattern
*/ */
private function matchesPattern($pattern) private function matchesPattern($pattern)
{ {
@@ -1143,9 +1142,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns true if the string contains only alphabetic chars, false otherwise. * Returns true if the string contains only alphabetic chars, false
* otherwise.
* *
* @return bool Whether or not $str contains only alphabetic chars * @return bool Whether or not $str contains only alphabetic chars
*/ */
public function isAlpha() public function isAlpha()
{ {
@@ -1156,7 +1156,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* Returns true if the string contains only alphabetic and numeric chars, * Returns true if the string contains only alphabetic and numeric chars,
* false otherwise. * false otherwise.
* *
* @return bool Whether or not $str contains only alphanumeric chars * @return bool Whether or not $str contains only alphanumeric chars
*/ */
public function isAlphanumeric() public function isAlphanumeric()
{ {
@@ -1164,9 +1164,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns true if the string contains only hexadecimal chars, false otherwise. * Returns true if the string contains only hexadecimal chars, false
* otherwise.
* *
* @return bool Whether or not $str contains only hexadecimal chars * @return bool Whether or not $str contains only hexadecimal chars
*/ */
public function isHexadecimal() public function isHexadecimal()
{ {
@@ -1174,9 +1175,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns true if the string contains only whitespace chars, false otherwise. * Returns true if the string contains only whitespace chars, false
* otherwise.
* *
* @return bool Whether or not $str contains only whitespace characters * @return bool Whether or not $str contains only whitespace characters
*/ */
public function isBlank() public function isBlank()
{ {
@@ -1186,7 +1188,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns true if the string is JSON, false otherwise. * Returns true if the string is JSON, false otherwise.
* *
* @return bool Whether or not $str is JSON * @return bool Whether or not $str is JSON
*/ */
public function isJson() public function isJson()
{ {
@@ -1199,9 +1201,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns true if the string contains only lower case chars, false otherwise. * Returns true if the string contains only lower case chars, false
* otherwise.
* *
* @return bool Whether or not $str contains only lower case characters * @return bool Whether or not $str contains only lower case characters
*/ */
public function isLowerCase() public function isLowerCase()
{ {
@@ -1209,9 +1212,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
} }
/** /**
* Returns true if the string contains only lower case chars, false otherwise. * Returns true if the string contains only lower case chars, false
* otherwise.
* *
* @return bool Whether or not $str contains only lower case characters * @return bool Whether or not $str contains only lower case characters
*/ */
public function isUpperCase() public function isUpperCase()
{ {
@@ -1221,7 +1225,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Returns true if the string is serialized, false otherwise. * Returns true if the string is serialized, false otherwise.
* *
* @return bool Whether or not $str is serialized * @return bool Whether or not $str is serialized
*/ */
public function isSerialized() public function isSerialized()
{ {
@@ -1233,9 +1237,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* By default, the comparison is case-sensitive, but can be made insensitive * By default, the comparison is case-sensitive, but can be made insensitive
* by setting $caseSensitive to false. * by setting $caseSensitive to false.
* *
* @param string $substring The substring to search for * @param string $substring The substring to search for
* @param bool $caseSensitive Whether or not to enforce case-sensitivity * @param bool $caseSensitive Whether or not to enforce case-sensitivity
* @return int The number of $substring occurrences * @return int The number of $substring occurrences
*/ */
public function countSubstr($substring, $caseSensitive = true) public function countSubstr($substring, $caseSensitive = true)
{ {
@@ -1252,9 +1256,9 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
/** /**
* Replaces all occurrences of $search in $str by $replacement. * Replaces all occurrences of $search in $str by $replacement.
* *
* @param string $search The needle to search for * @param string $search The needle to search for
* @param string $replacement The string to replace with * @param string $replacement The string to replace with
* @return Stringy Object with the resulting $str after the replacements * @return Stringy Object with the resulting $str after the replacements
*/ */
public function replace($search, $replacement) public function replace($search, $replacement)
{ {
@@ -1277,10 +1281,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
* in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support * in mb_ereg_replace() requires PHP 5.4+. This is due to a lack of support
* in the bundled version of Oniguruma in PHP 5.3. * in the bundled version of Oniguruma in PHP 5.3.
* *
* @param string $pattern The regular expression pattern * @param string $pattern The regular expression pattern
* @param string $replacement The string to replace with * @param string $replacement The string to replace with
* @param string $options Matching conditions to be used * @param string $options Matching conditions to be used
* @return Stringy Object with the resulting $str after the replacements * @return Stringy Object with the resulting $str after the replacements
*/ */
public function regexReplace($pattern, $replacement, $options = 'msr') public function regexReplace($pattern, $replacement, $options = 'msr')
{ {