Skip to content

Commit

Permalink
fix phpMD
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Apr 4, 2024
1 parent 6cafb57 commit 46f4a20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/Controller/DispatcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
use JsonException;
use OxidEsales\Eshop\Application\Controller\FrontendController;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\Counter;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Field;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;
use OxidSolutionCatalysts\Unzer\Model\TmpOrder;
Expand All @@ -27,6 +25,10 @@
use UnzerSDK\Exceptions\UnzerApiException;
use UnzerSDK\Resources\Payment;

/**
* TODO: Decrease count of dependencies to 13
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class DispatcherController extends FrontendController
{
use ServiceContainer;
Expand Down Expand Up @@ -158,6 +160,7 @@ public function updatePaymentTransStatus(): void
* @param bool $error
* @return void
* @throws Exception
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
protected function handleTmpOrder(Payment $unzerPayment, TmpOrder $tmpOrder, array $tmpData, bool $error = false): void
{
Expand All @@ -183,13 +186,13 @@ protected function handleTmpOrder(Payment $unzerPayment, TmpOrder $tmpOrder, arr
*/
protected function hasExceededTimeLimit(TmpOrder $tmpOrder): bool
{
$UnzerWebhookTimeDifference = Registry::getConfig()->getConfigParam('UnzerWebhookTimeDifference', 5);
$TimeDifferenceSeconds = $UnzerWebhookTimeDifference * 60;
$defTimeDiffMin = Registry::getConfig()->getConfigParam('defTimeDiffMin', 5);
$timeDiffSec = $defTimeDiffMin * 60;
$tmpOrderTime = is_string($tmpOrder->getFieldData('TIMESTAMP')) ? $tmpOrder->getFieldData('TIMESTAMP') : '';
$tmpOrderTimeUnix = strtotime($tmpOrderTime);
$nowTimeUnix = time();
$difference = $nowTimeUnix - $tmpOrderTimeUnix;

return $difference >= $TimeDifferenceSeconds;
return $difference >= $timeDiffSec;
}
}
2 changes: 2 additions & 0 deletions src/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ public function getUnzerInvoiceNr()
* @param $unzerPayment Payment
* @return void
* @throws Exception
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function finalizeTmpOrder(Payment $unzerPayment, bool $error = false): void
{
Expand Down
7 changes: 4 additions & 3 deletions src/Model/TmpOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function __construct()
$this->init('oscunzertmporder');
}


public function save()
{
return parent::save();
Expand All @@ -41,8 +40,10 @@ public function prepareOrderForJson(CoreOrderModel $oOrder): void
{
$oConfig = Registry::getConfig();
$oOrderArticles = $oOrder->getOrderArticles();
$completeOrder['order'] = $oOrder;
$completeOrder['orderArticles'] = $oOrderArticles->getArray();
$completeOrder = [
'order' => $oOrder,
'orderArticles' => $oOrderArticles->getArray()
];
$serializedOrder = serialize($completeOrder);
$base64Order = base64_encode($serializedOrder);
/** @var Order $oOrder */
Expand Down

0 comments on commit 46f4a20

Please sign in to comment.