/** * {@inheritDoc} */ public function extract($value) { if (!$this->isValidData($value)) { throw new InvalidValueException('Invalid data to extract. Array and Traversable objects allowed'); } $collection = array(); foreach ($value as $entry) { $collection[] = $this->type->extract($entry); } return $collection; }
/** * {@inheritDoc} */ public function extract($value) { if (!$this->isTargetType($value)) { $msg = vsprintf('Invalid data to extract. Only %s', array($this->getTypeCheck()->getTypeDescription())); throw new InvalidValueException($msg); } /* @var MapInterface $value */ $value->rewind(); $result = array(); while ($value->valid()) { $entryKey = $value->key(); $entryValue = $value->current(); if ($value->isUsingMapEntries()) { /* @var MapEntry $entryValue */ list($entryKey, $entryValue) = $entryValue->get(); } $result[] = array('key' => $this->keyType->extract($entryKey), 'value' => $this->valueType->extract($entryValue)); $value->next(); } return $result; }
/** * {@inheritDoc} */ public function extract($value) { if ($value === null) { if ($this->isNullable) { return null; } if ($this->hasDefaultValue) { return $this->type->extract($this->defaultValue); } } return $this->type->extract($value); }