Permalink
Browse files

is_callable instead of method_exists

  • Loading branch information...
1 parent c30bbd0 commit bd127e69912aaec657719b3506535dcd93e0926a @matteosister matteosister committed Apr 9, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 Transformer/ModelToElasticaAutoTransformer.php
@@ -42,12 +42,11 @@ public function __construct(array $options = array())
**/
public function transform($object, array $fields)
{
- $class = get_class($object);
$array = array();
foreach ($fields as $key) {
$getter = 'get'.ucfirst($key);
- if (!method_exists($class, $getter)) {
- throw new RuntimeException(sprintf('The getter %s::%s does not exist', $class, $getter));
+ if (!is_callable(array($object, $getter))) {
+ throw new RuntimeException(sprintf('The method %s::%s is not callable', get_class($object), $getter));
}
$array[$key] = $this->normalizeValue($object->$getter());
}

0 comments on commit bd127e6

Please sign in to comment.