Fix PHPCS errors

This commit is contained in:
Daniel Dudzic 2025-01-28 11:55:47 +01:00
parent 611dc0ae38
commit 0d59f9e39c
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
4 changed files with 74 additions and 74 deletions

View file

@ -233,12 +233,12 @@ return array(
'settings.data.settings' => static function() : SettingsModel {
return new SettingsModel();
},
'settings.rest.todos' => static function ( ContainerInterface $container ) : TodosRestEndpoint {
'settings.rest.todos' => static function ( ContainerInterface $container ) : TodosRestEndpoint {
return new TodosRestEndpoint(
$container->get( 'settings.data.todos' ),
);
},
'settings.data.todos' => static function ( ContainerInterface $container ) : TodosModel {
'settings.data.todos' => static function ( ContainerInterface $container ) : TodosModel {
return new TodosModel();
},
);

View file

@ -34,9 +34,9 @@ class TodosModel {
* @return array The formatted completion states array.
*/
public function get(): array {
$completion_states = get_option(self::OPTION_NAME, array());
$completion_states = get_option( self::OPTION_NAME, array() );
return array_map(
static function ($state) {
static function ( $state ) {
return (bool) $state;
},
$completion_states
@ -53,18 +53,18 @@ class TodosModel {
* @return void
* @throws RuntimeException When the completion states update fails.
*/
public function update(array $states): void {
public function update( array $states ): void {
$completion_states = array_map(
static function ($state) {
static function ( $state ) {
return (bool) $state;
},
$states
);
$result = update_option(self::OPTION_NAME, $completion_states);
$result = update_option( self::OPTION_NAME, $completion_states );
if (!$result) {
throw new RuntimeException('Failed to update todo completion states');
if ( ! $result ) {
throw new RuntimeException( 'Failed to update todo completion states' );
}
}
}

View file

@ -40,7 +40,7 @@ class TodosRestEndpoint extends RestEndpoint {
*
* @param TodosModel $todos The todos model instance.
*/
public function __construct(TodosModel $todos) {
public function __construct( TodosModel $todos ) {
$this->todos = $todos;
}
@ -52,9 +52,9 @@ class TodosRestEndpoint extends RestEndpoint {
$this->namespace,
'/' . $this->rest_base,
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_todos'),
'permission_callback' => array($this, 'check_permission'),
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_todos' ),
'permission_callback' => array( $this, 'check_permission' ),
)
);
}
@ -66,81 +66,81 @@ class TodosRestEndpoint extends RestEndpoint {
*/
protected function get_todo_definitions(): array {
return array(
'enable_fastlane' => array(
'title' => __('Enable Fastlane', 'woocommerce-paypal-payments'),
'description' => __('Accelerate your guest checkout with Fastlane by PayPal.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'payment_methods',
'enable_fastlane' => array(
'title' => __( 'Enable Fastlane', 'woocommerce-paypal-payments' ),
'description' => __( 'Accelerate your guest checkout with Fastlane by PayPal.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'payment_methods',
'section' => 'ppcp-card-payments-card',
),
),
'enable_credit_debit_cards' => array(
'title' => __('Enable Credit and Debit Cards on your checkout', 'woocommerce-paypal-payments'),
'description' => __('Credit and Debit Cards is now available for Blocks checkout pages.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'payment_methods',
'enable_credit_debit_cards' => array(
'title' => __( 'Enable Credit and Debit Cards on your checkout', 'woocommerce-paypal-payments' ),
'description' => __( 'Credit and Debit Cards is now available for Blocks checkout pages.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'payment_methods',
'section' => 'ppcp-card-payments-card',
),
),
'enable_pay_later_messaging' => array(
'title' => __('Enable Pay Later messaging', 'woocommerce-paypal-payments'),
'description' => __('Show Pay Later messaging to boost conversion rate and increase cart size.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'enable_pay_later_messaging' => array(
'title' => __( 'Enable Pay Later messaging', 'woocommerce-paypal-payments' ),
'description' => __( 'Show Pay Later messaging to boost conversion rate and increase cart size.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'section' => 'pay_later_messaging',
),
),
'configure_paypal_subscription' => array(
'title' => __('Configure a PayPal Subscription', 'woocommerce-paypal-payments'),
'description' => __('Connect a subscriptions-type product from WooCommerce with PayPal.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'configure_paypal_subscription' => array(
'title' => __( 'Configure a PayPal Subscription', 'woocommerce-paypal-payments' ),
'description' => __( 'Connect a subscriptions-type product from WooCommerce with PayPal.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'external',
'url' => admin_url('edit.php?post_type=product&product_type=subscription'),
'url' => admin_url( 'edit.php?post_type=product&product_type=subscription' ),
),
),
'register_domain_apple_pay' => array(
'title' => __('Register Domain for Apple Pay', 'woocommerce-paypal-payments'),
'description' => __('To enable Apple Pay, you must register your domain with PayPal.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'register_domain_apple_pay' => array(
'title' => __( 'Register Domain for Apple Pay', 'woocommerce-paypal-payments' ),
'description' => __( 'To enable Apple Pay, you must register your domain with PayPal.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'section' => 'apple_pay',
),
),
'add_digital_wallets_to_account' => array(
'title' => __('Add digital wallets to your account', 'woocommerce-paypal-payments'),
'description' => __('Add the ability to accept Apple Pay & Google Pay to your PayPal account.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'title' => __( 'Add digital wallets to your account', 'woocommerce-paypal-payments' ),
'description' => __( 'Add the ability to accept Apple Pay & Google Pay to your PayPal account.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'external',
'url' => 'https://www.paypal.com/businessmanage/account/settings',
'url' => 'https://www.paypal.com/businessmanage/account/settings',
),
),
'enable_apple_pay' => array(
'title' => __('Enable Apple Pay', 'woocommerce-paypal-payments'),
'description' => __('Allow your buyers to check out via Apple Pay.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'enable_apple_pay' => array(
'title' => __( 'Enable Apple Pay', 'woocommerce-paypal-payments' ),
'description' => __( 'Allow your buyers to check out via Apple Pay.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'section' => 'apple_pay',
),
),
'enable_google_pay' => array(
'title' => __('Enable Google Pay', 'woocommerce-paypal-payments'),
'description' => __('Allow your buyers to check out via Google Pay.', 'woocommerce-paypal-payments'),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'enable_google_pay' => array(
'title' => __( 'Enable Google Pay', 'woocommerce-paypal-payments' ),
'description' => __( 'Allow your buyers to check out via Google Pay.', 'woocommerce-paypal-payments' ),
'isEligible' => fn() => true,
'action' => array(
'type' => 'tab',
'tab' => 'overview',
'section' => 'google_pay',
),
),
@ -154,20 +154,20 @@ class TodosRestEndpoint extends RestEndpoint {
*/
public function get_todos(): WP_REST_Response {
$completion_states = $this->todos->get();
$todos = array();
$todos = array();
foreach ($this->get_todo_definitions() as $id => $todo) {
if ($todo['isEligible']()) {
foreach ( $this->get_todo_definitions() as $id => $todo ) {
if ( $todo['isEligible']() ) {
$todos[] = array_merge(
array(
'id' => $id,
'isCompleted' => $completion_states[$id] ?? false
'id' => $id,
'isCompleted' => $completion_states[ $id ] ?? false,
),
array_diff_key($todo, array('isEligible' => true))
array_diff_key( $todo, array( 'isEligible' => true ) )
);
}
}
return $this->return_success($todos);
return $this->return_success( $todos );
}
}

View file

@ -220,7 +220,7 @@ class SettingsModule implements ServiceModule, ExecutableModule {
'payment' => $container->get( 'settings.rest.payment' ),
'settings' => $container->get( 'settings.rest.settings' ),
'styling' => $container->get( 'settings.rest.styling' ),
'todos' => $container->get( 'settings.rest.todos' ),
'todos' => $container->get( 'settings.rest.todos' ),
);
foreach ( $endpoints as $endpoint ) {