<commit_before><?php
/**
 * PHPFrame/Document/XMLDocument.php
 * 
 * PHP version 5
 * 
 * @category  PHPFrame
 * @package   Document
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 The PHPFrame Group
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @version   SVN: $Id$
 * @link      http://code.google.com/p/phpframe/source/browse/PHPFrame
 */

/**
 * XML Document Class
 * 
 * @category PHPFrame
 * @package  Document
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @link     http://code.google.com/p/phpframe/source/browse/PHPFrame
 * @since    1.0
 */
class PHPFrame_XMLDocument extends PHPFrame_Document
{
    /**
     * DOM Document Type object
     * 
     * @var DOMDocumentType
     */
    protected $doctype = null;
    /**
     * DOM Document object
     * 
     * @var DOMDocument
     */
    protected $dom = null;
    
    /**
     * Constructor
     * 
     * @return void
     * @uses   DOMImplementation
     * @since  1.0 
     */
    public function __construct($mime="text/xml", $charset=null) 
    {
        // Call parent's constructor to set mime type
        parent::__construct($mime, $charset);
        
        // Acquire DOM object of HTML type
        $this->dom = new DOMDocument("1.0", $this->getCharset()); 
    }
    
    /**
     * Covert object to string
     * 
     * @return string
     * @since  1.0
     */
    public function __toString()
    {
        $str            = $this->dom->saveXML();
        $str           .= $this->getBody();
        
        $xml_beautifier = new XML_Beautifier();
        return $xml_beautifier->formatString($str);
        //return $this->indent($this->dom->saveXML().$this->getBody());
    }
    
    public function getDOM()
    {<commit_msg>Changed XMLDocument clas to make the beautifier optional.<commit_after><?php
/**
 * PHPFrame/Document/XMLDocument.php
 * 
 * PHP version 5
 * 
 * @category  PHPFrame
 * @package   Document
 * @author    <NAME> <<EMAIL>>
 * @copyright 2009 The PHPFrame Group
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @version   SVN: $Id$
 * @link      http://code.google.com/p/phpframe/source/browse/PHPFrame
 */

/**
 * XML Document Class
 * 
 * @category PHPFrame
 * @package  Document
 * @author   <NAME> <<EMAIL>>
 * @license  http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @link     http://code.google.com/p/phpframe/source/browse/PHPFrame
 * @since    1.0
 */
class PHPFrame_XMLDocument extends PHPFrame_Document
{
    /**
     * DOM Document Type object
     * 
     * @var DOMDocumentType
     */
    protected $doctype = null;
    /**
     * DOM Document object
     * 
     * @var DOMDocument
     */
    protected $dom = null;
    /**
     * A boolean indicating whether or not to use the XML beautifier when 
     * converting to string.
     * 
     * @var bool
     */
    private $_use_beautifier=true;
    
    /**
     * Constructor
     * 
     * @return void
     * @uses   DOMImplementation
     * @since  1.0 
     */
    public function __construct($mime="text/xml", $charset=null) 
    {
        // Call parent's constructor to set mime type
        parent::__construct($mime, $charset);
        
        // Acquire DOM object of HTML type
        $this->dom = new DOMDocument("1.0", $this->getCharset()); 
    }
    
    /**
     * Covert object to string
     * 
     * @return string
     * @since  1.0
     */
    public function __toString()
    {
        $str  = $this->dom->saveXML();
        $str .= $this->getBody();
        
        if ($this->useBeautifier()) {
            $xml_beautifier = new XML_Beautifier();
            return $xml_beautifier->formatString($str);
        }
        
        return $str;
    }
    
    /**
     * Set whether or not to use the XML beautifier when converting to string.
     * 
     * @param bool $bool [Optional] Boolean indicating whether or not to use 
     *                   the beautifier. If not passed this method simply 
     *                   returns the current value.
     * 
     * @return bool
     * @since  1.0
     */
    public function useBeautifier($bool=null)
    {
    	if (!is_null($bool)) {
    	    $this->_use_beautifier = (bool) $bool;
    	}
    	
    	return $this->_use_beautifier;
    }
    
    public function getDOM()
    {
{'fraction_non_alphanumeric': 0.12821095703568994, 'fraction_numerical': 0.006365082973403046, 'mean_word_length': 1.979011509817197, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '655947', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1338, 'n_words': 322}