src/MediaServices/Internal/ContentPropertiesSerializer.php
private static function _serializeRecursive($object, \XMLWriter $xmlWriter)
    {
        Validate::notNull($object, 'object');

        $reflectionClass = new \ReflectionClass($object);
        $methodArray = $reflectionClass->getMethods();

        $result = [];
        foreach ($methodArray as $method) {
            if ((strpos($method->name, 'get') === 0)
                && $method->isPublic()
            ) {
                $variableName = substr($method->name, 3);
                $variableValue = $method->invoke($object);
                if (!empty($variableValue) || self::_isRequired($object, $variableName)) {
                    if (is_a($variableValue, '\DateTime')) {
                        $variableValue = $variableValue->format(\DateTime::ATOM);
                    }
                    if (is_a($variableValue, '\DateInterval')) {
                        $variableValue = self::dateIntervalToString($variableValue);
                    }
                    if (gettype($variableValue) == 'array') {
                        $xmlWriter->startElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE
                        );

                        foreach ($variableValue as $item) {
                            $xmlWriter->startElementNS(
                                'data',
                                Resources::ELEMENT,
                                Resources::DS_XML_NAMESPACE
                            );

                            self::_serializeRecursive(
                                $item,
                                $xmlWriter
                            );

                            $xmlWriter->endElement();
                        }

                        $xmlWriter->endElement();
                    } elseif (gettype($variableValue) == 'object') {
                        $xmlWriter->startElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE
                        );

                        self::_serializeRecursive(
                            $variableValue,
                            $xmlWriter
                        );

                        $xmlWriter->endElement();
                    } else {
                        $xmlWriter->writeElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE,
                            (string) $variableValue
                        );
                    }
                }
            }
        }

        return $result;
    }
private static function _serializeRecursive($object, \XMLWriter $xmlWriter)
    {
        Validate::notNull($object, 'object');

        $reflectionClass = new \ReflectionClass($object);
        $methodArray = $reflectionClass->getMethods();

        $result = [];
        foreach ($methodArray as $method) {
            if ((strpos($method->name, 'get') === 0)
                && $method->isPublic()
            ) {
                $variableName = substr($method->name, 3);
                $variableValue = $method->invoke($object);
                if (!empty($variableValue) || self::_isRequired($object, $variableName)) {
                    if (is_a($variableValue, '\DateTime')) {
                        $variableValue = $variableValue->format(\DateTime::ATOM);
                    }
                    if (is_a($variableValue, '\DateInterval')) {
                        $variableValue = self::dateIntervalToString($variableValue);
                    }
                    if (gettype($variableValue) == 'array') {
                        $xmlWriter->startElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE
                        );

                        foreach ($variableValue as $item) {
                            $xmlWriter->startElementNS(
                                'data',
                                Resources::ELEMENT,
                                Resources::DS_XML_NAMESPACE
                            );

                            self::_serializeRecursive(
                                $item,
                                $xmlWriter
                            );

                            $xmlWriter->endElement();
                        }

                        $xmlWriter->endElement();
                    } elseif (gettype($variableValue) == 'object') {
                        $xmlWriter->startElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE
                        );

                        self::_serializeRecursive(
                            $variableValue,
                            $xmlWriter
                        );

                        $xmlWriter->endElement();
                    } else {
                        $xmlWriter->writeElementNS(
                            'data',
                            $variableName,
                            Resources::DS_XML_NAMESPACE,
                            (string) $variableValue
                        );
                    }
                }
            }
        }

        return $result;
    }
private static function _serializeRecursive ( $ object , \ XMLWriter $ xmlWriter ) { Validate :: notNull ( $ object , 'object' ) ; $ reflectionClass = new \ ReflectionClass ( $ object ) ; $ methodArray = $ reflectionClass -> getMethods ( ) ; $ result = [ ] ; foreach ( $ methodArray as $ method ) { if ( ( strpos ( $ method -> name , 'get' ) === 0 ) && $ method -> isPublic ( ) ) { $ variableName = substr ( $ method -> name , 3 ) ; $ variableValue = $ method -> invoke ( $ object ) ; if ( ! empty ( $ variableValue ) || self :: _isRequired ( $ object , $ variableName ) ) { if ( is_a ( $ variableValue , '\DateTime' ) ) { $ variableValue = $ variableValue -> format ( \ DateTime :: ATOM ) ; } if ( is_a ( $ variableValue , '\DateInterval' ) ) { $ variableValue = self :: dateIntervalToString ( $ variableValue ) ; } if ( gettype ( $ variableValue ) == 'array' ) { $ xmlWriter -> startElementNS ( 'data' , $ variableName , Resources :: DS_XML_NAMESPACE ) ; foreach ( $ variableValue as $ item ) { $ xmlWriter -> startElementNS ( 'data' , Resources :: ELEMENT , Resources :: DS_XML_NAMESPACE ) ; self :: _serializeRecursive ( $ item , $ xmlWriter ) ; $ xmlWriter -> endElement ( ) ; } $ xmlWriter -> endElement ( ) ; } elseif ( gettype ( $ variableValue ) == 'object' ) { $ xmlWriter -> startElementNS ( 'data' , $ variableName , Resources :: DS_XML_NAMESPACE ) ; self :: _serializeRecursive ( $ variableValue , $ xmlWriter ) ; $ xmlWriter -> endElement ( ) ; } else { $ xmlWriter -> writeElementNS ( 'data' , $ variableName , Resources :: DS_XML_NAMESPACE , ( string ) $ variableValue ) ; } } } } return $ result ; }
Get object properties as array.

@param object     $object    Source object
@param \XMLWriter $xmlWriter Xml writer to use

@return array
Get object properties as array .