vindi/vindi-woocommerce

View on GitHub
src/includes/gateways/CreditPayment.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    protected function get_installments()
    {
      if ($this->is_single_order())
        return $this->installments;
      $installments = 0;
Severity: Minor
Found in src/includes/gateways/CreditPayment.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

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

    global $woocommerce;

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 $verify_method is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

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 $enable_interest_rate is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

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 $max_installments is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

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 $interest_rate is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

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 $vindi_settings is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

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 $smallest_installment is not named in camelCase.
Open

class VindiCreditGateway extends VindiPaymentGateway
{
  /**
   * @var VindiSettings
   */

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 20 and the first side effect is on line 10.
Open

<?php

Inline control structures are not allowed
Open

      if ($this->is_single_order())

Line exceeds 120 characters; contains 127 characters
Open

            $user_payment_profile['card_number']     = sprintf('**** **** **** %s', $payment_profile['card_number_last_four']);

Inline control structures are not allowed
Open

      if ($installments != 0)

Inline control structures are not allowed
Open

      else

Line indented incorrectly; expected 8 spaces, found 6
Open

      else

Expected 1 space after ELSE keyword; newline found
Open

      else

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->method_title         = __('Vindi - Cartão de Crédito', VINDI);

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->verify_method = $this->get_option('verify_method');

Line indented incorrectly; expected at least 12 spaces, found 10
Open

          $plan_id = $item['data']->get_meta('vindi_plan_id');

Line indented incorrectly; expected 8 spaces, found 6
Open

      }

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->method_description   = __('Aceitar pagamentos via cartão de crédito utilizando a Vindi.', VINDI);

Line indented incorrectly; expected 16 spaces, found 10
Open

          if ($installments == 0) {

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      if ($installments != 0)

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    global $woocommerce;

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      if ($this->is_single_order())

Line indented incorrectly; expected at least 20 spaces, found 14
Open

              $installments = $plan['installments'];

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->smallest_installment = $this->get_option('smallest_installment');

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->enable_interest_rate = $this->get_option('enable_interest_rate');

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->interest_rate = $this->get_option('interest_rate');

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    return 'cc';

Line indented incorrectly; expected at least 20 spaces, found 14
Open

              $installments = $plan['installments'];

Line indented incorrectly; expected at least 4 spaces, found 2
Open

  exit;

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->id                   = 'vindi-credit-card';

Line indented incorrectly; expected 8 spaces, found 6
Open

      foreach ($this->vindi_settings->woocommerce->cart->cart_contents as $item) {

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->init_settings();

Line indented incorrectly; expected at least 8 spaces, found 6
Open

      $installments = 0;

Line indented incorrectly; expected 16 spaces, found 10
Open

          } elseif ($plan['installments'] < $installments) {

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->icon                 = apply_filters('vindi_woocommerce_credit_card_icon', '');

Line indented incorrectly; expected 12 spaces, found 8
Open

        if (!empty($plan_id)) {

Line indented incorrectly; expected 12 spaces, found 8
Open

        }

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    );

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->installments = $this->get_option('installments');

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    ));

Line indented incorrectly; expected at least 16 spaces, found 12
Open

            $plan = $this->routes->getPlan($plan_id);

Line indented incorrectly; expected 16 spaces, found 10
Open

          }

Line indented incorrectly; expected at least 12 spaces, found 6
Open

      return;

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->init_form_fields();

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    parent::__construct($vindi_settings, $controllers);

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->vindi_settings->get_template('creditcard-checkout.html.php', compact(

Line indented incorrectly; expected at least 8 spaces, found 4
Open

    $this->has_fields           = true;

There are no issues that match your filters.

Category
Status