public function substr(int $start, int $length = null): self
    {
        if ($start < 0) {
            throw new InvalidArgumentException('Negative index is not allowed!');
        }

        return new static(mb_substr($this->data, $start, $length, $this->encoding), $this->encoding);
    }
public function substr(int $start, int $length = null): self
    {
        if ($start < 0) {
            throw new InvalidArgumentException('Negative index is not allowed!');
        }

        return new static(mb_substr($this->data, $start, $length, $this->encoding), $this->encoding);
    }
public function substr ( int $ start , int $ length = null ) : self { if ( $ start < 0 ) { throw new InvalidArgumentException ( 'Negative index is not allowed!' ) ; } return new static ( mb_substr ( $ this -> data , $ start , $ length , $ this -> encoding ) , $ this -> encoding ) ; }
Returns a new string object that is a substring of this string

@param int $start
@param int $length
@return static
@throws InvalidArgumentException
Returns a new string object that is a substring of this string