/** * @param enum $key * @return array */ public function slice($key) { if ($this->Object->has($key)) { $start = $this->LastIndex == 0 ? $this->LastIndex : $this->LastIndex + 1; return array_slice($this->Object->get($key), $start, $this->Index - $start + 1); } return array(); }
/** * Slice object based on last/current index * @return \Runalyze\Model\Entity * @throws \RuntimeException */ public function sliceObject() { if ($this->Object instanceof Runalyze\Model\Entity) { throw new \RuntimeException('This object cannot be sliced.'); } $data = array(); foreach ($this->Object->properties() as $key) { if ($this->Object->isArray($key)) { $data[$key] = $this->slice($key); } } return $this->createNewObject($data); }