public static function getFieldValue(PageInterface $object, $fieldName, $method = null)
{
$getters = array();
// prefer method name given in the code option
if ($method) {
$getters[] = $method;
}
$camelizedFieldName = self::camelize($fieldName);
$getters[] = 'get' . $camelizedFieldName;
$getters[] = 'is' . $camelizedFieldName;
foreach ($getters as $getter) {
if (method_exists($object, $getter)) {
return call_user_func(array($object, $getter));
}
}
throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $camelizedFieldName));
}