/** * @return array */ public function extract() { // In this specific situation, object holds the data, that is too say an array if (!is_array($this->object)) { return array(); } $values = array(); foreach ($this->object as $key => $value) { if ($value instanceof $this->targetElement->object) { $this->targetElement->object = $value; $values[$key] = $this->targetElement->extract(); } } return $values; }
/** * @return array */ public function extract() { if ($this->object instanceof Traversable) { $this->object = ArrayUtils::iteratorToArray($this->object); } if (!is_array($this->object)) { return array(); } $values = array(); foreach ($this->object as $key => $value) { if ($this->hydrator) { $values[$key] = $this->hydrator->extract($value); } elseif ($value instanceof $this->targetElement->object) { $this->targetElement->object = $value; $values[$key] = $this->targetElement->extract(); } } return $values; }