skyverge/wc-plugin-framework

View on GitHub
woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php

Summary

Maintainability
D
2 days
Test Coverage

File class-sv-wc-payment-gateway-apple-pay.php has 365 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_Apple_Pay has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[\AllowDynamicProperties]
    class SV_WC_Payment_Gateway_Apple_Pay extends Payment_Gateway\External_Checkout\External_Checkout {
    
    
        /** @var SV_WC_Payment_Gateway_Apple_Pay_Admin the admin instance */

      Function get_product_payment_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_product_payment_request( \WC_Product $product, $in_cart = false ) {
      
              if ( ! is_user_logged_in() ) {
                  WC()->session->set_customer_session_cookie( true );
              }

      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 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process_payment() {
      
              $order = null;
      
              try {

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

          public function build_payment_request_lines( $totals ) {
      
              $totals = wp_parse_args( $totals, array(
                  'subtotal' => 0.00,
                  'discount' => 0.00,

        Method build_payment_request has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function build_payment_request( $amount, $args = [] ) {
        
                $args = wp_parse_args( $args, array(
                    'currency_code'         => get_woocommerce_currency(),
                    'country_code'          => get_option( 'woocommerce_default_country' ),

          Method process_payment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function process_payment() {
          
                  $order = null;
          
                  try {

            Function recalculate_totals has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function recalculate_totals() {
            
                    $payment_request = $this->get_stored_payment_request();
            
                    if ( empty( $payment_request ) ){

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

                public function recalculate_totals() {
            
                    $payment_request = $this->get_stored_payment_request();
            
                    if ( empty( $payment_request ) ){

              Function build_payment_request_lines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function build_payment_request_lines( $totals ) {
              
                      $totals = wp_parse_args( $totals, array(
                          'subtotal' => 0.00,
                          'discount' => 0.00,

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

                  public function get_product_payment_request( \WC_Product $product, $in_cart = false ) {
              
                      if ( ! is_user_logged_in() ) {
                          WC()->session->set_customer_session_cookie( true );
                      }

                Function update_customer_addresses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function update_customer_addresses( $user_id, SV_WC_Payment_Gateway_Apple_Pay_Payment_Response $payment_response ) {
                
                        foreach ( $payment_response->get_billing_address() as $key => $value ) {
                            update_user_meta( $user_id, 'billing_' . $key, $value );
                        }

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

                    public function get_cart_payment_request( \WC_Cart $cart ) {
                
                        if ( $this->get_plugin()->is_subscriptions_active() && \WC_Subscriptions_Cart::cart_contains_subscription() ) {
                            throw new SV_WC_Payment_Gateway_Exception( 'Cart contains subscriptions.' );
                        }

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

                    public function build_payment_request( $amount, $args = [] ) {
                
                        $args = wp_parse_args( $args, array(
                            'currency_code'         => get_woocommerce_currency(),
                            'country_code'          => get_option( 'woocommerce_default_country' ),

                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