public static function ensureAssociativeArray($object)
    {
        if (!is_object($object) && !is_array($object)) {
            return $object;
        }
        
        $data = (array)$object;
        foreach ($data as $key => $value) { // convert object to associative array
            $data[$key] = self::ensureAssociativeArray($value);
        }
        
        return $data;
    }