<commit_before><?php

namespace Namecheap\Api;

/**
 * This class handles a namecheap API response
 *
 * @author <NAME> <<EMAIL>>
 */
class Response
{
    /**
     * @var string
     */
    private $raw;

    /**
     * @var \SimpleXMLElement
     */
    private $xml;

    public function __construct($response)
    {
        $this->raw = $response;
        
        try {
            $this->xml = new \SimpleXMLElement($this->raw);
        } catch (Exception $e) {
            echo $e;
        }
    }

    /**
     * Returns the response status (OK = success, ERROR = error, null = invalid responses)
     *
     * @return string NULL
     */
    public function getStatus()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return (string) $this->xml->attributes()->Status;
        }
        return null;
    }

    /**
     * Returns errors contained in the response
     *
     * @return string|array
     */
    public function getErrors()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return $this->toArray($this->xml->Errors);
        }
        
        return null;
    }

    /**
     * Returns warnings contained in the response
     *
     * @return array|NULL
     */
    public function getWarnings()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return $this->toArray($this->xml->Warnings);
        }
        return false;
    }
    
    /**
     * Returns the raw XML response
     * 
     * @return string
     */
    public function getRaw()
    {
        return $this->raw;
    }

    /**
     * Returns an array from a SimpleXmlElement
     * 
     * @param mixed $data
     * @return array 
     */
    public function toArray($data)
    {
        return json_decode(json_encode($data), true);
    }
}<commit_msg>added method to return the xml instance of SimpleXMLElement<commit_after><?php

namespace Namecheap\Api;

/**
 * This class handles a namecheap API response
 *
 * @author <NAME> <<EMAIL>>
 */
class Response
{
    /**
     * @var string
     */
    private $raw;

    /**
     * @var \SimpleXMLElement
     */
    private $xml;

    public function __construct($response)
    {
        $this->raw = $response;
        
        try {
            $this->xml = new \SimpleXMLElement($this->raw);
        } catch (Exception $e) {
            echo $e;
        }
    }

    /**
     * Returns the response status (OK = success, ERROR = error, null = invalid responses)
     *
     * @return string NULL
     */
    public function getStatus()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return (string) $this->xml->attributes()->Status;
        }
        return null;
    }

    /**
     * Returns errors contained in the response
     *
     * @return string|array
     */
    public function getErrors()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return $this->toArray($this->xml->Errors);
        }
        
        return null;
    }

    /**
     * Returns warnings contained in the response
     *
     * @return array|NULL
     */
    public function getWarnings()
    {
        if ($this->xml && $this->xml instanceof \SimpleXMLElement) {
            return $this->toArray($this->xml->Warnings);
        }
        return false;
    }
    
    /**
     * Returns the XML response
     * 
     * @return string
     */
    public function getXml()
    {
        return $this->xml;
    }
    
    /**
     * Returns the raw XML response
     * 
     * @return string
     */
    public function getRaw()
    {
        return $this->raw;
    }

    /**
     * Returns an array from a SimpleXmlElement
     * 
     * @param mixed $data
     * @return array 
     */
    public function toArray($data)
    {
        return json_decode(json_encode($data), true);
    }
}
{'fraction_non_alphanumeric': 0.1267605633802817, 'fraction_numerical': 0.0, 'mean_word_length': 1.664392905866303, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, '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': '6176475', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1123, 'n_words': 285}