From bd127e69912aaec657719b3506535dcd93e0926a Mon Sep 17 00:00:00 2001 From: matteosister Date: Mon, 9 Apr 2012 18:14:45 +0200 Subject: [PATCH] is_callable instead of method_exists --- Transformer/ModelToElasticaAutoTransformer.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Transformer/ModelToElasticaAutoTransformer.php b/Transformer/ModelToElasticaAutoTransformer.php index 62170cd..2fa0b5d 100644 --- a/Transformer/ModelToElasticaAutoTransformer.php +++ b/Transformer/ModelToElasticaAutoTransformer.php @@ -42,12 +42,11 @@ class ModelToElasticaAutoTransformer implements ModelToElasticaTransformerInterf **/ 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()); }