From 3e8a4667231ba5a4d82b82fc1a2bdd3b4760b013 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Thu, 27 May 2021 16:01:41 +0200 Subject: [PATCH] Fix PHPCS. --- phpcs.xml.dist | 1 + src/WebhookController.php | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3464d3f..017a199 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -44,6 +44,7 @@ + diff --git a/src/WebhookController.php b/src/WebhookController.php index 8a0f9d3..3cd061f 100644 --- a/src/WebhookController.php +++ b/src/WebhookController.php @@ -54,9 +54,9 @@ public function rest_api_init() { Integration::REST_ROUTE_NAMESPACE, '/webhook/(?P[\d]+)', array( - 'args' => array( + 'args' => array( 'id' => array( - 'description' => __( 'Unique identifier for the gateway configuration post.', 'pronamic_ideal' ), + 'description' => \__( 'Unique identifier for the gateway configuration post.', 'pronamic_ideal' ), 'type' => 'integer', ), ), @@ -101,10 +101,12 @@ public function rest_api_omnikassa_2_webhook( \WP_REST_Request $request ) { } // Response. - $response = new \WP_REST_Response( array( - 'success' => true, - 'results' => $results, - ) ); + $response = new \WP_REST_Response( + array( + 'success' => true, + 'results' => $results, + ) + ); $response->add_link( 'self', \rest_url( $request->get_route() ) ); @@ -142,7 +144,7 @@ public function rest_api_omnikassa_2_webhook_item( \WP_REST_Request $request ) { if ( null === $id ) { return new \WP_Error( 'rest_omnikassa_2_gateway_no_id', - __( 'No gateway ID given in `id` parameter.', 'pronamic_ideal' ) + \__( 'No gateway ID given in `id` parameter.', 'pronamic_ideal' ) ); } @@ -162,6 +164,7 @@ public function rest_api_omnikassa_2_webhook_item( \WP_REST_Request $request ) { try { $gateway->handle_notification( $notification ); + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch ( \Pronamic\WordPress\Pay\Gateways\OmniKassa2\UnknownOrderIdsException $e ) { /** * We don't return an error for unknown order IDs, since OmniKassa @@ -170,7 +173,7 @@ public function rest_api_omnikassa_2_webhook_item( \WP_REST_Request $request ) { } catch ( \Exception $e ) { return new \WP_Error( 'rest_omnikassa_2_exception', - $e->getMessage(), + $e->getMessage(), array( 'status' => 400, 'notification' => $json, @@ -178,9 +181,9 @@ public function rest_api_omnikassa_2_webhook_item( \WP_REST_Request $request ) { ) ); } - + // Response. - $response = new \WP_REST_Response( $data ); + $response = new \WP_REST_Response( array( 'success' => true ) ); $response->add_link( 'self', \rest_url( $request->get_route() ) );