src/Response/XML.php
public function parse($data, array $headers)
    {
        libxml_use_internal_errors(true);
        $this->string = $data;
        $source = simplexml_load_string($data);
        $errors = $this->getXmlErrors($source);
        if ($source) {
            if ($headers['Status'] === 201 || $headers['Status'] === 200) {
                switch ($headers['Method']) {
                    case 'UPLOAD':
                        if (!empty($source->ref)) {
                            return (string) $source->ref;
                        }
                        break;
                    case 'POST':
                        if (!empty($headers['id'])) {
                            return $headers['id'];
                        } else {
                            $property = 0;
                            $value = (int) $source->$property;
                            // this case the fileid
                            if ($value > 0) {
                                return $value;
                            }
                        }
                        break;
                     case 'PUT':
                     case 'DELETE':
                        return true;
                     default:
                        if (!empty($source->files->file)) {
                            $source = $source->files->file;
                            $isArray = true;
                        } elseif (!empty($source->notebooks->notebook)) {
                            $source = $source->notebooks->notebook;
                            $isArray = true;
                        } elseif (!empty($source->project->links)) {
                            $source = $source->project->links;
                            $isArray = true;
                        } else {
                            $attrs = $source->attributes();
                            $isArray = !empty($attrs->type) &&
                                            (string) $attrs->type === 'array';
                        }
                        $this->headers = $headers;

                        $_this = self::toStdClass($source, $isArray);

                        foreach ($_this as $key=>$value) {
                            $this->$key = $value;
                        }
                        return $this;
                }
            } else {
                if (!empty($source->error)) {
                    foreach ($source as $error) {
                        $errors .= $error ."\n";
                    }
                } else {
                    $property = 0;
                    $errors .= $source->$property;
                }
            }
        }
        throw new Exception([
            'Message'=> $errors,
            'Response'=> $data,
            'Headers'=> $headers
        ]);
    }
public function parse($data, array $headers)
    {
        libxml_use_internal_errors(true);
        $this->string = $data;
        $source = simplexml_load_string($data);
        $errors = $this->getXmlErrors($source);
        if ($source) {
            if ($headers['Status'] === 201 || $headers['Status'] === 200) {
                switch ($headers['Method']) {
                    case 'UPLOAD':
                        if (!empty($source->ref)) {
                            return (string) $source->ref;
                        }
                        break;
                    case 'POST':
                        if (!empty($headers['id'])) {
                            return $headers['id'];
                        } else {
                            $property = 0;
                            $value = (int) $source->$property;
                            // this case the fileid
                            if ($value > 0) {
                                return $value;
                            }
                        }
                        break;
                     case 'PUT':
                     case 'DELETE':
                        return true;
                     default:
                        if (!empty($source->files->file)) {
                            $source = $source->files->file;
                            $isArray = true;
                        } elseif (!empty($source->notebooks->notebook)) {
                            $source = $source->notebooks->notebook;
                            $isArray = true;
                        } elseif (!empty($source->project->links)) {
                            $source = $source->project->links;
                            $isArray = true;
                        } else {
                            $attrs = $source->attributes();
                            $isArray = !empty($attrs->type) &&
                                            (string) $attrs->type === 'array';
                        }
                        $this->headers = $headers;

                        $_this = self::toStdClass($source, $isArray);

                        foreach ($_this as $key=>$value) {
                            $this->$key = $value;
                        }
                        return $this;
                }
            } else {
                if (!empty($source->error)) {
                    foreach ($source as $error) {
                        $errors .= $error ."\n";
                    }
                } else {
                    $property = 0;
                    $errors .= $source->$property;
                }
            }
        }
        throw new Exception([
            'Message'=> $errors,
            'Response'=> $data,
            'Headers'=> $headers
        ]);
    }
public function parse ( $ data , array $ headers ) { libxml_use_internal_errors ( true ) ; $ this -> string = $ data ; $ source = simplexml_load_string ( $ data ) ; $ errors = $ this -> getXmlErrors ( $ source ) ; if ( $ source ) { if ( $ headers [ 'Status' ] === 201 || $ headers [ 'Status' ] === 200 ) { switch ( $ headers [ 'Method' ] ) { case 'UPLOAD' : if ( ! empty ( $ source -> ref ) ) { return ( string ) $ source -> ref ; } break ; case 'POST' : if ( ! empty ( $ headers [ 'id' ] ) ) { return $ headers [ 'id' ] ; } else { $ property = 0 ; $ value = ( int ) $ source -> $ property ; // this case the fileid if ( $ value > 0 ) { return $ value ; } } break ; case 'PUT' : case 'DELETE' : return true ; default : if ( ! empty ( $ source -> files -> file ) ) { $ source = $ source -> files -> file ; $ isArray = true ; } elseif ( ! empty ( $ source -> notebooks -> notebook ) ) { $ source = $ source -> notebooks -> notebook ; $ isArray = true ; } elseif ( ! empty ( $ source -> project -> links ) ) { $ source = $ source -> project -> links ; $ isArray = true ; } else { $ attrs = $ source -> attributes ( ) ; $ isArray = ! empty ( $ attrs -> type ) && ( string ) $ attrs -> type === 'array' ; } $ this -> headers = $ headers ; $ _this = self :: toStdClass ( $ source , $ isArray ) ; foreach ( $ _this as $ key => $ value ) { $ this -> $ key = $ value ; } return $ this ; } } else { if ( ! empty ( $ source -> error ) ) { foreach ( $ source as $ error ) { $ errors .= $ error . "\n" ; } } else { $ property = 0 ; $ errors .= $ source -> $ property ; } } } throw new Exception ( [ 'Message' => $ errors , 'Response' => $ data , 'Headers' => $ headers ] ) ; }
Parsea un string type xml

@param string $data
@param type $headers
@return mixed [bool, int, TeamWorkPm\Response\XML]
@throws \TeamWorkPm\Exception
Parsea un string type xml