<commit_before><?php
namespace Gencoding\Guzzle\Encoding\Common;

use Gencoding\Guzzle\Encoding\Common\Exception\EncodingXmlException;

/**
 * Encoding.com Response XML Class
 */
class EncodingResponse
{

    /**
     * The SimpleXMLElement Response Object
     *
     * @var SimpleXMLElement
     */
    protected $xmlElement;

    /**
     * Constructor.
     *
     * @param SimpleXMLElement $xmlResponse
     *            The XML response
     */
    public function __construct($xmlString)
    {
        try {
            $this->xmlElement = new \SimpleXMLElement($xmlString);
        } catch (\Exception $e) {
            throw new EncodingXmlException('Could not parse the XML response.');
        }
    }

    /**
     * Checks if the XML response contains an error
     *
     * @return boolean True if terror
     */
    public function hasError()
    {
        return isset($this->xmlElement->errors);
    }

    /**
     * Returns the error message
     *
     * @return string Error message
     */
    public function getErrorMessage()
    {
        $errorValue = null;
        if ($this->hasError()) {
            $errorValue = (string) $this->xmlElement->errors->error;
        }
        return $errorValue;
    }

    /**
     * XML Result as string
     */
    public function __toString()
    {
        return $this->xmlElement ? $this->xmlElement->saveXML() : "";
    }
}<commit_msg>Refactoring Response Class<commit_after><?php
namespace Gencoding\Guzzle\Encoding\Common;

use Gencoding\Guzzle\Encoding\Common\Exception\EncodingXmlException;

/**
 * Encoding.com Response XML Class
 */
class EncodingResponse
{

    /**
     * The SimpleXMLElement Response Object
     *
     * @var SimpleXMLElement
     */
    protected $xmlElement;

    /**
     * Constructor.
     *
     * @param SimpleXMLElement $xmlResponse
     *            The XML response
     */
    public function __construct($xmlString)
    {
        try {
            $this->xmlElement = new \SimpleXMLElement($xmlString);
        } catch (\Exception $e) {
            throw new EncodingXmlException('Could not parse the XML response.');
        }
    }

    /**
     * Checks if the XML response contains an error
     *
     * @return boolean True if terror
     */
    public function hasError()
    {
        return isset($this->xmlElement->errors);
    }

    /**
     *
     * @return \Gencoding\Guzzle\Encoding\Common\SimpleXMLElement
     */
    public function getXmlElement()
    {
        return $this->xmlElement;
    }

    /**
     * XML Result as string
     *
     * @return string
     */
    public function getXmlString()
    {
        return $this->xmlElement ? trim($this->xmlElement->saveXML()) : "";
    }

    /**
     * Returns the error message
     *
     * @return string Error message
     */
    public function getErrorMessage()
    {
        $errorValue = null;
        if ($this->hasError()) {
            $errorValue = (string) $this->xmlElement->errors->error;
        }
        return $errorValue;
    }

    /**
     * XML Result as string
     *
     * @return string
     */
    public function __toString()
    {
        return $this->getXmlString();
    }
}
{'fraction_non_alphanumeric': 0.11459968602825746, 'fraction_numerical': 0.0, 'mean_word_length': 1.9391143911439115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 19}, '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': '7657280', 'n_tokens_mistral': 900, 'n_tokens_neox': 887, 'n_words': 206}