public function save($path, $format = Document::XML)
    {
        switch ($format) {
            case Document::XML:
                $format = 'saveXML';
                break;
            case Document::HTML:
                $format = 'saveHTML';
                break;
            case Document::JSON:
                $format = 'toJson';
                break;
            default:
                throw new DomException('Invalid format', 2);
        }

        $tmp = Storage::temp($this->$format(), 'tmp', '~xml-');

        if ($tmp === false) {
            throw new DomException('Can\'t create tmp file', 2);
        } elseif (copy($tmp, $path) === false) {
            throw new DomException('Can\'t copy tmp file to ' . $path, 2);
        } else {
            unlink($tmp);
        }
    }
public function save($path, $format = Document::XML)
    {
        switch ($format) {
            case Document::XML:
                $format = 'saveXML';
                break;
            case Document::HTML:
                $format = 'saveHTML';
                break;
            case Document::JSON:
                $format = 'toJson';
                break;
            default:
                throw new DomException('Invalid format', 2);
        }

        $tmp = Storage::temp($this->$format(), 'tmp', '~xml-');

        if ($tmp === false) {
            throw new DomException('Can\'t create tmp file', 2);
        } elseif (copy($tmp, $path) === false) {
            throw new DomException('Can\'t copy tmp file to ' . $path, 2);
        } else {
            unlink($tmp);
        }
    }
public function save ( $ path , $ format = Document :: XML ) { switch ( $ format ) { case Document :: XML : $ format = 'saveXML' ; break ; case Document :: HTML : $ format = 'saveHTML' ; break ; case Document :: JSON : $ format = 'toJson' ; break ; default : throw new DomException ( 'Invalid format' , 2 ) ; } $ tmp = Storage :: temp ( $ this -> $ format ( ) , 'tmp' , '~xml-' ) ; if ( $ tmp === false ) { throw new DomException ( 'Can\'t create tmp file' , 2 ) ; } elseif ( copy ( $ tmp , $ path ) === false ) { throw new DomException ( 'Can\'t copy tmp file to ' . $ path , 2 ) ; } else { unlink ( $ tmp ) ; } }
Save file to location

@param string $path
@param int    $format Support XML, HTML, and JSON
@throws \Inphinit\Experimental\Exception
@return void
Save file to location