mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-13 00:34:11 +02:00
Style fixes
This commit is contained in:
24
README.md
24
README.md
@@ -479,30 +479,32 @@ S::humanize('author_id'); // 'Author'
|
||||
|
||||
#### indexOf
|
||||
|
||||
$stringy->indexOf(string $substr [, $offset = 0 ]);
|
||||
$stringy->indexOf(string $needle [, $offset = 0 ]);
|
||||
|
||||
S::indexOf(string $str , string $substr [, $offset = 0 [, $encoding = null ]])
|
||||
S::indexOf(string $haystack , string $needle [, $offset = 0 [, $encoding = null ]])
|
||||
|
||||
Returns the offset/index of the first occurrence of $substr in the string.
|
||||
In case $substr is not a substring of the string, returns false.
|
||||
Returns the index of the first occurrence of $needle in the string,
|
||||
and false if not found. Accepts an optional offset from which to begin
|
||||
the search.
|
||||
|
||||
```php
|
||||
S::create('string', 'UTF-8')->indexOf('ing');
|
||||
S::indexOf('string', 'ing', 0, 'UTF-8'); // 3
|
||||
S::indexOf('string', 'ing'); // 3
|
||||
```
|
||||
|
||||
#### indexOfLast
|
||||
|
||||
$stringy->indexOfLast(string $substr [, $offset = 0 ]);
|
||||
$stringy->indexOfLast(string $needle [, $offset = 0 ]);
|
||||
|
||||
S::indexOfLast(string $str , string $substr [, $offset = 0 [, $encoding = null ]])
|
||||
S::indexOfLast(string $haystack , string $needle [, $offset = 0 [, $encoding = null ]])
|
||||
|
||||
Returns the offset/index of the last occurrence of $substr in the string.
|
||||
In case $substr is not a substring of the string, returns false.
|
||||
Returns the index of the last occurrence of $needle in the string,
|
||||
and false if not found. Accepts an optional offset from which to begin
|
||||
the search.
|
||||
|
||||
```php
|
||||
S::create('string', 'UTF-8')->indexOfLast('ing');
|
||||
S::indexOfLast('string string', 'ing', 0, 'UTF-8'); // 10
|
||||
S::indexOfLast('string string', 'ing'); // 10
|
||||
```
|
||||
|
||||
#### insert
|
||||
@@ -1054,7 +1056,7 @@ $stringy->trim()
|
||||
|
||||
S::trim(string $str)
|
||||
|
||||
Returns the trimmed string. An alias for PHP's trim() function.
|
||||
Returns the trimmed string.
|
||||
|
||||
```php
|
||||
S::create('fòô bàř', 'UTF-8')->trim();
|
||||
|
@@ -422,31 +422,37 @@ class StaticStringy
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset/index of the first occurance of $substr in the string.
|
||||
* In case $substr is not a substring of the string, returns false.
|
||||
* Returns the index of the first occurrence of $needle in the string,
|
||||
* and false if not found. Accepts an optional offset from which to begin
|
||||
* the search.
|
||||
*
|
||||
* @param string $str The haystack to search through
|
||||
* @param string $substr substring
|
||||
* @param int $offset
|
||||
* @return int|bool
|
||||
* @param string $haystack String to search
|
||||
* @param string $needle Substring to look for
|
||||
* @param int $offset Offset from which to search
|
||||
* @return int|bool The occurrence's index if found, otherwise false
|
||||
*/
|
||||
public static function indexOf($str, $substr, $offset = 0, $encoding = null)
|
||||
public static function indexOf($haystack, $needle, $offset = 0,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->indexOf($substr, $offset);
|
||||
return Stringy::create($haystack, $encoding)
|
||||
->indexOf($needle, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset/index of the last occurance of $substr in the string.
|
||||
* In case $substr is not a substring of the string, returns false.
|
||||
* Returns the index of the last occurrence of $needle in the string,
|
||||
* and false if not found. Accepts an optional offset from which to begin
|
||||
* the search.
|
||||
*
|
||||
* @param string $str The haystack to search through
|
||||
* @param string $substr substring
|
||||
* @param int $offset
|
||||
* @return int|bool
|
||||
* @param string $haystack String to search
|
||||
* @param string $needle Substring to look for
|
||||
* @param int $offset Offset from which to search
|
||||
* @return int|bool The last occurrence's index if found, otherwise false
|
||||
*/
|
||||
public static function indexOfLast($str, $substr, $offset = 0, $encoding = null)
|
||||
public static function indexOfLast($haystack, $needle, $offset = 0,
|
||||
$encoding = null)
|
||||
{
|
||||
return Stringy::create($str, $encoding)->indexOfLast($substr, $offset);
|
||||
return Stringy::create($haystack, $encoding)
|
||||
->indexOfLast($needle, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -895,29 +895,33 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset/index of the first occurrence of $substr in the string.
|
||||
* In case $substr is not a substring of the string, returns false.
|
||||
* Returns the index of the first occurrence of $needle in the string,
|
||||
* and false if not found. Accepts an optional offset from which to begin
|
||||
* the search.
|
||||
*
|
||||
* @param string $substr substring
|
||||
* @param int $offset
|
||||
* @return int|bool
|
||||
* @param string $needle Substring to look for
|
||||
* @param int $offset Offset from which to search
|
||||
* @return int|bool The occurrence's index if found, otherwise false
|
||||
*/
|
||||
public function indexOf($substr, $offset = 0)
|
||||
public function indexOf($needle, $offset = 0)
|
||||
{
|
||||
return mb_strpos($this->str, (string)$substr, (int)$offset, $this->encoding);
|
||||
return mb_strpos($this->str, (string) $needle,
|
||||
(int) $offset, $this->encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the offset/index of the last occurrence of $substr in the string.
|
||||
* In case $substr is not a substring of the string, returns false.
|
||||
* Returns the index of the last occurrence of $needle in the string,
|
||||
* and false if not found. Accepts an optional offset from which to begin
|
||||
* the search.
|
||||
*
|
||||
* @param string $substr substring
|
||||
* @param int $offset
|
||||
* @return int|bool
|
||||
* @param string $needle Substring to look for
|
||||
* @param int $offset Offset from which to search
|
||||
* @return int|bool The last occurrence's index if found, otherwise false
|
||||
*/
|
||||
public function indexOfLast($substr, $offset = 0)
|
||||
public function indexOfLast($needle, $offset = 0)
|
||||
{
|
||||
return mb_strrpos($this->str, (string)$substr, (int)$offset, $this->encoding);
|
||||
return mb_strrpos($this->str, (string) $needle,
|
||||
(int) $offset, $this->encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1057,10 +1061,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the trimmed string. An alias for PHP's trim() function.
|
||||
* Returns the trimmed string.
|
||||
*
|
||||
* @param string $charList list with characters to be removed
|
||||
* @param int $type which function will be used to trim the string, trim, ltrim or rtrim
|
||||
* @param string $charList Characters to be removed
|
||||
* @param int $type One of TRIM_BOTH, TRIM_LEFT or TRIM_RIGHT
|
||||
* @return Stringy Object with a trimmed $str
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -1072,14 +1076,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
||||
);
|
||||
}
|
||||
|
||||
if (!in_array($type, array(
|
||||
self::TRIM_BOTH,
|
||||
self::TRIM_LEFT,
|
||||
self::TRIM_RIGHT,
|
||||
))) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Type of trim function must be trim (default), rtrim or ltrim, just as native php.'
|
||||
);
|
||||
$validTypes = array(self::TRIM_BOTH, self::TRIM_LEFT, self::TRIM_RIGHT);
|
||||
if (!in_array($type, $validTypes)) {
|
||||
throw new \InvalidArgumentException('Type of trim function must ' .
|
||||
'be trim (default), rtrim or ltrim, just as native php.');
|
||||
}
|
||||
|
||||
return static::create($type($this->str, $charList), $this->encoding);
|
||||
|
Reference in New Issue
Block a user