skyverge/wc-plugin-framework

View on GitHub
woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php

Summary

Maintainability
C
1 day
Test Coverage

SV_WC_Payment_Gateway_Payment_Token has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

#[\AllowDynamicProperties]
class SV_WC_Payment_Gateway_Payment_Token {


    /** @var string payment gateway token ID */

    Function save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function save() {
    
            $token = $this->get_woocommerce_payment_token();
    
            if ( ! $token instanceof \WC_Payment_Token ) {

    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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct( $id, $data ) {
    
            if ( $data instanceof \WC_Payment_Token ) {
    
                $this->token = $data;

    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_woocommerce_payment_token has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function get_woocommerce_payment_token() {
    
            if ( ! $this->token instanceof \WC_Payment_Token && $this->get_user_id() && $this->get_gateway_id() ) {
    
                // see if there is already a token with this ID saved for this customer and gateway

    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 save has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function save() {
    
            $token = $this->get_woocommerce_payment_token();
    
            if ( ! $token instanceof \WC_Payment_Token ) {

      Function read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function read( \WC_Payment_Token $core_token ) {
      
              $token_data = $core_token->get_data();
              $meta_data  = $token_data['meta_data'] ?: [];
      
      

      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

      There are no issues that match your filters.

      Category
      Status