Skip to content

Commit

Permalink
PHPCS fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vedanshujain committed Dec 23, 2024
1 parent bc58e4d commit 83ea800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions app/src/Store/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ protected function handle_request(): Controller {
->set_order_from_cart()
->process_payment()
->save_order()
->empty_cart()
;
->empty_cart();
}
$order_data = $this->order->to_public_array();
$prefixed_keys = array( 'id', 'key' );
Expand All @@ -177,7 +176,7 @@ private function validate_order_from_cart(): CheckoutController {
}

private function process_payment(): CheckoutController {
$params = $this->get_params_or_exit();
$params = $this->get_params_or_exit();
if ( ! isset( $params['billing_email'] ) ) {
send_error_and_exit( 'missing_billing_email', 400, 'Billing email is required' );
}
Expand Down
20 changes: 9 additions & 11 deletions app/src/Store/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ class OrderController extends Controller {
private Order $order;

public function __construct( StoreAuth $auth, string $request, SerializableHotStoreInterface $hot_store, SiteInfo $site_info ) {
$this->auth = $auth;
$this->auth = $auth;
$this->hot_store = $hot_store;
$this->request = $request;
$this->request = $request;
$this->site_info = $site_info;
}

private function set_order_id_from_request(): OrderController {
$path_parts = explode('/', trim($this->request, '/'));
$this->order_id = (int) end($path_parts);
$path_parts = explode( '/', trim( $this->request, '/' ) );
$this->order_id = (int) end( $path_parts );

if ( $this->order_id <= 0 ) {
send_error_and_exit( 'invalid_request', 400, 'Missing required parameters: order_id' );
}

$query_params = array();
parse_str(parse_url($this->request, PHP_URL_QUERY), $query_params);
parse_str( parse_url( $this->request, PHP_URL_QUERY ), $query_params );

if (empty($query_params['key'])) {
send_error_and_exit('invalid_request', 400, 'Missing required parameters: key' );
if ( empty( $query_params['key'] ) ) {
send_error_and_exit( 'invalid_request', 400, 'Missing required parameters: key' );
}

$this->key = $query_params['key'];
$this->key = $query_params['key'];
$this->billing_email = $query_params['billing_email'] ?? '';
return $this;
}
Expand Down Expand Up @@ -79,14 +79,12 @@ public function authenticate(): Controller {
->set_order_id_from_request()
->fetch_order()
->validate_order_key()
->validate_billing_email()
;
->validate_billing_email();
return $this;
}

public function handle_request(): Controller {
echo json_encode( $this->order->to_public_array() );
return $this;
}

}

0 comments on commit 83ea800

Please sign in to comment.