diff --git a/src/Stringy.php b/src/Stringy.php index 7f6688d..1de02a5 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -1077,17 +1077,10 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess */ public function substr($start, $length = null) { - $stringy = self::create($this->str, $this->encoding); + $length = $length === null ? $this->length() : $length; + $str = mb_substr($this->str, $start, $length, $this->encoding); - if ($length === null) { - $stringy->str = mb_substr($stringy->str, $start, - $stringy->length() - $start, $this->encoding); - } else { - $stringy->str = mb_substr($stringy->str, $start, $length, - $stringy->encoding); - } - - return $stringy; + return self::create($str, $this->encoding); } /**