From 17d442738a7d9e4af087dcc6a0869f8a0edbfa8e Mon Sep 17 00:00:00 2001 From: Sven Buijsrogge Date: Thu, 13 Jul 2017 10:33:21 +0200 Subject: [PATCH] Fixed some CodeClimate issues --- src/Responses/TransactionResponse.php | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Responses/TransactionResponse.php b/src/Responses/TransactionResponse.php index d0be2ef..0605ed9 100644 --- a/src/Responses/TransactionResponse.php +++ b/src/Responses/TransactionResponse.php @@ -188,13 +188,13 @@ public function getRedirectUrl() */ public function getRequestedInformation() { - $aRequestedInformation = []; + $aInformation = []; if ($this->hasRequiredAction() && !is_null($this->aResponseData['RequiredAction']['RequestedInformation'])) { - $aRequestedInformation = $this->aResponseData['RequiredAction']['RequestedInformation']; + $aInformation = $this->aResponseData['RequiredAction']['RequestedInformation']; } - return $aRequestedInformation; + return $aInformation; } /** @@ -230,13 +230,7 @@ public function getRemainderAmount() */ public function getRemainderCurrency() { - $mCurrency = false; - - if ($this->hasToPayRemainder() && isset($this->aResponseData['RequiredAction']['PayRemainderDetails']['Currency'])) { - $mCurrency = $this->aResponseData['RequiredAction']['PayRemainderDetails']['Currency']; - } - - return $mCurrency; + return $this->getPayRemainderDetail('Currency'); } /** @@ -246,13 +240,25 @@ public function getRemainderCurrency() */ public function getRemainderGroupTransaction() { - $mGroupTransaction = false; + return $this->getPayRemainderDetail('GroupTransaction'); + } + + /** + * Get item out of the PayRemainderDetails array + * + * @param string $sDetailKey The key of the PayRemainderDetails item to retrieve + * + * @return bool + */ + protected function getPayRemainderDetail($sDetailKey) + { + $mValue = false; - if ($this->hasToPayRemainder() && isset($this->aResponseData['RequiredAction']['PayRemainderDetails']['GroupTransaction'])) { - $mGroupTransaction = $this->aResponseData['RequiredAction']['PayRemainderDetails']['GroupTransaction']; + if ($this->hasToPayRemainder() && isset($this->aResponseData['RequiredAction']['PayRemainderDetails'][$sDetailKey])) { + $mValue = $this->aResponseData['RequiredAction']['PayRemainderDetails'][$sDetailKey]; } - return $mGroupTransaction; + return $mValue; } /**