src/DataListTrait.php
public function sliceProperties(array $properties)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['sliceProperties', $properties];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $className = get_class($this);
        $list = new $className();
        $class = $this->internalDataListClasses['IvoPetkov\DataListObject'];
        $tempObject = new $class();
        foreach ($data as $index => $object) {
            $object = $this->internalDataListUpdateValueIfNeeded($data, $index);
            $newObject = clone($tempObject);
            foreach ($properties as $property) {
                $newObject[$property] = isset($object->$property) ? $object->$property : null;
            }
            $list->push($newObject);
        }
        return $list;
    }
public function sliceProperties(array $properties)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['sliceProperties', $properties];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $className = get_class($this);
        $list = new $className();
        $class = $this->internalDataListClasses['IvoPetkov\DataListObject'];
        $tempObject = new $class();
        foreach ($data as $index => $object) {
            $object = $this->internalDataListUpdateValueIfNeeded($data, $index);
            $newObject = clone($tempObject);
            foreach ($properties as $property) {
                $newObject[$property] = isset($object->$property) ? $object->$property : null;
            }
            $list->push($newObject);
        }
        return $list;
    }
public function sliceProperties ( array $ properties ) { $ actions = $ this -> internalDataListActions ; $ actions [ ] = [ 'sliceProperties' , $ properties ] ; $ data = $ this -> internalDataListUpdateData ( $ this -> internalDataListData , $ actions ) ; $ className = get_class ( $ this ) ; $ list = new $ className ( ) ; $ class = $ this -> internalDataListClasses [ 'IvoPetkov\DataListObject' ] ; $ tempObject = new $ class ( ) ; foreach ( $ data as $ index => $ object ) { $ object = $ this -> internalDataListUpdateValueIfNeeded ( $ data , $ index ) ; $ newObject = clone ( $ tempObject ) ; foreach ( $ properties as $ property ) { $ newObject [ $ property ] = isset ( $ object -> $ property ) ? $ object -> $ property : null ; } $ list -> push ( $ newObject ) ; } return $ list ; }
Returns a new list of object that contain only the specified properties of the objects in the current list.

@param array $properties The list of property names.
@return mixed Returns a new list.
Returns a new list of object that contain only the specified properties of the objects in the current list .