Code Duplication    Length = 17-20 lines in 2 locations

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

src/Callback/Xml.php 1 location

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