Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
zendframework/zendframework#6869 - minor CS fixes/spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Nov 29, 2014
1 parent d961e5e commit cf786b9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Hydrator/ObjectProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class ObjectProperty extends AbstractHydrator
{

/**
* @var array
*/
Expand All @@ -38,21 +37,24 @@ public function extract($object)
));
}

$data = get_object_vars($object);

$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)) {
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);
}

Expand All @@ -71,22 +73,26 @@ public function extract($object)
*/
public function hydrate(array $data, $object)
{
if (!is_object($object)) {
if (! is_object($object)) {
throw new Exception\BadMethodCallException(sprintf(
'%s expects the provided $object to be a PHP object)', __METHOD__
));
}

$prop = &$this->propertyFilterCache[get_class($object)];
$prop = & $this->propertyFilterCache[get_class($object)];

if (!isset($prop)) {
if (! isset($prop)) {
$reflectionObject = new ReflectionClass($object);
$prop = array_fill_keys(
array_map(
function ($property) {
return $property->name;
},
$reflectionObject->getProperties(ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PROTECTED + ReflectionProperty::IS_STATIC)
$reflectionObject->getProperties(
ReflectionProperty::IS_PRIVATE
+ ReflectionProperty::IS_PROTECTED
+ ReflectionProperty::IS_STATIC
)
),
true
);
Expand All @@ -101,6 +107,7 @@ function ($property) {

$object->$property = $this->hydrateValue($property, $value, $data);
}

return $object;
}
}

0 comments on commit cf786b9

Please sign in to comment.