Skip to content

Commit

Permalink
Remove elseif
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed May 20, 2014
1 parent b3a603e commit 16b70e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getNamingStrategy()
*/
public function extractValue($property, $value, ExtractionContext $context = null)
{
// Optimization: avoid a method call, please do not change
// Optimization: avoid a method call by inlining, please do not change
if (isset($this->strategies[$property]) || isset($this->strategies['*'])) {
return $this->getStrategy($property)->extract($value, $context);
}
Expand All @@ -178,7 +178,7 @@ public function extractValue($property, $value, ExtractionContext $context = nul
*/
public function hydrateValue($property, $value, HydrationContext $context = null)
{
// Optimization: avoid a method call, please do not change
// Optimization: avoid a method call by inlining, please do not change
if (isset($this->strategies[$property]) || isset($this->strategies['*'])) {
return $this->getStrategy($property)->hydrate($value, $context);
}
Expand Down
18 changes: 11 additions & 7 deletions src/Hydrator/ArraySerializableHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ public function hydrate(array $data, $object)

if (is_callable([$object, 'exchangeArray'])) {
$object->exchangeArray($replacement);
} elseif (is_callable([$object, 'populate'])) {

return $object;
}

if (is_callable([$object, 'populate'])) {
$object->populate($replacement);
} else {
throw new Exception\BadMethodCallException(sprintf(
'%s expects the provided object to implement exchangeArray() or populate()',
__METHOD__
));

return $object;
}

return $object;
throw new Exception\BadMethodCallException(sprintf(
'%s expects the provided object to implement exchangeArray() or populate()',
__METHOD__
));
}
}

0 comments on commit 16b70e8

Please sign in to comment.