mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-04 20:37:29 +02:00
Update alignment in phpdocs
This commit is contained in:
124
src/Stringy.php
124
src/Stringy.php
@@ -62,8 +62,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* then returns the initialized object. Throws an InvalidArgumentException
|
||||
* 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 string $encoding The character encoding
|
||||
* @param mixed $str Value to modify, after being cast to string
|
||||
* @param string $encoding The character encoding
|
||||
* @return static A Stringy object
|
||||
* @throws \InvalidArgumentException if an array or object without a
|
||||
* __toString method is passed as the first argument
|
||||
@@ -86,7 +86,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* Returns a new string with $string appended.
|
||||
*
|
||||
* @param string $string The string to append
|
||||
* @param string $string The string to append
|
||||
* @return static Object with appended $string
|
||||
*/
|
||||
public function append($string)
|
||||
@@ -97,7 +97,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static The character at $index
|
||||
*/
|
||||
public function at($index)
|
||||
@@ -219,9 +219,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* default the comparison is case-sensitive, but can be made insensitive by
|
||||
* setting $caseSensitive to false.
|
||||
*
|
||||
* @param string[] $needles Substrings to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @return bool Whether or not $str contains $needle
|
||||
* @param string[] $needles Substrings to look for
|
||||
* @param bool $caseSensitive Whether or not to enforce case-sensitivity
|
||||
* @return bool Whether or not $str contains $needle
|
||||
*/
|
||||
public function containsAll($needles, $caseSensitive = true)
|
||||
{
|
||||
@@ -311,7 +311,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* of the first character of the string), and in place of spaces, dashes,
|
||||
* and underscores. Alpha delimiters are not converted to lowercase.
|
||||
*
|
||||
* @param string $delimiter Sequence used to separate parts of the string
|
||||
* @param string $delimiter Sequence used to separate parts of the string
|
||||
* @return static Object with a delimited $str
|
||||
*/
|
||||
public function delimit($delimiter)
|
||||
@@ -382,7 +382,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Ensures that the string begins with $substring. If it doesn't, it's
|
||||
* prepended.
|
||||
*
|
||||
* @param string $substring The substring to add if not present
|
||||
* @param string $substring The substring to add if not present
|
||||
* @return static Object with its $str prefixed by the $substring
|
||||
*/
|
||||
public function ensureLeft($substring)
|
||||
@@ -400,7 +400,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Ensures that the string ends with $substring. If it doesn't, it's
|
||||
* appended.
|
||||
*
|
||||
* @param string $substring The substring to add if not present
|
||||
* @param string $substring The substring to add if not present
|
||||
* @return static Object with its $str suffixed by the $substring
|
||||
*/
|
||||
public function ensureRight($substring)
|
||||
@@ -417,7 +417,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object with its $str being the first $n chars
|
||||
*/
|
||||
public function first($n)
|
||||
@@ -484,7 +484,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* http://php.net/manual/en/function.html-entity-decode.php
|
||||
*
|
||||
* @param int|null $flags Optional flags
|
||||
* @return static Object with the resulting $str after being html decoded.
|
||||
* @return static Object with the resulting $str after being html decoded.
|
||||
*/
|
||||
public function htmlDecode($flags = ENT_COMPAT)
|
||||
{
|
||||
@@ -499,7 +499,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* for a list of flags.
|
||||
*
|
||||
* @param int|null $flags Optional flags
|
||||
* @return static Object with the resulting $str after being html encoded.
|
||||
* @return static Object with the resulting $str after being html encoded.
|
||||
*/
|
||||
public function htmlEncode($flags = ENT_COMPAT)
|
||||
{
|
||||
@@ -555,8 +555,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* Inserts $substring into the string at the $index provided.
|
||||
*
|
||||
* @param string $substring String to be inserted
|
||||
* @param int $index The index at which to insert the substring
|
||||
* @param string $substring String to be inserted
|
||||
* @param int $index The index at which to insert the substring
|
||||
* @return static Object with the resulting $str after the insertion
|
||||
*/
|
||||
public function insert($substring, $index)
|
||||
@@ -683,7 +683,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object with its $str being the last $n chars
|
||||
*/
|
||||
public function last($n)
|
||||
@@ -727,7 +727,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object with its $str being the longest common prefix
|
||||
*/
|
||||
public function longestCommonPrefix($otherStr)
|
||||
@@ -752,7 +752,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object with its $str being the longest common suffix
|
||||
*/
|
||||
public function longestCommonSuffix($otherStr)
|
||||
@@ -778,7 +778,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Returns the longest common substring between the string and $otherStr.
|
||||
* 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 static Object with its $str being the longest common substring
|
||||
*/
|
||||
public function longestCommonSubstring($otherStr)
|
||||
@@ -916,9 +916,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* 'left', 'right', 'both') is 'right'. Throws an InvalidArgumentException
|
||||
* if $padType isn't one of those 3 values.
|
||||
*
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $padType One of 'left', 'right', 'both'
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param string $padType One of 'left', 'right', 'both'
|
||||
* @return static Object with a padded $str
|
||||
* @throws /InvalidArgumentException If $padType isn't one of 'right',
|
||||
* 'left' or 'both'
|
||||
@@ -944,8 +944,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* 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'.
|
||||
*
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @return static String with padding applied
|
||||
*/
|
||||
public function padBoth($length, $padStr = ' ')
|
||||
@@ -960,8 +960,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* 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'.
|
||||
*
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @return static String with left padding
|
||||
*/
|
||||
public function padLeft($length, $padStr = ' ')
|
||||
@@ -973,8 +973,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Returns a new string of a given length such that the end of the string
|
||||
* is padded. Alias for pad() with a $padType of 'right'.
|
||||
*
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @param int $length Desired string length after padding
|
||||
* @param string $padStr String used to pad, defaults to space
|
||||
* @return static String with right padding
|
||||
*/
|
||||
public function padRight($length, $padStr = ' ')
|
||||
@@ -985,7 +985,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* Returns a new string starting with $string.
|
||||
*
|
||||
* @param string $string The string to append
|
||||
* @param string $string The string to append
|
||||
* @return static Object with appended $string
|
||||
*/
|
||||
public function prepend($string)
|
||||
@@ -1000,9 +1000,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* to a lack of support in the bundled version of Oniguruma in PHP < 5.6,
|
||||
* and current versions of HHVM (3.8 and below).
|
||||
*
|
||||
* @param string $pattern The regular expression pattern
|
||||
* @param string $replacement The string to replace with
|
||||
* @param string $options Matching conditions to be used
|
||||
* @param string $pattern The regular expression pattern
|
||||
* @param string $replacement The string to replace with
|
||||
* @param string $options Matching conditions to be used
|
||||
* @return static Object with the resulting $str after the replacements
|
||||
*/
|
||||
public function regexReplace($pattern, $replacement, $options = 'msr')
|
||||
@@ -1019,7 +1019,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object having a $str without the prefix $substring
|
||||
*/
|
||||
public function removeLeft($substring)
|
||||
@@ -1037,7 +1037,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object having a $str without the suffix $substring
|
||||
*/
|
||||
public function removeRight($substring)
|
||||
@@ -1055,7 +1055,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* Returns a repeated string given a multiplier. An alias for str_repeat.
|
||||
*
|
||||
* @param int $multiplier The number of times to repeat the string
|
||||
* @param int $multiplier The number of times to repeat the string
|
||||
* @return static Object with a repeated str
|
||||
*/
|
||||
public function repeat($multiplier)
|
||||
@@ -1068,8 +1068,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* Replaces all occurrences of $search in $str by $replacement.
|
||||
*
|
||||
* @param string $search The needle to search for
|
||||
* @param string $replacement The string to replace with
|
||||
* @param string $search The needle to search for
|
||||
* @param string $replacement The string to replace with
|
||||
* @return static Object with the resulting $str after the replacements
|
||||
*/
|
||||
public function replace($search, $replacement)
|
||||
@@ -1101,8 +1101,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* string is further truncated so that the substring may be appended without
|
||||
* exceeding the desired length.
|
||||
*
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @return static Object with the resulting $str after truncating
|
||||
*/
|
||||
public function safeTruncate($length, $substring = '')
|
||||
@@ -1159,7 +1159,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* $replacement. The replacement defaults to a single dash, and the string
|
||||
* is also converted to lowercase.
|
||||
*
|
||||
* @param string $replacement The string used to replace whitespace
|
||||
* @param string $replacement The string used to replace whitespace
|
||||
* @return static Object whose $str has been converted to an URL slug
|
||||
*/
|
||||
public function slugify($replacement = '-')
|
||||
@@ -1229,8 +1229,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* the remaining string. If $end is negative, it is computed from the end
|
||||
* of the string.
|
||||
*
|
||||
* @param int $start Initial index from which to begin extraction
|
||||
* @param int $end Optional index at which to end extraction
|
||||
* @param int $start Initial index from which to begin extraction
|
||||
* @param int $end Optional index at which to end extraction
|
||||
* @return static Object with its $str being the extracted substring
|
||||
*/
|
||||
public function slice($start, $end = null)
|
||||
@@ -1253,8 +1253,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* array of Stringy objects. An optional integer $limit will truncate the
|
||||
* results.
|
||||
*
|
||||
* @param string $pattern The regex with which to split the string
|
||||
* @param int $limit Optional maximum number of results to return
|
||||
* @param string $pattern The regex with which to split the string
|
||||
* @param int $limit Optional maximum number of results to return
|
||||
* @return static[] An array of Stringy objects
|
||||
*/
|
||||
public function split($pattern, $limit = null)
|
||||
@@ -1317,8 +1317,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* 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.
|
||||
*
|
||||
* @param int $start Position of the first character to use
|
||||
* @param int $length Maximum number of characters used
|
||||
* @param int $start Position of the first character to use
|
||||
* @param int $length Maximum number of characters used
|
||||
* @return static Object with its $str being the substring
|
||||
*/
|
||||
public function substr($start, $length = null)
|
||||
@@ -1332,7 +1332,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
/**
|
||||
* 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 static Object whose $str had the substring both prepended and
|
||||
* appended
|
||||
*/
|
||||
@@ -1397,7 +1397,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Also accepts an array, $ignore, allowing you to list words not to be
|
||||
* capitalized.
|
||||
*
|
||||
* @param array $ignore An array of words not to capitalize
|
||||
* @param array $ignore An array of words not to capitalize
|
||||
* @return static Object with a titleized $str
|
||||
*/
|
||||
public function titleize($ignore = null)
|
||||
@@ -1430,8 +1430,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* en, en_GB, or en-GB. For example, passing "de" results in "äöü" mapping
|
||||
* to "aeoeue" rather than "aou" as in other languages.
|
||||
*
|
||||
* @param string $language Language of the source string
|
||||
* @param bool $removeUnsupported Whether or not to remove the
|
||||
* @param string $language Language of the source string
|
||||
* @param bool $removeUnsupported Whether or not to remove the
|
||||
* unsupported characters
|
||||
* @return static Object whose $str contains only ASCII characters
|
||||
*/
|
||||
@@ -1506,7 +1506,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* 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.
|
||||
*
|
||||
* @param int $tabLength Number of spaces to replace each tab with
|
||||
* @param int $tabLength Number of spaces to replace each tab with
|
||||
* @return static Object whose $str has had tabs switched to spaces
|
||||
*/
|
||||
public function toSpaces($tabLength = 4)
|
||||
@@ -1522,7 +1522,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* defined by $tabLength, to a tab. By default, each 4 consecutive spaces
|
||||
* 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 static Object whose $str has had spaces switched to tabs
|
||||
*/
|
||||
public function toTabs($tabLength = 4)
|
||||
@@ -1563,7 +1563,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* string. Supports the removal of unicode whitespace. Accepts an optional
|
||||
* string of characters to strip instead of the defaults.
|
||||
*
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @return static Object with a trimmed $str
|
||||
*/
|
||||
public function trim($chars = null)
|
||||
@@ -1578,7 +1578,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Supports the removal of unicode whitespace. Accepts an optional
|
||||
* string of characters to strip instead of the defaults.
|
||||
*
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @return static Object with a trimmed $str
|
||||
*/
|
||||
public function trimLeft($chars = null)
|
||||
@@ -1593,7 +1593,7 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Supports the removal of unicode whitespace. Accepts an optional
|
||||
* string of characters to strip instead of the defaults.
|
||||
*
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @param string $chars Optional string of characters to strip
|
||||
* @return static Object with a trimmed $str
|
||||
*/
|
||||
public function trimRight($chars = null)
|
||||
@@ -1608,8 +1608,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* truncating occurs, the string is further truncated so that the substring
|
||||
* may be appended without exceeding the desired length.
|
||||
*
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @param int $length Desired length of the truncated string
|
||||
* @param string $substring The substring to append if it can fit
|
||||
* @return static Object with the resulting $str after truncating
|
||||
*/
|
||||
public function truncate($length, $substring = '')
|
||||
@@ -1851,8 +1851,8 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* For example, German will map 'ä' to 'ae', while other languages
|
||||
* will simply return 'a'.
|
||||
*
|
||||
* param string $language Language of the source string
|
||||
* @return array An array of replacements.
|
||||
* @param string $language Language of the source string
|
||||
* @return array An array of replacements.
|
||||
*/
|
||||
protected static function langSpecificCharsArray($language = 'en')
|
||||
{
|
||||
@@ -1884,9 +1884,9 @@ class Stringy implements Countable, IteratorAggregate, ArrayAccess
|
||||
* Adds the specified amount of left and right padding to the given string.
|
||||
* The default character used is a space.
|
||||
*
|
||||
* @param int $left Length of left padding
|
||||
* @param int $right Length of right padding
|
||||
* @param string $padStr String used to pad
|
||||
* @param int $left Length of left padding
|
||||
* @param int $right Length of right padding
|
||||
* @param string $padStr String used to pad
|
||||
* @return static String with padding applied
|
||||
*/
|
||||
protected function applyPadding($left = 0, $right = 0, $padStr = ' ')
|
||||
|
Reference in New Issue
Block a user