src/Str.php
public function chunk(int $size = 1): StreamInterface
    {
        $stream = new Stream(self::class);
        $string = $this;

        while ($string->length() > 0) {
            $stream = $stream->add($string->substring(0, $size));
            $string = $string->substring($size);
        }

        return $stream;
    }
public function chunk(int $size = 1): StreamInterface
    {
        $stream = new Stream(self::class);
        $string = $this;

        while ($string->length() > 0) {
            $stream = $stream->add($string->substring(0, $size));
            $string = $string->substring($size);
        }

        return $stream;
    }
public function chunk ( int $ size = 1 ) : StreamInterface { $ stream = new Stream ( self :: class ) ; $ string = $ this ; while ( $ string -> length ( ) > 0 ) { $ stream = $ stream -> add ( $ string -> substring ( 0 , $ size ) ) ; $ string = $ string -> substring ( $ size ) ; } return $ stream ; }
Returns a collection of the string splitted by the given chunk size

@param int $size

@return StreamInterface<self>
Returns a collection of the string splitted by the given chunk size