PayPalModel to differentiate between empty objects and array

- Fixes to PayPalModel Conversion
- Fixes #262
This commit is contained in:
Jay Patel
2015-03-03 16:55:18 -06:00
parent 207c2c233e
commit fd6a38d0ef
5 changed files with 101 additions and 6 deletions

View File

@@ -60,6 +60,32 @@ class ReflectionUtil
}
}
/**
* Checks if the Property is of type array or an object
*
* @param $class
* @param $propertyName
* @return null|boolean
* @throws PayPalConfigurationException
*/
public static function isPropertyClassArray($class, $propertyName)
{
// If the class doesn't exist, or the method doesn't exist, return null.
if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) {
return null;
}
if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
$param = $annotations['return'];
}
if (isset($param)) {
return substr($param, -strlen('[]'))==='[]';
} else {
throw new PayPalConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type.");
}
}
/**
* Retrieves Annotations of each property
*