src/Utility/ReflectionUtil.php
public static function constructObjectFromWebhooksArray($array, $arrayContainerClassName)
    {
        $clazz = ReflectionUtil::isValidWebhooksClass($arrayContainerClassName);
        if (!isset($clazz)) {
            return null;
        }
        $wrapObject = new $clazz();

        if (isset($array) && !empty($array)) {
            foreach ($array  as $key => $value) {
                if (is_array($value)) {
                    //Case 1: key is string, value is array and it is not associate Array
                    //create an array holder, loop through each element in the value, convert the array and put it
                    //in the list
                    if (!ArrayUtil::isAssociateArray($value)) {
                        $list = array();
                        foreach ($value as $index => $element) {
                            $obj = ReflectionUtil::constructObjectFromWebhooksArray($element, $key);
                            array_push($list, $obj);
                        }
                        ReflectionUtil::assignValue($wrapObject, $key, $list);
                    }
                    //Case 2: key is string, value is array and also it is associate array
                    //we then just pass the array to next recursive call
                    else {
                        $obj = ReflectionUtil::constructObjectFromWebhooksArray($value, $key);

                        ReflectionUtil::assignValue($wrapObject, $key, $obj);
                    }
                }
                //Case 3: key is string and value is String. Call the setter method for the key.
                else {
                    ReflectionUtil::assignValue($wrapObject, $key, $value);
                }
            }
        }

        return $wrapObject;
    }
public static function constructObjectFromWebhooksArray($array, $arrayContainerClassName)
    {
        $clazz = ReflectionUtil::isValidWebhooksClass($arrayContainerClassName);
        if (!isset($clazz)) {
            return null;
        }
        $wrapObject = new $clazz();

        if (isset($array) && !empty($array)) {
            foreach ($array  as $key => $value) {
                if (is_array($value)) {
                    //Case 1: key is string, value is array and it is not associate Array
                    //create an array holder, loop through each element in the value, convert the array and put it
                    //in the list
                    if (!ArrayUtil::isAssociateArray($value)) {
                        $list = array();
                        foreach ($value as $index => $element) {
                            $obj = ReflectionUtil::constructObjectFromWebhooksArray($element, $key);
                            array_push($list, $obj);
                        }
                        ReflectionUtil::assignValue($wrapObject, $key, $list);
                    }
                    //Case 2: key is string, value is array and also it is associate array
                    //we then just pass the array to next recursive call
                    else {
                        $obj = ReflectionUtil::constructObjectFromWebhooksArray($value, $key);

                        ReflectionUtil::assignValue($wrapObject, $key, $obj);
                    }
                }
                //Case 3: key is string and value is String. Call the setter method for the key.
                else {
                    ReflectionUtil::assignValue($wrapObject, $key, $value);
                }
            }
        }

        return $wrapObject;
    }
Pre-assumption: the input array must be a map at the beginning, no matter it is at beginning or at a recursive call. Otherwise, the reflection class won't know
what the object name is for the list.

@param $array
The object in array format
@param $arrayContainerClassName
The class that contains the array
@param null $classCollection
A user defined class collection. Default is null and default use all WebhooksService classes
@return null