Skip to content

Commit 58fbce7

Browse files
authored
fix: clean up unnecessary variables and ternaries (#766)
1 parent 4ed9cb9 commit 58fbce7

16 files changed

+21
-38
lines changed

includes/admin/class-general.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static function get_fields() {
7676
. ( defined( 'NO_QL_SESSION_HANDLER' ) ? __( ' This setting is disabled. The "NO_QL_SESSION_HANDLER" flag has been triggered with code', 'wp-graphql-woocommerce' ) : '' ),
7777
'type' => 'checkbox',
7878
'value' => defined( 'NO_QL_SESSION_HANDLER' ) ? 'on' : woographql_setting( 'disable_ql_session_handler', 'off' ),
79-
'disabled' => defined( 'NO_QL_SESSION_HANDLER' ) ? true : false,
79+
'disabled' => defined( 'NO_QL_SESSION_HANDLER' ),
8080
],
8181
[
8282
'name' => 'enable_unsupported_product_type',
@@ -101,7 +101,7 @@ public static function get_fields() {
101101
]
102102
),
103103
'value' => $enable_auth_urls_hardcoded ? $all_urls_checked : woographql_setting( 'enable_authorizing_url_fields', [] ),
104-
'disabled' => $enable_auth_urls_hardcoded ? true : false,
104+
'disabled' => $enable_auth_urls_hardcoded,
105105
'sanitize_callback' => static function( $value ) {
106106
if ( empty( $value ) ) {
107107
return [];

includes/connection/class-products.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public static function bypass_get_args_sanitization( $args, $connection_resolver
398398
* @return \WPGraphQL\Data\Connection\PostObjectConnectionResolver
399399
*/
400400
public static function set_ordering_query_args( $resolver, $args ) {
401-
$backward = isset( $args['last'] ) ? true : false;
401+
$backward = isset( $args['last'] );
402402

403403
if ( ! empty( $args['where']['orderby'] ) ) {
404404
$default_fields = [

includes/connection/class-wc-terms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function register_connections() {
4040
$wc_post_types = WP_GraphQL_WooCommerce::get_post_types();
4141

4242
// Loop through the allowed_taxonomies to register appropriate connections.
43-
foreach ( $allowed_taxonomies as $taxonomy => $tax_object ) {
43+
foreach ( $allowed_taxonomies as $tax_object ) {
4444
foreach ( $wc_post_types as $post_type ) {
4545
if ( 'product' === $post_type ) {
4646
continue;

includes/data/connection/class-cart-item-connection-resolver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ public function get_query() {
103103
* {@inheritDoc}
104104
*/
105105
public function get_ids_from_query() {
106-
$ids = ! empty( $this->query ) ? $this->query : [];
107-
108-
return $ids;
106+
return ! empty( $this->query ) ? $this->query : [];
109107
}
110108

111109
/**

includes/data/connection/class-downloadable-item-connection-resolver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,7 @@ public function get_query() {
140140
* @return array
141141
*/
142142
public function get_ids_from_query() {
143-
$ids = ! empty( $this->query ) ? $this->query : [];
144-
145-
return $ids;
143+
return ! empty( $this->query ) ? $this->query : [];
146144
}
147145

148146
/**

includes/data/connection/class-order-item-connection-resolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function get_query() {
9999
}//end switch
100100

101101
$items = [];
102-
foreach ( $this->source->get_items( $type ) as $id => $item ) {
102+
foreach ( $this->source->get_items( $type ) as $item ) {
103103
$items[] = $item;
104104
}
105105

includes/data/mutation/class-order-mutation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ protected static function get_order_item_keys( $type ) {
262262
* @param array $item_keys Order item keys.
263263
* @param string $type Order item type slug.
264264
*/
265-
$item_keys = apply_filters( 'woographql_get_order_item_keys', [], $type );
266-
return $item_keys;
265+
return apply_filters( 'woographql_get_order_item_keys', [], $type );
267266
}//end switch
268267
}
269268

includes/model/class-order.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ protected function owner_matches_current_user() {
299299
}
300300

301301
// If customer ID matches current user, return true.
302-
return absint( $customer_id ) === absint( $this->current_user->ID ) ? true : false;
302+
return absint( $customer_id ) === absint( $this->current_user->ID );
303303
}
304304

305305
/**
@@ -327,7 +327,7 @@ public function guest_order_customer_matches_current_user() {
327327
}
328328

329329
// If customer email matches current user, return true.
330-
return $customer_email === $session_customer->get_billing_email() ? true : false;
330+
return $customer_email === $session_customer->get_billing_email();
331331
}
332332

333333
/**
@@ -336,7 +336,7 @@ public function guest_order_customer_matches_current_user() {
336336
* @return bool
337337
*/
338338
public function is_private() {
339-
return wc_is_order_status( 'wc-' . $this->data->get_status() ) ? false : true;
339+
return ! wc_is_order_status( 'wc-' . $this->data->get_status() );
340340
}
341341

342342
/**

includes/mutation/class-cart-add-fee.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function register_mutation() {
4242
* @return array
4343
*/
4444
public static function get_input_fields() {
45-
$input_fields = [
45+
return [
4646
'name' => [
4747
'type' => [ 'non_null' => 'String' ],
4848
'description' => __( 'Unique name for the fee.', 'wp-graphql-woocommerce' ),
@@ -60,8 +60,6 @@ public static function get_input_fields() {
6060
'description' => __( 'The tax class for the fee if taxable.', 'wp-graphql-woocommerce' ),
6161
],
6262
];
63-
64-
return $input_fields;
6563
}
6664

6765
/**

includes/mutation/class-cart-add-item.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public static function get_output_fields() {
7676
'cartItem' => [
7777
'type' => 'CartItem',
7878
'resolve' => static function ( $payload ) {
79-
$item = \WC()->cart->get_cart_item( $payload['key'] );
80-
81-
return $item;
79+
return \WC()->cart->get_cart_item( $payload['key'] );
8280
},
8381
],
8482
'cart' => Cart_Mutation::get_cart_field( true ),

0 commit comments

Comments
 (0)