<commit_before><?php
/**
 * Created by <NAME>.
 * User: sinan
 * Date: 31/05/14
 * Time: 21:28.
 */

namespace SanalPos\Garanti;

use SanalPos\SanalPosResponseInterface;
use SimpleXMLElement;

class SanalPosReponseGaranti implements SanalPosResponseInterface
{
    protected $response;
    protected $xml;

    public function __construct($response)
    {
        $this->response = $response;
        $this->xml = new SimpleXMLElement($response);
    }

    public function success()
    {
        // if response code === '00'
        // then the transaction is approved
        // if code is anything other than '00' that means there's an error
        if ($this->xml->Transaction->Response->Code[0]) {
            $code = $this->xml->Transaction->Response->Code[0];
        } else {
            $code = $this->xml->Transaction->Response->Code;
        }

        return (string) $code === '00';
    }

    public function errors()
    {
        if ($this->success()) {
            return [];
        }
        if ($this->xml->Transaction->Response->SysErrMsg) {
            return $this->xml->Transaction->Response->SysErrMsg;
        } else {
            return $this->xml->Transaction->Response->ErrorMsg;
        }
    }

    public function response()
    {
        return $this->response;
    }
}<commit_msg>garanti response update<commit_after><?php
/**
 * Created by <NAME>.
 * User: sinan
 * Date: 31/05/14
 * Time: 21:28.
 */

namespace SanalPos\Garanti;

use SanalPos\SanalPosResponseInterface;
use SimpleXMLElement;

class SanalPosReponseGaranti implements SanalPosResponseInterface
{
    protected $response;
    protected $xml;

    public function __construct($response)
    {
        $this->response = $response;
        $this->xml = new SimpleXMLElement($response);
    }

    public function success()
    {
        // if response code === '00'
        // then the transaction is approved
        // if code is anything other than '00' that means there's an error
        if ($this->xml->Transaction->Response->Code[0]) {
            $code = $this->xml->Transaction->Response->Code[0];
        } else {
            $code = $this->xml->Transaction->Response->Code;
        }

        return (string) $code === '00';
    }

    public function errors()
    {
        if ($this->success()) {
            return [];
        }
        if (@$this->xml->Transaction->Response->ErrorMsg) {
            return $this->xml->Transaction->Response->ErrorMsg;
        } else {
            return @$this->xml->Transaction->Response->SysErrMsg;
        }
    }

    public function response()
    {
        return $this->response;
    }
}
{'fraction_non_alphanumeric': 0.13934115865202576, 'fraction_numerical': 0.013631200302915562, 'mean_word_length': 2.2024242424242426, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '7051590', 'n_tokens_mistral': 779, 'n_tokens_neox': 745, 'n_words': 172}