Code Duplication    Length = 27-28 lines in 2 locations

Models/Adapters/PayInQuery.php 2 locations

@@ 46-72 (lines=27) @@
43
        $this->payInTranslator = $payInTranslator;
44
    }
45
46
    public function createPayInCardDirect(CardDirectPayIn $cardDirectPayIn) : CardDirectPayIn
47
    {
48
        try {
49
            $payIn = $this->payInTranslator->translateDtoToMangoPayInForDirectPayIn($cardDirectPayIn);
50
            $createdPayIn = $this->mangoPayApi->PayIns->Create($payIn);
51
52
            if ($createdPayIn instanceof PayIn) {
53
                if ($createdPayIn->Status == PayInStatus::Succeeded) {
54
                    return $this->payInTranslator->translateMangoPayDirectPayInToDto($createdPayIn);
55
                }
56
                $this->logger->addCritical(
57
                    "Pay-In has been created with status: ".$createdPayIn->Status . ' (result code: ' . $createdPayIn->ResultCode . ')'
58
                );
59
                throw new PartFireException(
60
                    "Pay-In has been created with status: ".$createdPayIn->Status . ' (result code: ' . $createdPayIn->ResultCode . ')'
61
                );
62
            }
63
            $this->logger->addCritical("Failed to create PayIn");
64
            throw new PartFireException("Failed to create PayIn");
65
        } catch (ResponseException $e) {
66
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
67
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
68
        } catch (Exception $e) {
69
            $this->logger->addError($e->getMessage());
70
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
71
        }
72
    }
73
74
    public function createBankWireDirectPayIn(BankwireDirectPayIn $bankwireDirectPayIn) : BankwireDirectPayIn
75
    {
@@ 74-101 (lines=28) @@
71
        }
72
    }
73
74
    public function createBankWireDirectPayIn(BankwireDirectPayIn $bankwireDirectPayIn) : BankwireDirectPayIn
75
    {
76
        try {
77
            $payIn = $this->payInTranslator->translateDtoToMangoPayInForBankwireDirectPayIn($bankwireDirectPayIn);
78
            $createdPayIn = $this->mangoPayApi->PayIns->Create($payIn);
79
80
            if ($createdPayIn instanceof PayIn) {
81
82
                if ($createdPayIn->Status == PayInStatus::Created) {
83
                    return $this->payInTranslator->translateMangoPayBankwireDirectPayInToDto($createdPayIn);
84
                }
85
                $this->logger->addCritical(
86
                    "Pay-In has been created with status: ".$createdPayIn->Status . ' (result code: ' . $createdPayIn->ResultCode . ')'
87
                );
88
                throw new PartFireException(
89
                    "Pay-In has been created with status: ".$createdPayIn->Status . ' (result code: ' . $createdPayIn->ResultCode . ')'
90
                );
91
            }
92
            $this->logger->addCritical("Failed to create PayIn");
93
            throw new PartFireException("Failed to create PayIn");
94
        } catch (ResponseException $e) {
95
            $this->logger->addCritical($e->getMessage(), ['code' => $e->getCode(), 'details' => $e->GetErrorDetails()]);
96
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
97
        } catch (Exception $e) {
98
            $this->logger->addError($e->getMessage());
99
            throw new PartFireException($e->getMessage(), $e->getCode(), $e);
100
        }
101
    }
102
}
103