Skip to content

Commit 1d4daa2

Browse files
author
Dat Pham
committed
PHP code fixer
1 parent 3b830f9 commit 1d4daa2

9 files changed

+263
-254
lines changed

src/woocommerce-gateway-lemonway/includes/abstracts/abstract-wc-lemonway-payment-gateway.php

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
if ( ! defined( 'ABSPATH' ) ) {
2+
if (! defined('ABSPATH')) {
33
exit; // Exit if accessed directly
44
}
55

@@ -119,25 +119,28 @@ abstract class WC_LemonWay_Payment_Gateway extends WC_Payment_Gateway
119119
*
120120
* @param string $warning Warning message.
121121
*/
122-
protected function add_warning( $warning ) {
122+
protected function add_warning($warning)
123+
{
123124
$this->warnings[] = $warning;
124125
}
125126

126127
/**
127128
* Get admin warning messages.
128129
*/
129-
protected function get_warnings() {
130+
protected function get_warnings()
131+
{
130132
return $this->warnings;
131133
}
132134

133135
/**
134136
* Display admin warning messages.
135137
*/
136-
protected function display_warnings() {
137-
if ( $this->get_warnings() ) {
138+
protected function display_warnings()
139+
{
140+
if ($this->get_warnings()) {
138141
echo '<div id="woocommerce_warnings" class="notice-warning notice is-dismissible">';
139-
foreach ( $this->get_warnings() as $warning ) {
140-
echo '<p>' . wp_kses_post( $warning ) . '</p>';
142+
foreach ($this->get_warnings() as $warning) {
143+
echo '<p>' . wp_kses_post($warning) . '</p>';
141144
}
142145
echo '</div>';
143146
}
@@ -147,25 +150,25 @@ protected function display_warnings() {
147150
* Load API settings
148151
*/
149152
protected function load_api_settings()
150-
{
153+
{
151154
// Load main settings
152155
$settings_field_key = $this->get_option_key();
153-
$main_settings = get_option( $settings_field_key );
154-
155-
$this->wlLogin = ! empty( $main_settings['wlLogin'] ) ? $main_settings['wlLogin'] : '';
156-
$this->wlPass = ! empty( $main_settings['wlPass'] ) ? $main_settings['wlPass'] : '';
157-
$this->test_mode = ( ! empty( $main_settings['test_mode'] ) && 'yes' === $main_settings['test_mode'] ) ? true : false;
158-
$this->env_name = ! empty( $main_settings['env_name'] ) ? $main_settings['env_name'] : '';
159-
$this->wallet = ! empty( $main_settings['wallet'] ) ? $main_settings['wallet'] : '';
160-
$this->directkit_url = ! empty( $main_settings['directkit_url'] ) ? $main_settings['directkit_url'] : '';
161-
$this->webkit_url = ! empty( $main_settings['webkit_url'] ) ? $main_settings['webkit_url'] : '';
156+
$main_settings = get_option($settings_field_key);
157+
158+
$this->wlLogin = ! empty($main_settings['wlLogin']) ? $main_settings['wlLogin'] : '';
159+
$this->wlPass = ! empty($main_settings['wlPass']) ? $main_settings['wlPass'] : '';
160+
$this->test_mode = (! empty($main_settings['test_mode']) && 'yes' === $main_settings['test_mode']) ? true : false;
161+
$this->env_name = ! empty($main_settings['env_name']) ? $main_settings['env_name'] : '';
162+
$this->wallet = ! empty($main_settings['wallet']) ? $main_settings['wallet'] : '';
163+
$this->directkit_url = ! empty($main_settings['directkit_url']) ? $main_settings['directkit_url'] : '';
164+
$this->webkit_url = ! empty($main_settings['webkit_url']) ? $main_settings['webkit_url'] : '';
162165
}
163166

164167
/**
165168
* Set up API
166169
*/
167170
protected function set_up_api()
168-
{
171+
{
169172
$settings = array(
170173
'directkit_url' => $this->directkit_url,
171174
'wlLogin' => $this->wlLogin,
@@ -190,8 +193,8 @@ protected function test_api()
190193
try {
191194
$wallet_details = $this->api->get_wallet_details($params);
192195
} catch (WC_LemonWay_Exception $e) {
193-
if ( ! is_ajax() ) {
194-
$this->add_error( $e->getLocalizedMessage() . ' (' . $e->getCode() . ')' );
196+
if (! is_ajax()) {
197+
$this->add_error($e->getLocalizedMessage() . ' (' . $e->getCode() . ')');
195198
$this->display_errors();
196199
}
197200

@@ -206,7 +209,7 @@ protected function test_api()
206209
*/
207210
protected function format_amount($amount)
208211
{
209-
return number_format ( $amount , 2 , '.' , '' );
212+
return number_format($amount, 2, '.', '');
210213
}
211214

212215
/**
@@ -221,21 +224,21 @@ public function __construct()
221224
$this->init_settings();
222225

223226
// Get setting values.
224-
$this->title = $this->get_option( 'title' );
225-
$this->description = $this->get_option( 'description' );
227+
$this->title = $this->get_option('title');
228+
$this->description = $this->get_option('description');
226229

227230
// Load API settings
228231
$this->load_api_settings();
229232

230-
if ( $this->test_mode ) {
233+
if ($this->test_mode) {
231234
$this->title .= ' [TEST]';
232-
$this->description = '[' . __( 'This is only a test payment.', LEMONWAY_TEXT_DOMAIN ) . ' <a href="' . __( 'https://lemonway.zendesk.com/hc/en-gb/articles/212557765-2-How-do-I-test-with-the-WooCommerce-module-', LEMONWAY_TEXT_DOMAIN ) . '" target="_blank">' . __( 'Click here to see how to use Test mode.', LEMONWAY_TEXT_DOMAIN ) . '</a>' . ']' . "\n" . $this->description;
235+
$this->description = '[' . __('This is only a test payment.', LEMONWAY_TEXT_DOMAIN) . ' <a href="' . __('https://lemonway.zendesk.com/hc/en-gb/articles/212557765-2-How-do-I-test-with-the-WooCommerce-module-', LEMONWAY_TEXT_DOMAIN) . '" target="_blank">' . __('Click here to see how to use Test mode.', LEMONWAY_TEXT_DOMAIN) . '</a>' . ']' . "\n" . $this->description;
233236
}
234237

235238
// Set API language
236-
$locale = substr( get_locale(), 0, 2 );
239+
$locale = substr(get_locale(), 0, 2);
237240

238-
if ( array_key_exists( $locale, $this->supported_locales ) ) {
241+
if (array_key_exists($locale, $this->supported_locales)) {
239242
$this->language = $this->supported_locales[$locale];
240243
} else {
241244
$this->language = 'en';
@@ -244,7 +247,7 @@ public function __construct()
244247
// Set up API
245248
$this->set_up_api();
246249

247-
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
250+
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ));
248251
}
249252

250253
/**

0 commit comments

Comments
 (0)