vindi/vindi-woocommerce

View on GitHub
src/utils/PaymentProcessor.php

Summary

Maintainability
F
5 days
Test Coverage

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

installments accesses the super-global variable $_POST.
Open

    protected function installments()
    {
        if (
            'credit_card' == $this->payment_method_code() &&
            isset($_POST['vindi_cc_installments'])
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

installments accesses the super-global variable $_POST.
Open

    protected function installments()
    {
        if (
            'credit_card' == $this->payment_method_code() &&
            isset($_POST['vindi_cc_installments'])
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

get_cc_payment_type accesses the super-global variable $_POST.
Open

    public function get_cc_payment_type($customer_id)
    {
        if ($this->gateway->verify_user_payment_profile()) {
            return false;
        }
Severity: Minor
Found in src/utils/PaymentProcessor.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

File PaymentProcessor.php has 949 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace VindiPaymentGateways;

use DateTime;
Severity: Major
Found in src/utils/PaymentProcessor.php - About 2 days to fix

    VindiPaymentProcessor has 62 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class VindiPaymentProcessor
    {
        /**
         * Order type is invalid.
         */
    Severity: Major
    Found in src/utils/PaymentProcessor.php - About 1 day to fix

      Function process_order has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process_order()
          {
              $this->check_trial_and_single_product();
              $customer = $this->get_customer();
              $order_items = $this->order->get_items();
      Severity: Minor
      Found in src/utils/PaymentProcessor.php - About 3 hrs to fix

      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

      The class VindiPaymentProcessor has 45 non-getter- and setter-methods. Consider refactoring VindiPaymentProcessor to keep number of methods under 25.
      Open

      class VindiPaymentProcessor
      {
          /**
           * Order type is invalid.
           */
      Severity: Minor
      Found in src/utils/PaymentProcessor.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      The class VindiPaymentProcessor has an overall complexity of 234 which is very high. The configured complexity threshold is 50.
      Open

      class VindiPaymentProcessor
      {
          /**
           * Order type is invalid.
           */
      Severity: Minor
      Found in src/utils/PaymentProcessor.php by phpmd

      Method process_order has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function process_order()
          {
              $this->check_trial_and_single_product();
              $customer = $this->get_customer();
              $order_items = $this->order->get_items();
      Severity: Major
      Found in src/utils/PaymentProcessor.php - About 3 hrs to fix

        Function build_tax_item has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function build_tax_item($order_items)
            {
        
                $total_tax = 0;
                $taxItem = [];
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 1 hr to fix

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

            public function order_has_trial_and_simple_product()
            {
                $has_trial = false;
                $has_simple_product = false;
                $order_items = $this->order->get_items();
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 1 hr to fix

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

            protected function build_sign_up_fee_item($order_items)
            {
                foreach ($order_items as $order_item) {
                    if (!is_object($order_item) || !method_exists($order_item, 'get_product')) {
                        continue;
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 45 mins to fix

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

            private function get_cycle_from_product_type($item)
            {
                $cycles = null;
                $product = is_object($item) && method_exists($item, 'get_product') ? $item->get_product() : false;
        
        
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 45 mins to fix

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

            public function get_plan_from_order_item($order_item)
            {
                $product = $order_item->get_product();
        
                if (isset($order_item['variation_id']) && $order_item['variation_id'] != 0) {
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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

            protected function build_product_items_for_subscription($order_item)
            {
                $plan_cycles = $this->get_cycle_from_product_type($order_item);
                $product_item = array(
                    'product_id' => $order_item['vindi_id'],
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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

            protected function build_shipping_item($order_items)
            {
                $shipping_item = [];
                $shipping_method = $this->order->get_shipping_method();
                $get_total_shipping = $this->order->get_shipping_total();
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 35 mins to fix

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

            protected function get_product($order_item)
            {
        
                $product = $order_item->get_product();
                $product_id = $order_item->get_id();
        Severity: Minor
        Found in src/utils/PaymentProcessor.php - About 35 mins to fix

        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 $cycles > 0 ? $cycles : null;
        Severity: Major
        Found in src/utils/PaymentProcessor.php - About 30 mins to fix

          Function coupon_supports_product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function coupon_supports_product($order_item, $coupon)
              {
                  $product_id = $order_item->get_product()->get_id();
                  $included_products = $coupon->get_product_ids();
                  $excluded_products = $coupon->get_excluded_product_ids();
          Severity: Minor
          Found in src/utils/PaymentProcessor.php - About 25 mins to fix

          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

          The class VindiPaymentProcessor has 1495 lines of code. Current threshold is 1000. Avoid really long classes.
          Open

          class VindiPaymentProcessor
          {
              /**
               * Order type is invalid.
               */
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          The method process_order() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
          Open

              public function process_order()
              {
                  $this->check_trial_and_single_product();
                  $customer = $this->get_customer();
                  $order_items = $this->order->get_items();
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          The method get_cycle_from_product_type() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
          Open

              private function get_cycle_from_product_type($item)
              {
                  $cycles = null;
                  $product = is_object($item) && method_exists($item, 'get_product') ? $item->get_product() : false;
          
          
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          The method abort has a boolean flag argument $throw_exception, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function abort($message, $throw_exception = false)
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          The method get_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $vindi_product = $this->controllers->plans->create($product_id, '', '', true);
                      }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'.
          Open

                  $matching_item = VindiHelpers::get_matching_subscription_item($subscription, $order_item);
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          The method order_has_trial_and_simple_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $has_simple_product = true;
                          if ($has_trial) {
                              return true;
                          }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          The method get_plan_from_order_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $vindi_plan = get_post_meta($product->get_id(), 'vindi_plan_id', true);
                  }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          The method add_additional_items uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $order_items[] = $this->build_product_from_order_item($order_type, $product);
                  }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'build_shipping_item'.
          Open

                      $wc_subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'.
          Open

                  $subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          The method build_product_from_order_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $order_items['price'] = (float) $order_items['subtotal'] / $order_items['qty'];
                  }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          The method build_tax_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                              } else {
                                  $total_tax += (float) ($order_item->get_total_tax());
                              }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          Avoid using static access to class '\WC_Subscriptions_Product' in method 'subscription_has_trial'.
          Open

                  return $this->is_subscription_type($product) && class_exists('WC_Subscriptions_Product') && WC_Subscriptions_Product::get_trial_length($product->get_id()) > 0;
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          The method build_tax_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          !empty($order_item['type']) && $total_tax += ($order_item['type'] === 'shipping' ? (float) $this->order->get_shipping_tax() : (float) $order_item->get_total_tax());
                      }
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          Avoid unused parameters such as '$order_items'.
          Open

              protected function build_interest_rate_item($order_items)
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          UnusedFormalParameter

          Since: 0.2

          Avoid passing parameters to methods or constructors and then not using those parameters.

          Example

          class Foo
          {
              private function bar($howdy)
              {
                  // $howdy is not used
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

          Avoid unused local variables such as '$index'.
          Open

                  foreach ($cart->get_fees() as $index => $fee) {
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

          Avoid unused local variables such as '$orderType'.
          Open

                  switch ($orderType = $this->get_order_type()) {
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

          The property $vindi_settings is not named in camelCase.
          Open

          class VindiPaymentProcessor
          {
              /**
               * Order type is invalid.
               */
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          The property $single_freight is not named in camelCase.
          Open

          class VindiPaymentProcessor
          {
              /**
               * Order type is invalid.
               */
          Severity: Minor
          Found in src/utils/PaymentProcessor.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          Blank line found at start of control structure
          Open

                      if ($sign_up_fee != null && $sign_up_fee > 0) {

          The DEFAULT body must start on the line following the statement
          Open

                      default:

          The CASE body must start on the line following the statement
          Open

                      case static::ORDER_TYPE_SUBSCRIPTION:

          Line exceeds 120 characters; contains 130 characters
          Open

                          $this->abort(__('Falha ao registrar o método de pagamento. Verifique os dados e tente novamente.', VINDI), true);

          Inline control structures are not allowed
          Open

                      if (empty($subscription_order_item))

          Line exceeds 120 characters; contains 167 characters
          Open

                  return $this->is_subscription_type($product) && class_exists('WC_Subscriptions_Product') && WC_Subscriptions_Product::get_trial_length($product->get_id()) > 0;

          Line exceeds 120 characters; contains 140 characters
          Open

              public function __construct(WC_Order $order, VindiPaymentGateway $gateway, VindiSettings $vindi_settings, VindiControllers $controllers)

          Line exceeds 120 characters; contains 145 characters
          Open

                          return $this->abort(__('Falha ao processar carrinho de compras. Verifique os itens escolhidos e tente novamente.', VINDI), true);

          Line exceeds 120 characters; contains 121 characters
          Open

               * @param WC_Order_Item_Product|WC_Order_Item_Product[] $order_items. Subscriptions will pass only one order_item and

          Line exceeds 120 characters; contains 122 characters
          Open

                      'tax' == $order_item['type'] || 'interest_rate' == $order_item['type'] || 'sign_up_fee' == $order_item['type']

          Line exceeds 120 characters; contains 169 characters
          Open

               * @param WC_Order_Item_Product|WC_Order_Item_Product[] $product The product to be built. If the order type is 'bill' this will be an array of WC_Order_Item_Product,

          Line exceeds 120 characters; contains 128 characters
          Open

                  if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($this->order, array('any'))) {

          Line exceeds 120 characters; contains 149 characters
          Open

                      return $this->abort(__('Falha ao recuperar informações sobre o produto na Vindi. Verifique os dados e tente novamente.', VINDI), true);

          Inline control structures are not allowed
          Open

                  if ($product->id === null) $product->id = 63;

          Line exceeds 120 characters; contains 126 characters
          Open

                      $this->abort(__('Falha ao registrar o método de pagamento. Verifique os dados e tente novamente.', VINDI), true);

          Line exceeds 120 characters; contains 180 characters
          Open

                          !empty($order_item['type']) && $total_tax += ($order_item['type'] === 'shipping' ? (float) $this->order->get_shipping_tax() : (float) $order_item->get_total_tax());

          Line exceeds 120 characters; contains 182 characters
          Open

                      'card_expiration' => filter_var($_POST['vindi_cc_monthexpiry'], FILTER_SANITIZE_NUMBER_INT) . '/' . filter_var($_POST['vindi_cc_yearexpiry'], FILTER_SANITIZE_NUMBER_INT),

          Expected 0 spaces after opening bracket; newline found
          Open

                  if (

          Expected 0 spaces after opening bracket; newline found
          Open

                  if (

          Expected 0 spaces after opening bracket; newline found
          Open

                      if (

          There are no issues that match your filters.

          Category
          Status