Function add_subscriptions_details_to_order
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function add_subscriptions_details_to_order( $order, $gateway ) {
if ( isset( $order->payment ) ) {
// defaults
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File class-sv-wc-payment-gateway-integration-subscriptions.php
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
SV_WC_Payment_Gateway_Integration_Subscriptions
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
class SV_WC_Payment_Gateway_Integration_Subscriptions extends SV_WC_Payment_Gateway_Integration {
/** @var string|float renewal payment total for Subs 2.0.x renewals */
Method add_support
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_support() {
$this->get_gateway()->add_support( array(
'subscriptions',
'subscription_suspension',
Function save_payment_meta
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function save_payment_meta( $order ) {
// a single order can contain multiple subscriptions
$subscriptions = wcs_get_subscriptions_for_order( $order, [
'order_type' => [ 'any' ],
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method add_subscriptions_details_to_order
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_subscriptions_details_to_order( $order, $gateway ) {
if ( isset( $order->payment ) ) {
// defaults
Function process_change_payment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function process_change_payment( $result, $order_id, $gateway ) {
// if this is not a subscription and not changing payment, bail for normal order processing
if ( ! wcs_is_subscription( $order_id ) || ! did_action( 'woocommerce_subscription_change_payment_method_via_pay_shortcode' ) ) {
return $result;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_payment_method_subscriptions_html
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function get_payment_method_subscriptions_html( $token ) {
$html = '';
// make sure the token belongs to this gateway
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function add_support
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function add_support() {
$this->get_gateway()->add_support( array(
'subscriptions',
'subscription_suspension',
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function remove_order_meta_from_change_payment
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function remove_order_meta_from_change_payment( $result, $subscription ) {
$subscription = is_numeric( $subscription ) ? wcs_get_subscription( $subscription ) : $subscription;
$updated_subscription = false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if ( $subscription instanceof \WC_Subscription ) {
$order->payment->subscriptions[] = $this->add_subscription_details_to_order( $subscription, false );
}
Function add_subscription_details_to_order
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function add_subscription_details_to_order( $subscription, $renewal ) {
$details = new \stdClass;
$details->id = max( 0, (int) $subscription->get_id() );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function maybe_force_tokenization
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function maybe_force_tokenization( $force_tokenization ) {
// pay page with subscription?
$pay_page_subscription = false;
if ( $this->get_gateway()->is_pay_page_gateway() ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if ( $subscription instanceof \WC_Subscription ) {
$order->payment->subscriptions[] = $this->add_subscription_details_to_order( $subscription, true );
}
Function add_my_payment_methods_table_header
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function add_my_payment_methods_table_header( $headers, $handler ) {
if ( isset( $headers['subscriptions'] ) ) {
return $headers;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function do_not_copy_order_meta
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function do_not_copy_order_meta( $order_meta ) {
$meta_keys = $this->get_order_specific_meta_keys();
foreach ( (array) $order_meta as $index => $meta ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_payment_token_subscriptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function get_payment_token_subscriptions( $user_id, $token ) {
$subscriptions = wcs_get_users_subscriptions( $user_id );
foreach ( $subscriptions as $key => $subscription ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"