Code Duplication    Length = 10-11 lines in 4 locations

src/Amadeus/Client/ResponseHandler/FOP/HandlerCreateFormOfPayment.php 4 locations

@@ 72-81 (lines=10) @@
69
        //General error level in the transmissionError location:
70
        $errorCodeNodeList = $domXpath->query(self::Q_G_ERR);
71
72
        if ($errorCodeNodeList->length > 0) {
73
            $errorCatNode = $domXpath->query(self::Q_G_CAT)->item(0);
74
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
75
76
            $code = $errorCodeNodeList->item(0)->nodeValue;
77
            $errorTextNodeList = $domXpath->query(self::Q_G_MSG);
78
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
79
80
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general');
81
        }
82
83
        //FP level errors via the fopDescription/fpElementError data:
84
        $errorCodeNodeList = $domXpath->query(self::Q_F_ERR);
@@ 86-95 (lines=10) @@
83
        //FP level errors via the fopDescription/fpElementError data:
84
        $errorCodeNodeList = $domXpath->query(self::Q_F_ERR);
85
86
        if ($errorCodeNodeList->length > 0) {
87
            $errorCatNode = $domXpath->query(self::Q_F_CAT)->item(0);
88
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
89
90
            $code = $errorCodeNodeList->item(0)->nodeValue;
91
            $errorTextNodeList = $domXpath->query(self::Q_F_MSG);
92
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
93
94
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'fp');
95
        }
96
97
        //Deficient FOP level errors:
98
        $errorCodeNodeList = $domXpath->query(self::Q_D_ERR);
@@ 100-110 (lines=11) @@
97
        //Deficient FOP level errors:
98
        $errorCodeNodeList = $domXpath->query(self::Q_D_ERR);
99
100
        if ($errorCodeNodeList->length > 0) {
101
            $errorCatNode = $domXpath->query(self::Q_D_CAT)->item(0);
102
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
103
104
            $code = $errorCodeNodeList->item(0)->nodeValue;
105
106
            $errorTextNodeList = $domXpath->query(self::Q_D_MSG);
107
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
108
109
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'deficient_fop');
110
        }
111
112
        //authorization failure:
113
        $errorCodeNodeList = $domXpath->query(self::Q_A_ERR);
@@ 115-125 (lines=11) @@
112
        //authorization failure:
113
        $errorCodeNodeList = $domXpath->query(self::Q_A_ERR);
114
115
        if ($errorCodeNodeList->length > 0) {
116
            $errorCatNode = $domXpath->query(self::Q_A_CAT)->item(0);
117
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
118
119
            $code = $errorCodeNodeList->item(0)->nodeValue;
120
121
            $errorTextNodeList = $domXpath->query(self::Q_A_MSG);
122
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
123
124
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'authorization_failure');
125
        }
126
127
        return $analyzeResponse;
128
    }