src/Response/XML.php
private static function toStdClass(
        SimpleXMLElement $source,
        $isArray = false
    ) {
        $destination = $isArray ? [] : new stdClass();
        foreach ($source as $key=>$value) {
            $key = Str::camel($key);
            $attrs = $value->attributes();
            if (!empty($attrs->type)) {
                $type = (string) $attrs->type;
                switch ($type) {
                    case 'integer':
                        $destination->$key = (int) $value;
                        break;
                    case 'boolean':
                        $value = (string) $value;
                        $destination->$key = (bool) $value === 'true';
                        break;
                    case 'array':
                        if (is_array($destination)) {
                            $destination[$key] = self::toStdClass($value, true);
                        } else {
                            $destination->$key = self::toStdClass($value, true);
                        }
                        break;
                    default:
                        $destination->$key = (string) $value;
                        break;
                }
            } else {
                $children = $value->children();
                if (!empty($children)) {
                    if ($isArray) {
                        $i               = count($destination);
                        $destination[$i] = self::toStdClass($value);
                    } else {
                        $destination->$key = self::toStdClass($value);
                    }
                } else {
                    $destination->$key = (string) $value;
                }
            }
        }

        return $destination;
    }
private static function toStdClass(
        SimpleXMLElement $source,
        $isArray = false
    ) {
        $destination = $isArray ? [] : new stdClass();
        foreach ($source as $key=>$value) {
            $key = Str::camel($key);
            $attrs = $value->attributes();
            if (!empty($attrs->type)) {
                $type = (string) $attrs->type;
                switch ($type) {
                    case 'integer':
                        $destination->$key = (int) $value;
                        break;
                    case 'boolean':
                        $value = (string) $value;
                        $destination->$key = (bool) $value === 'true';
                        break;
                    case 'array':
                        if (is_array($destination)) {
                            $destination[$key] = self::toStdClass($value, true);
                        } else {
                            $destination->$key = self::toStdClass($value, true);
                        }
                        break;
                    default:
                        $destination->$key = (string) $value;
                        break;
                }
            } else {
                $children = $value->children();
                if (!empty($children)) {
                    if ($isArray) {
                        $i               = count($destination);
                        $destination[$i] = self::toStdClass($value);
                    } else {
                        $destination->$key = self::toStdClass($value);
                    }
                } else {
                    $destination->$key = (string) $value;
                }
            }
        }

        return $destination;
    }
private static function toStdClass ( SimpleXMLElement $ source , $ isArray = false ) { $ destination = $ isArray ? [ ] : new stdClass ( ) ; foreach ( $ source as $ key => $ value ) { $ key = Str :: camel ( $ key ) ; $ attrs = $ value -> attributes ( ) ; if ( ! empty ( $ attrs -> type ) ) { $ type = ( string ) $ attrs -> type ; switch ( $ type ) { case 'integer' : $ destination -> $ key = ( int ) $ value ; break ; case 'boolean' : $ value = ( string ) $ value ; $ destination -> $ key = ( bool ) $ value === 'true' ; break ; case 'array' : if ( is_array ( $ destination ) ) { $ destination [ $ key ] = self :: toStdClass ( $ value , true ) ; } else { $ destination -> $ key = self :: toStdClass ( $ value , true ) ; } break ; default : $ destination -> $ key = ( string ) $ value ; break ; } } else { $ children = $ value -> children ( ) ; if ( ! empty ( $ children ) ) { if ( $ isArray ) { $ i = count ( $ destination ) ; $ destination [ $ i ] = self :: toStdClass ( $ value ) ; } else { $ destination -> $ key = self :: toStdClass ( $ value ) ; } } else { $ destination -> $ key = ( string ) $ value ; } } } return $ destination ; }
Convierte un objecto SimpleXMLElement a stdClass

@param SimpleXMLElement $source
@param bool $isArray
@return stdClass
Convierte un objecto SimpleXMLElement a stdClass