🎨 Code-style, apply phpcs rules

This commit is contained in:
Philipp Stracker 2025-03-04 17:29:09 +01:00
parent 60ab51a2f8
commit 8153026e22
No known key found for this signature in database

View file

@ -6,7 +6,7 @@
* @package WooCommerce\PayPalCommerce\Button\Endpoint * @package WooCommerce\PayPalCommerce\Button\Endpoint
*/ */
declare(strict_types=1); declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Button\Endpoint; namespace WooCommerce\PayPalCommerce\Button\Endpoint;
@ -24,7 +24,6 @@ use WooCommerce\PayPalCommerce\Button\Helper\WooCommerceOrderCreator;
use WooCommerce\PayPalCommerce\Session\SessionHandler; use WooCommerce\PayPalCommerce\Session\SessionHandler;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
/** /**
* Class ApproveOrderEndpoint * Class ApproveOrderEndpoint
@ -159,7 +158,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
* *
* @return string * @return string
*/ */
public static function nonce(): string { public static function nonce() : string {
return self::ENDPOINT; return self::ENDPOINT;
} }
@ -169,9 +168,9 @@ class ApproveOrderEndpoint implements EndpointInterface {
* @return bool * @return bool
* @throws RuntimeException When order not found or handling failed. * @throws RuntimeException When order not found or handling failed.
*/ */
public function handle_request(): bool { public function handle_request() : bool {
try { try {
$data = $this->request_data->read_request( $this->nonce() ); $data = $this->request_data->read_request( self::nonce() );
if ( ! isset( $data['order_id'] ) ) { if ( ! isset( $data['order_id'] ) ) {
throw new RuntimeException( throw new RuntimeException(
__( 'No order id given', 'woocommerce-paypal-payments' ) __( 'No order id given', 'woocommerce-paypal-payments' )
@ -181,6 +180,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
$order = $this->api_endpoint->order( $data['order_id'] ); $order = $this->api_endpoint->order( $data['order_id'] );
$payment_source = $order->payment_source(); $payment_source = $order->payment_source();
if ( $payment_source && $payment_source->name() === 'card' ) { if ( $payment_source && $payment_source->name() === 'card' ) {
if ( $this->settings->has( 'disable_cards' ) ) { if ( $this->settings->has( 'disable_cards' ) ) {
$disabled_cards = (array) $this->settings->get( 'disable_cards' ); $disabled_cards = (array) $this->settings->get( 'disable_cards' );
@ -250,6 +250,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
wp_send_json_success( array( 'order_received_url' => $order_received_url ) ); wp_send_json_success( array( 'order_received_url' => $order_received_url ) );
} }
wp_send_json_success(); wp_send_json_success();
return true; return true;
} catch ( Exception $error ) { } catch ( Exception $error ) {
$this->logger->error( 'Order approve failed: ' . $error->getMessage() ); $this->logger->error( 'Order approve failed: ' . $error->getMessage() );
@ -262,6 +263,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(), 'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(),
) )
); );
return false; return false;
} }
} }
@ -271,7 +273,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
* *
* @return void * @return void
*/ */
protected function toggle_final_review_enabled_setting(): void { protected function toggle_final_review_enabled_setting() : void {
// TODO new-ux: This flag must also be updated in the new settings. // TODO new-ux: This flag must also be updated in the new settings.
$final_review_enabled_setting = $this->settings->has( 'blocks_final_review_enabled' ) && $this->settings->get( 'blocks_final_review_enabled' ); $final_review_enabled_setting = $this->settings->has( 'blocks_final_review_enabled' ) && $this->settings->get( 'blocks_final_review_enabled' );
$this->settings->set( 'blocks_final_review_enabled', ! $final_review_enabled_setting ); $this->settings->set( 'blocks_final_review_enabled', ! $final_review_enabled_setting );