Skip to content

Commit

Permalink
Resolving issues raised by SonarCloud.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aashish committed May 30, 2024
1 parent db76c20 commit 35e23be
Show file tree
Hide file tree
Showing 31 changed files with 488 additions and 488 deletions.
96 changes: 48 additions & 48 deletions includes/blocks/gateways/abstract-omise-block-apm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@

abstract class Omise_Block_Apm extends AbstractPaymentMethodType {
/**
* The gateway instance.
*/
protected $gateway;
* The gateway instance.
*/
protected $gateway;

/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name;
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name;

/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] );
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[ $this->name ];
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] );
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[ $this->name ];
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return $this->gateway->is_available();
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return $this->gateway->is_available();
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
if ( ! wp_script_is( 'wc-omise-one-click-apms-payments-blocks', 'enqueued' ) ) {
$script_asset = require __DIR__ . '/../assets/js/build/omise-one-click-apms.asset.php';
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
if ( ! wp_script_is( 'wc-omise-one-click-apms-payments-blocks', 'enqueued' ) ) {
$script_asset = require_once __DIR__ . '/../assets/js/build/omise-one-click-apms.asset.php';
wp_register_script(
"wc-omise-one-click-apms-payments-blocks",
plugin_dir_url( __DIR__ ) . 'assets/js/build/omise-one-click-apms.js',
Expand All @@ -52,20 +52,20 @@ public function get_payment_method_script_handles() {
wp_enqueue_script( 'wc-omise-one-click-apms-payments-blocks' );
}

return [ 'wc-omise-one-click-apms-payments-blocks' ];
}
return [ 'wc-omise-one-click-apms-payments-blocks' ];
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'name' => $this->name,
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] )
];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'name' => $this->name,
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] )
];
}
}
148 changes: 74 additions & 74 deletions includes/blocks/gateways/abstract-omise-block-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,89 @@
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

abstract class Omise_Block_Payment extends AbstractPaymentMethodType {
/**
* The gateway instance.
*/
protected $gateway;
/**
* The gateway instance.
*/
protected $gateway;

/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name;
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name;

/**
* Additional data required in the UI
*/
protected $additional_data;
/**
* Additional data required in the UI
*/
protected $additional_data;

/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option("woocommerce_{$this->name}_settings", []);
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[$this->name];
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option("woocommerce_{$this->name}_settings", []);
$gateways = WC()->payment_gateways->payment_gateways();
$this->gateway = $gateways[$this->name];
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return $this->gateway->is_available();
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return $this->gateway->is_available();
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
if (!wp_script_is("wc-{$this->name}-payments-blocks", 'enqueued')) {
$script_asset = require __DIR__ . "/../assets/js/build/{$this->name}.asset.php";
wp_register_script(
"wc-{$this->name}-payments-blocks",
plugin_dir_url(__DIR__) . "assets/js/build/{$this->name}.js",
$script_asset['dependencies'],
$script_asset['version'],
true
);
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
if (!wp_script_is("wc-{$this->name}-payments-blocks", 'enqueued')) {
$script_asset = require_once __DIR__ . "/../assets/js/build/{$this->name}.asset.php";
wp_register_script(
"wc-{$this->name}-payments-blocks",
plugin_dir_url(__DIR__) . "assets/js/build/{$this->name}.js",
$script_asset['dependencies'],
$script_asset['version'],
true
);

wp_enqueue_script("wc-{$this->name}-payments-blocks");
}
wp_enqueue_script("wc-{$this->name}-payments-blocks");
}

return ["wc-{$this->name}-payments-blocks"];
}
return ["wc-{$this->name}-payments-blocks"];
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
if (!is_checkout()) {
return [];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
if (!is_checkout()) {
return [];
}

$this->set_additional_data();
$this->set_additional_data();

return [
'name' => $this->name,
'title' => $this->get_setting('title'),
'description' => $this->get_setting('description'),
'supports' => array_filter($this->gateway->supports, [$this->gateway, 'supports']),
'data' => $this->additional_data,
];
}
return [
'name' => $this->name,
'title' => $this->get_setting('title'),
'description' => $this->get_setting('description'),
'supports' => array_filter($this->gateway->supports, [$this->gateway, 'supports']),
'data' => $this->additional_data,
];
}

/**
* Set additional data requried to make UI work. Different payment
* methods may require different additional data.
*
* @return void
*/
abstract public function set_additional_data();
/**
* Set additional data requried to make UI work. Different payment
* methods may require different additional data.
*
* @return void
*/
abstract public function set_additional_data();
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-alipay-cn.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Alipay_CN extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay_cn';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay_cn';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-alipay-hk.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Alipay_HK extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay_hk';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay_hk';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-alipay.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Alipay extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_alipay';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-dana.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Dana extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_dana';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_dana';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-gcash.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Gcash extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_gcash';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_gcash';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-kakaopay.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Kakaopay extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_kakaopay';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_kakaopay';
}
12 changes: 6 additions & 6 deletions includes/blocks/gateways/alipay/omise-block-touch-n-go.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Omise_Block_Touch_N_Go extends Omise_Block_Apm {
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_touch_n_go';
/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'omise_touch_n_go';
}
Loading

0 comments on commit 35e23be

Please sign in to comment.