src/GeneratorCollection.php
public function slice($offset, $length = null): CollectionInterface
    {
        if ($length < 0) {
            throw new InvalidArgumentException('Negative slice lengths are not supported');
        }

        $result = $this;
        if ($offset < 0) {
            $result = $this->take($offset);
        } elseif ($offset > 0) {
            $result = $this->offset($offset);
        }

        if ($length !== null) {
            $result = $result->take($length);
        }

        return $result;
    }
public function slice($offset, $length = null): CollectionInterface
    {
        if ($length < 0) {
            throw new InvalidArgumentException('Negative slice lengths are not supported');
        }

        $result = $this;
        if ($offset < 0) {
            $result = $this->take($offset);
        } elseif ($offset > 0) {
            $result = $this->offset($offset);
        }

        if ($length !== null) {
            $result = $result->take($length);
        }

        return $result;
    }
public function slice ( $ offset , $ length = null ) : CollectionInterface { if ( $ length < 0 ) { throw new InvalidArgumentException ( 'Negative slice lengths are not supported' ) ; } $ result = $ this ; if ( $ offset < 0 ) { $ result = $ this -> take ( $ offset ) ; } elseif ( $ offset > 0 ) { $ result = $ this -> offset ( $ offset ) ; } if ( $ length !== null ) { $ result = $ result -> take ( $ length ) ; } return $ result ; }
Slice the underlying collection array.

@param  int $offset
@param  int $length
@return CollectionInterface
@throws \InvalidArgumentException
Slice the underlying collection array .