mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-15 09:44:14 +02:00
Code comments and documentation cleanup
This commit is contained in:
35
README.md
35
README.md
@@ -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
|
||||||
|
@@ -41,9 +41,9 @@ 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
|
||||||
@@ -111,9 +111,8 @@ 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
|
||||||
@@ -179,10 +178,10 @@ 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
|
||||||
@@ -212,12 +211,13 @@ class StaticStringy
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
@@ -227,11 +227,12 @@ class StaticStringy
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
@@ -242,12 +243,13 @@ class StaticStringy
|
|||||||
*/
|
*/
|
||||||
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
|
||||||
@@ -265,8 +267,8 @@ class StaticStringy
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -295,9 +297,9 @@ 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
|
||||||
@@ -336,10 +338,10 @@ 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
|
||||||
@@ -364,7 +366,8 @@ class StaticStringy
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -390,7 +393,8 @@ class StaticStringy
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,8 +417,8 @@ class StaticStringy
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -539,7 +543,7 @@ 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
|
||||||
@@ -606,7 +610,7 @@ 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
|
||||||
@@ -619,7 +623,7 @@ 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
|
||||||
@@ -632,7 +636,8 @@ 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
|
||||||
@@ -657,7 +662,8 @@ 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
|
||||||
@@ -681,7 +687,8 @@ 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
|
||||||
@@ -705,7 +712,8 @@ 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
|
||||||
@@ -717,7 +725,8 @@ 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
|
||||||
@@ -757,7 +766,8 @@ class StaticStringy
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -776,7 +786,7 @@ class StaticStringy
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ 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
|
||||||
@@ -201,9 +201,9 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -316,9 +316,8 @@ 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
|
||||||
@@ -494,10 +493,10 @@ 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
|
||||||
@@ -565,8 +564,8 @@ 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
|
||||||
@@ -578,7 +577,7 @@ 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
|
||||||
@@ -591,8 +590,8 @@ 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
|
||||||
@@ -614,8 +613,8 @@ 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
|
||||||
@@ -655,9 +654,9 @@ 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
|
||||||
@@ -700,10 +699,10 @@ 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
|
||||||
@@ -798,8 +797,8 @@ 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
|
||||||
@@ -1007,7 +1006,7 @@ 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
|
||||||
@@ -1090,7 +1089,7 @@ 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
|
||||||
@@ -1108,7 +1107,7 @@ 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
|
||||||
@@ -1143,7 +1142,8 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -1164,7 +1164,8 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -1174,7 +1175,8 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -1199,7 +1201,8 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -1209,7 +1212,8 @@ 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
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user