public function split($pattern, int $limit = -1): array
    {
        Assert::typeOf(['string', __CLASS__], $pattern);

        $response = [];
        $results  = preg_split((string) $pattern, $this->data, $limit);

        if ($results === false) {
            throw new RuntimeException('An unknown error occurred while splitting string!');
        }

        foreach ($results as $result) {
            $response[] = new static($result, $this->encoding);
        }

        return $response;
    }
public function split($pattern, int $limit = -1): array
    {
        Assert::typeOf(['string', __CLASS__], $pattern);

        $response = [];
        $results  = preg_split((string) $pattern, $this->data, $limit);

        if ($results === false) {
            throw new RuntimeException('An unknown error occurred while splitting string!');
        }

        foreach ($results as $result) {
            $response[] = new static($result, $this->encoding);
        }

        return $response;
    }
public function split ( $ pattern , int $ limit = - 1 ) : array { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ pattern ) ; $ response = [ ] ; $ results = preg_split ( ( string ) $ pattern , $ this -> data , $ limit ) ; if ( $ results === false ) { throw new RuntimeException ( 'An unknown error occurred while splitting string!' ) ; } foreach ( $ results as $ result ) { $ response [ ] = new static ( $ result , $ this -> encoding ) ; } return $ response ; }
Splits this string around matches of the given regex pattern

@param static|string $pattern
@param int           $limit
@return static[]
@throws InvalidArgumentException
@throws RuntimeException
@throws TypeError
Splits this string around matches of the given regex pattern