mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-12 16:24:00 +02:00
Go psr-2
This commit is contained in:
@@ -26,7 +26,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'Passed value cannot be an array'
|
'Passed value cannot be an array'
|
||||||
);
|
);
|
||||||
} else if (is_object($str) && !method_exists($str, '__toString')) {
|
} elseif (is_object($str) && !method_exists($str, '__toString')) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'Passed object must have a __toString method'
|
'Passed object must have a __toString method'
|
||||||
);
|
);
|
||||||
@@ -105,7 +105,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
* @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();
|
||||||
$offset = (int) $offset;
|
$offset = (int) $offset;
|
||||||
|
|
||||||
@@ -127,7 +128,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
* @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;
|
||||||
$length = $this->length();
|
$length = $this->length();
|
||||||
|
|
||||||
@@ -146,7 +148,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
* @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
|
||||||
throw new \Exception('Stringy object is immutable, cannot modify char');
|
throw new \Exception('Stringy object is immutable, cannot modify char');
|
||||||
}
|
}
|
||||||
@@ -158,7 +161,8 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
* @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
|
||||||
throw new \Exception('Stringy object is immutable, cannot unset char');
|
throw new \Exception('Stringy object is immutable, cannot unset char');
|
||||||
}
|
}
|
||||||
@@ -224,7 +228,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
|
|
||||||
$camelCase = preg_replace_callback(
|
$camelCase = preg_replace_callback(
|
||||||
'/[-_\s]+(.)?/u',
|
'/[-_\s]+(.)?/u',
|
||||||
function($match) use ($encoding) {
|
function ($match) use ($encoding) {
|
||||||
return $match[1] ? mb_strtoupper($match[1], $encoding) : '';
|
return $match[1] ? mb_strtoupper($match[1], $encoding) : '';
|
||||||
},
|
},
|
||||||
$stringy->trim()->lowerCaseFirst()->str
|
$stringy->trim()->lowerCaseFirst()->str
|
||||||
@@ -232,7 +236,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
|
|
||||||
$stringy->str = preg_replace_callback(
|
$stringy->str = preg_replace_callback(
|
||||||
'/[\d]+(.)?/u',
|
'/[\d]+(.)?/u',
|
||||||
function($match) use ($encoding) {
|
function ($match) use ($encoding) {
|
||||||
return mb_strtoupper($match[0], $encoding);
|
return mb_strtoupper($match[0], $encoding);
|
||||||
},
|
},
|
||||||
$camelCase
|
$camelCase
|
||||||
|
Reference in New Issue
Block a user