File class-sv-wc-payment-gateway-direct.php
has 579 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
Function get_order
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function get_order( $order_id ) {
$order = parent::get_order( $order_id );
// payment info
- 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 process_payment
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function process_payment( $order_id ) {
parent::process_payment( $order_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 do_transaction
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
protected function do_transaction( $order ) {
// perform the credit card or check transaction
if ( $this->is_credit_card_gateway() ) {
$response = $this->do_credit_card_transaction( $order );
- 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 update_transaction_payment_method
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function update_transaction_payment_method( \WC_Order $order ) {
$token = $this->get_payment_tokens_handler()->get_token( $order->get_user_id(), $order->payment->token );
$address = new Addresses\Customer_Address();
$address->set_from_order( $order );
- 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 validate_check_fields
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function validate_check_fields( $is_valid ) {
$account_number = SV_WC_Helper::get_posted_value( 'wc-' . $this->get_id_dasherized() . '-account-number' );
$routing_number = SV_WC_Helper::get_posted_value( 'wc-' . $this->get_id_dasherized() . '-routing-number' );
- 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_credit_card_transaction
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function do_credit_card_transaction( $order, $response = null ) {
if ( is_null( $response ) ) {
if ( $this->perform_credit_card_charge( $order ) ) {
$response = $this->get_api()->credit_card_charge( $order );
- 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 validate_fields
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function validate_fields() {
$is_valid = parent::validate_fields();
if ( $this->supports_tokenization() ) {
- 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
SV_WC_Payment_Gateway_Direct
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
#[\AllowDynamicProperties]
abstract class SV_WC_Payment_Gateway_Direct extends SV_WC_Payment_Gateway {
/**
Consider simplifying this complex logical expression. Open
if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_12_4\\SV_WC_Payment_Gateway_Direct' ) ) :
/**
* # WooCommerce Payment Gateway Framework Direct Gateway
Function do_add_payment_method_transaction
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function do_add_payment_method_transaction( \WC_Order $order, SV_WC_Payment_Gateway_API_Create_Payment_Token_Response $response = null ) {
if ( is_null( $response ) ) {
$response = $this->get_api()->tokenize_payment_method( $order );
}
- 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 process_payment
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process_payment( $order_id ) {
parent::process_payment( $order_id );
/**
Method do_credit_card_transaction
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function do_credit_card_transaction( $order, $response = null ) {
if ( is_null( $response ) ) {
if ( $this->perform_credit_card_charge( $order ) ) {
$response = $this->get_api()->credit_card_charge( $order );
Method get_order
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_order( $order_id ) {
$order = parent::get_order( $order_id );
// payment info
Method get_order_for_add_payment_method
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_order_for_add_payment_method() {
// mock order, as all gateway API implementations require an order object for tokenization
$order = new \WC_Order( 0 );
$order = $this->get_order( $order );
Function validate_credit_card_account_number
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function validate_credit_card_account_number( $account_number ) {
$is_valid = true;
// validate card number
- 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 validate_check_fields
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validate_check_fields( $is_valid ) {
$account_number = SV_WC_Helper::get_posted_value( 'wc-' . $this->get_id_dasherized() . '-account-number' );
$routing_number = SV_WC_Helper::get_posted_value( 'wc-' . $this->get_id_dasherized() . '-routing-number' );
Method do_transaction
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function do_transaction( $order ) {
// perform the credit card or check transaction
if ( $this->is_credit_card_gateway() ) {
$response = $this->do_credit_card_transaction( $order );
Method do_add_payment_method_transaction
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function do_add_payment_method_transaction( \WC_Order $order, SV_WC_Payment_Gateway_API_Create_Payment_Token_Response $response = null ) {
if ( is_null( $response ) ) {
$response = $this->get_api()->tokenize_payment_method( $order );
}
Method update_transaction_payment_method
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function update_transaction_payment_method( \WC_Order $order ) {
$token = $this->get_payment_tokens_handler()->get_token( $order->get_user_id(), $order->payment->token );
$address = new Addresses\Customer_Address();
$address->set_from_order( $order );
Consider simplifying this complex logical expression. Open
if ( ! ctype_digit( $expiration_month ) || ! ctype_digit( $expiration_year ) ||
$expiration_month > 12 ||
$expiration_month < 1 ||
$expiration_year < $current_year ||
( $expiration_year == $current_year && $expiration_month < $current_month ) ||
Function do_check_transaction
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function do_check_transaction( $order, $response = null ) {
if ( is_null( $response ) ) {
$response = $this->get_api()->check_debit( $order );
}
- 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 validate_csc
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function validate_csc( $csc ) {
$is_valid = true;
// validate security code
- 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_notices_as_user_messages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function get_notices_as_user_messages( ?string $type = null ) : array {
if ( null == $type ) {
$type = $this->debug_checkout() ? '' : 'error';
}
- 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 validate_credit_card_expiration_date
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function validate_credit_card_expiration_date( $expiration_month, $expiration_year ) {
$is_valid = true;
if ( 2 === strlen( $expiration_year ) ) {
- 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 too many return
statements within this method. Open
return $is_valid;
Function add_add_payment_method_customer_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function add_add_payment_method_customer_data( $order, $response ) {
$user_id = $order->get_user_id();
// set customer ID from response if available
- 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"