Code Duplication    Length = 17-20 lines in 2 locations

src/Callback/Xml.php 1 location

@@ 51-70 (lines=20) @@
48
     */
49
    protected $errorMessage;
50
51
    public function init()
52
    {
53
        $this->xml = $this->body['xml'];
54
        $this->xmlDoc = new \SimpleXMLElement($this->xml);
55
        $this->version = (string)$this->xmlDoc['version'];
56
        $this->date = \DateTimeImmutable::createFromFormat(DATE_RFC3339, (string)$this->xmlDoc->Header->Date);
57
        if ($this->date === false) {
58
            $exception = new XmlException('The date format is wrong in xml header');
59
            $exception->setXmlElement($this->xmlDoc);
60
            throw $exception;
61
        }
62
        $this->path = (string)$this->xmlDoc->Header->Path;
63
        $this->errorCode = (int)$this->xmlDoc->Header->ErrorCode;
64
        $this->errorMessage = (string)$this->xmlDoc->Header->ErrorMessage;
65
66
        /** @var \SimpleXMLElement $body */
67
        $body = $this->xmlDoc->Body;
68
69
        $this->hydrateTransactions($body);
70
    }
71
}
72

src/Response/Response.php 1 location

@@ 71-87 (lines=17) @@
68
     * @param PsrResponseInterface $response
69
     * @throws XmlException
70
     */
71
    public function __construct(PsrResponseInterface $response)
72
    {
73
        $this->response = $response;
74
        $this->xml = (string)$this->response->getBody();
75
        $this->xmlDoc = new \SimpleXMLElement($this->xml);
76
        $this->version = (string)$this->xmlDoc['version'];
77
        $this->date = \DateTimeImmutable::createFromFormat(DATE_RFC3339, (string)$this->xmlDoc->Header->Date);
78
        if ($this->date === false) {
79
            $exception = new XmlException('The date format is wrong in xml header');
80
            $exception->setXmlElement($this->xmlDoc);
81
            throw $exception;
82
        }
83
        $this->path = (string)$this->xmlDoc->Header->Path;
84
        $this->errorCode = (int)$this->xmlDoc->Header->ErrorCode;
85
        $this->errorMessage = (string)$this->xmlDoc->Header->ErrorMessage;
86
        $this->init();
87
    }
88
89
    /**
90
     * @return bool