src/DataListTrait.php
public function slice(int $offset, int $length = null)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['slice', $offset, $length];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $slice = array_slice($data, $offset, $length);
        $className = get_class($this);
        $list = new $className();
        foreach ($slice as $object) {
            $list->push($object);
        }
        return $list;
    }
public function slice(int $offset, int $length = null)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['slice', $offset, $length];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $slice = array_slice($data, $offset, $length);
        $className = get_class($this);
        $list = new $className();
        foreach ($slice as $object) {
            $list->push($object);
        }
        return $list;
    }
public function slice ( int $ offset , int $ length = null ) { $ actions = $ this -> internalDataListActions ; $ actions [ ] = [ 'slice' , $ offset , $ length ] ; $ data = $ this -> internalDataListUpdateData ( $ this -> internalDataListData , $ actions ) ; $ slice = array_slice ( $ data , $ offset , $ length ) ; $ className = get_class ( $ this ) ; $ list = new $ className ( ) ; foreach ( $ slice as $ object ) { $ list -> push ( $ object ) ; } return $ list ; }
Extract a slice of the list.

@param int $offset The index position where the extraction should begin
@param int $length The max length of the items in the extracted slice.
@return mixed Returns a slice of the list.
@throws \InvalidArgumentException
Extract a slice of the list .