public function ObjectProperty::extract in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-hydrator/src/ObjectProperty.php \Zend\Hydrator\ObjectProperty::extract()
Extracts the accessible non-static properties of the given $object.
Throws
Exception\BadMethodCallException for a non-object $object
Overrides ExtractionInterface::extract
File
- vendor/
zendframework/ zend-hydrator/ src/ ObjectProperty.php, line 29
Class
Namespace
Zend\HydratorCode
public function extract($object) {
if (!is_object($object)) {
throw new Exception\BadMethodCallException(sprintf('%s expects the provided $object to be a PHP object)', __METHOD__));
}
$data = get_object_vars($object);
$filter = $this
->getFilter();
foreach ($data as $name => $value) {
// Filter keys, removing any we don't want
if (!$filter
->filter($name)) {
unset($data[$name]);
continue;
}
// Replace name if extracted differ
$extracted = $this
->extractName($name, $object);
if ($extracted !== $name) {
unset($data[$name]);
$name = $extracted;
}
$data[$name] = $this
->extractValue($name, $value, $object);
}
return $data;
}