From 44fc687d5441e203570fad4235d784df203f2a5f Mon Sep 17 00:00:00 2001 From: Roel van Hintum Date: Thu, 13 Jul 2023 14:37:47 +0200 Subject: [PATCH] Match Craft's php standards as much as possible --- CHANGELOG.md | 4 ++++ src/base/Gateway.php | 17 +++++++++-------- src/gateways/CreditCardGateway.php | 14 +++++++------- src/gateways/IdealGateway.php | 14 +++++++------- src/gateways/PayPalGateway.php | 14 +++++++------- src/gateways/SepaDirectDebitGateway.php | 14 +++++++------- src/models/forms/CreditCardPaymentForm.php | 5 ++++- src/models/forms/IdealPaymentForm.php | 5 ++++- 8 files changed, 49 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef9ceed..928a094 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release notes for Buckaroo Gateway for Craft Commerce +## 2.1.1 - 2023-07-13 +### Changed +- Match Craft's php standards as much as possible + ## 2.1.0 - 2023-07-07 ### Changed - Ideal issuer select doesn't have a bank selected by default anymore diff --git a/src/base/Gateway.php b/src/base/Gateway.php index 889e1fb..a3ebef0 100755 --- a/src/base/Gateway.php +++ b/src/base/Gateway.php @@ -7,6 +7,7 @@ use Craft; use craft\commerce\models\payments\BasePaymentForm; use craft\commerce\omnipay\base\OffsiteGateway; +use craft\helpers\App; use Omnipay\Common\AbstractGateway; use Omnipay\Buckaroo\BuckarooGateway as OmnipayBuckarooGateway; @@ -17,19 +18,19 @@ abstract class Gateway extends OffsiteGateway // ========================================================================= /** - * @var string + * @var string|null */ - public $websiteKey; + public ?string $websiteKey; /** - * @var string + * @var string|null */ - public $secretKey; + public ?string $secretKey; /** - * @var bool + * @var bool|null */ - public $testMode = false; + public ?bool $testMode = false; // Public Methods // ========================================================================= @@ -93,8 +94,8 @@ protected function createGateway(): AbstractGateway $settings = BuckarooPlugin::$plugin->getSettings(); $testMode = $settings->testMode !== null ? $settings->testMode : $this->testMode; - $gateway->setWebsiteKey(Craft::parseEnv($this->websiteKey)); - $gateway->setSecretKey(Craft::parseEnv($this->secretKey)); + $gateway->setWebsiteKey(App::parseEnv($this->websiteKey)); + $gateway->setSecretKey(App::parseEnv($this->secretKey)); $gateway->setTestMode($testMode); return $gateway; diff --git a/src/gateways/CreditCardGateway.php b/src/gateways/CreditCardGateway.php index 9788dee..f3f6bf8 100644 --- a/src/gateways/CreditCardGateway.php +++ b/src/gateways/CreditCardGateway.php @@ -16,19 +16,19 @@ class CreditCardGateway extends Gateway // ========================================================================= /** - * @var string + * @var string|null */ - public $websiteKey; + public ?string $websiteKey; /** - * @var string + * @var string|null */ - public $secretKey; + public ?string $secretKey; /** - * @var bool + * @var bool|null */ - public $testMode = false; + public ?bool $testMode = false; // Public Methods // ========================================================================= @@ -122,7 +122,7 @@ public function fetchPaymentMethods(): array /** * @inheritdoc */ - protected function getGatewayClassName(): null|string + protected function getGatewayClassName(): ?string { return '\\' . OmniPayCreditCardGateway::class; } diff --git a/src/gateways/IdealGateway.php b/src/gateways/IdealGateway.php index a499823..9473668 100644 --- a/src/gateways/IdealGateway.php +++ b/src/gateways/IdealGateway.php @@ -16,19 +16,19 @@ class IdealGateway extends Gateway // ========================================================================= /** - * @var string + * @var string|null */ - public $websiteKey; + public ?string $websiteKey; /** - * @var string + * @var string|null */ - public $secretKey; + public ?string $secretKey; /** - * @var bool + * @var bool|null */ - public $testMode = false; + public ?bool $testMode = false; // Public Methods // ========================================================================= @@ -121,7 +121,7 @@ public function fetchIssuers(): array /** * @inheritdoc */ - protected function getGatewayClassName(): null|string + protected function getGatewayClassName(): ?string { return '\\' . OmniPayIdealGateway::class; } diff --git a/src/gateways/PayPalGateway.php b/src/gateways/PayPalGateway.php index 436e0c8..b920e94 100644 --- a/src/gateways/PayPalGateway.php +++ b/src/gateways/PayPalGateway.php @@ -13,19 +13,19 @@ class PayPalGateway extends Gateway // ========================================================================= /** - * @var string + * @var string|null */ - public $websiteKey; + public ?string $websiteKey; /** - * @var string + * @var string|null */ - public $secretKey; + public ?string $secretKey; /** - * @var bool + * @var bool|null */ - public $testMode = false; + public ?bool $testMode = false; // Public Methods // ========================================================================= @@ -44,7 +44,7 @@ public static function displayName(): string /** * @inheritdoc */ - protected function getGatewayClassName(): null|string + protected function getGatewayClassName(): ?string { return '\\' . OmniPayPayPalGateway::class; } diff --git a/src/gateways/SepaDirectDebitGateway.php b/src/gateways/SepaDirectDebitGateway.php index 7ec75e7..6239e62 100644 --- a/src/gateways/SepaDirectDebitGateway.php +++ b/src/gateways/SepaDirectDebitGateway.php @@ -13,19 +13,19 @@ class SepaDirectDebitGateway extends Gateway // ========================================================================= /** - * @var string + * @var string|null */ - public $websiteKey; + public ?string $websiteKey; /** - * @var string + * @var string|null */ - public $secretKey; + public ?string $secretKey; /** - * @var bool + * @var bool|null */ - public $testMode = false; + public ?bool $testMode = false; // Public Methods // ========================================================================= @@ -44,7 +44,7 @@ public static function displayName(): string /** * @inheritdoc */ - protected function getGatewayClassName(): null|string + protected function getGatewayClassName(): ?string { return '\\' . OmniPaySepaDirectDebitGateway::class; } diff --git a/src/models/forms/CreditCardPaymentForm.php b/src/models/forms/CreditCardPaymentForm.php index 327db7d..f1e81e3 100755 --- a/src/models/forms/CreditCardPaymentForm.php +++ b/src/models/forms/CreditCardPaymentForm.php @@ -6,5 +6,8 @@ class CreditCardPaymentForm extends OffsitePaymentForm { - public $paymentMethod; + /** + * @var string|null + */ + public ?string $paymentMethod = null; } \ No newline at end of file diff --git a/src/models/forms/IdealPaymentForm.php b/src/models/forms/IdealPaymentForm.php index 506eff3..1baf679 100755 --- a/src/models/forms/IdealPaymentForm.php +++ b/src/models/forms/IdealPaymentForm.php @@ -6,5 +6,8 @@ class IdealPaymentForm extends OffsitePaymentForm { - public $issuer; + /** + * @var string|null + */ + public ?string $issuer = null; } \ No newline at end of file