<commit_before><?php

namespace arc\xml;

class Parser
{

    public $namespaces = array();

    public function __construct( $options = array() )
    {
        $optionList = array( 'namespaces' );
        foreach( $options as $option => $optionValue) {
            if (in_array( $option, $optionList )) {
                $this->{$option} = $optionValue;
            }
        }
    }

    public function parse( $xml, $encoding = null )
    {
        if (!$xml) {
            return Proxy( null );
        }
        if ($xml instanceof Proxy) { // already parsed
            return $xml;
        }
        $xml = (string) $xml;
        try {
            return $this->parseFull( $xml, $encoding );<commit_msg>return a clone of the Proxy if a Proxy is given as the XML to parse.<commit_after><?php

namespace arc\xml;

class Parser
{

    public $namespaces = array();

    public function __construct( $options = array() )
    {
        $optionList = array( 'namespaces' );
        foreach( $options as $option => $optionValue) {
            if (in_array( $option, $optionList )) {
                $this->{$option} = $optionValue;
            }
        }
    }

    /**
     * Parses an XML string and returns a Proxy for it.
     * @param string|Proxy|null $xml
     * @param string $encoding The character set to use, defaults to UTF-8
     * @return Proxy
     */
    public function parse( $xml=null, $encoding = null )
    {
        if (!$xml) {
            return Proxy( null );
        }
        if ($xml instanceof Proxy) { // already parsed
            return $xml->cloneNode();
        }
        $xml = (string) $xml;
        try {
            return $this->parseFull( $xml, $encoding );
{'fraction_non_alphanumeric': 0.12779740871613662, 'fraction_numerical': 0.0005889281507656066, 'mean_word_length': 1.799011532125206, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 17}, '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': '188872', 'n_tokens_mistral': 494, 'n_tokens_neox': 488, 'n_words': 149}