Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PHP Code Style

on:
push:
branches: [ "b-6.1.x" ]
pull_request:
branches: [ "b-6.1.x" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Validate composer.json
run: composer validate --strict

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Setup IDE helper
run: php ./ide-helper.php

- name: Check code styling
run: composer run-script style-check
27 changes: 27 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PHP Stan check

on:
push:
branches: [ "b-6.1.x" ]
pull_request:
branches: [ "b-6.1.x" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Setup IDE helper
run: php ./ide-helper.php

- name: phpstan check
run: php ./vendor/bin/phpstan --no-progress
27 changes: 27 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PHP Unit Test

on:
push:
branches: [ "b-6.1.x" ]
pull_request:
branches: [ "b-6.1.x" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: Setup IDE helper
run: php ./ide-helper.php

- name: Unit tests
run: php ./vendor/bin/phpunit
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
/tests/reports/
/source
/var
/build
composer.lock
.phpunit.result.cache
.php-cs-fixer.cache
# phpstorm project files
.idea

# netbeans project files
nbproject

# zend studio for eclipse project files
.buildpath
.project
.settings

# windows thumbnail cache
Thumbs.db

# composer vendor dir
/vendor

# composer itself is not needed
composer.phar

# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar

# vagrant runtime
/.vagrant
/.phpstorm.meta.php/oxid.meta.php
/.ide-helper.php
32 changes: 32 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);


$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->ignoreVCSIgnored(true)
->exclude('Application/views')
->exclude('metadata.php')
->exclude('source');

/**
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/
return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
'@PSR12' => true,
'@PHP74Migration' => true,
'header_comment' => ['header' => <<<'EOF'
This file is part of OXID eSales AG EasyCredit module
Copyright © OXID eSales AG. All rights reserved.

Licensed under the GNU GPL v3 - See the file LICENSE for details.
EOF],
'numeric_literal_separator' => true,
])
->setFinder($finder);
31 changes: 14 additions & 17 deletions Application/Component/Widget/EasyCreditExampleCalculation.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
/**
* This Software is the property of OXID eSales and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license key
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.

/*
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2021
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/

namespace OxidProfessionalServices\EasyCredit\Application\Component\Widget;
Expand Down Expand Up @@ -46,7 +42,7 @@ class EasyCreditExampleCalculation extends WidgetController
/**
* Return the monthly fee to pay for credit.
*
* @return string
* @return string|void
*/
public function getExampleCalculationRate()
{
Expand All @@ -62,7 +58,7 @@ public function getExampleCalculationRate()
*/
public function hasExampleCalculation()
{
return (bool)$this->getExampleCalulation();
return (bool) $this->getExampleCalulation();
}

/**
Expand Down Expand Up @@ -121,7 +117,7 @@ protected function getBasket()
/**
* Load example calculation from ec service.
*
* @return false|\stdClass
* @return false|\stdClass|void
* @throws SystemComponentException
*/
protected function getExampleCalculationResponse()
Expand All @@ -132,8 +128,8 @@ protected function getExampleCalculationResponse()

if (
!$price ||
(int)$price->getBruttoPrice() < (int)$payment->getFieldData('oxfromamount') ||
(int)$price->getBruttoPrice() > (int)$payment->getFieldData('oxtoamount')
(int) $price->getBruttoPrice() < (int) $payment->getFieldData('oxfromamount') ||
(int) $price->getBruttoPrice() > (int) $payment->getFieldData('oxtoamount')
) {
return false;
}
Expand All @@ -145,8 +141,9 @@ protected function getExampleCalculationResponse()
$webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient(
EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_MODELLRECHNUNG_GUENSTIGSTER_RATENPLAN,
$dic,
array(),
array(EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice()));
[],
[EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice()]
);
return $webServiceClient->execute();
} catch (\Exception $ex) {
$this->getDic()->getLogging()->log($ex->getMessage());
Expand Down Expand Up @@ -196,4 +193,4 @@ public function isAjax()
{
return (Registry::getConfig()->getRequestParameter('ajax') == 1);
}
}
}
16 changes: 6 additions & 10 deletions Application/Component/Widget/EasyCreditExampleCalculationPopup.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
/**
* This Software is the property of OXID eSales and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license key
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.

/*
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2021
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/

namespace OxidProfessionalServices\EasyCredit\Application\Component\Widget;
Expand Down Expand Up @@ -91,4 +87,4 @@ protected function getWebshopId()
{
return $this->getDic()->getApiConfig()->getWebShopId();
}
}
}
16 changes: 6 additions & 10 deletions Application/Controller/Admin/EasyCreditOrderAddressController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
/**
* This Software is the property of OXID eSales and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license key
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.

/*
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2021
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/

namespace OxidProfessionalServices\EasyCredit\Application\Controller\Admin;
Expand All @@ -33,7 +29,7 @@ public function render()

$soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();

if ($soxId != "-1" && isset($soxId)) {
if ($soxId != "-1") {
// load object
$oOrder = oxNew(Order::class);
$oOrder->load($soxId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
/**
* This Software is the property of OXID eSales and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license key
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.

/*
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2021
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/

namespace OxidProfessionalServices\EasyCredit\Application\Controller\Admin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<?php
/**
* This Software is the property of OXID eSales and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license key
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.

/*
* This file is part of OXID eSales AG EasyCredit module
* Copyright © OXID eSales AG. All rights reserved.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2021
* Licensed under the GNU GPL v3 - See the file LICENSE for details.
*/

namespace OxidProfessionalServices\EasyCredit\Application\Controller\Admin;
Expand Down Expand Up @@ -97,7 +93,7 @@ public function sendReversal()
$reversalSuccess = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ADMIN_REVERSAL_SUCCESS');
$this->addTplParam('reversalsuccess', $reversalSuccess);
} catch (EasyCreditException $e) {
if( 0 < $e->getCode()) {
if (0 < $e->getCode()) {
$reversalError = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ADMIN_REVERSAL_ERROR_AMOUNT');

} else {
Expand All @@ -115,7 +111,7 @@ public function sendReversal()
protected function getOrder()
{
$soxId = $this->getEditObjectId();
if ($this->order === false && isset($soxId) && $soxId != '-1') {
if ($this->order === false && $soxId != '-1') {
$this->order = oxNew(Order::class);
$this->order->load($soxId);
}
Expand Down Expand Up @@ -223,8 +219,8 @@ protected function validateInput(array $request)
# match reversal amount to max open amount
$service = $this->getService();
$orderData = $service->getOrderData();
$maxReversalAmount = (float)$orderData[0]->bestellwertAktuell;
$requestReversalAmount = (float)$request['amount'];
$maxReversalAmount = (float) $orderData[0]->bestellwertAktuell;
$requestReversalAmount = (float) $request['amount'];
if ($requestReversalAmount > $maxReversalAmount || 0 >= $requestReversalAmount) {
throw new EasyCreditException("Requested reversal greater than actual amount", 10);
}
Expand All @@ -247,4 +243,4 @@ private function sendReversalToEc(array $request)
$service = $this->getService();
$service->sendReversal($amount, $reason);
}
}
}
Loading