vindi/vindi-woocommerce

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

Summary

Maintainability
A
1 hr
Test Coverage

Method __construct has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
  {
    $this->id                   = 'vindi-bank-slip';
    $this->icon                 = apply_filters('vindi_woocommerce_bank_slip_icon', '');
    $this->method_title         = __('Vindi - Boleto Bancário', VINDI);
Severity: Minor
Found in src/includes/gateways/BankSlipPayment.php - About 1 hr to fix

    Avoid assigning values to variables in if clauses and the like (line '127', column '9').
    Open

      public function payment_fields()
      {
        $user_country = $this->get_country_code();
    
        if (empty($user_country)) {

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    The property $vindi_settings is not named in camelCase.
    Open

    class VindiBankSlipGateway 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 18 and the first side effect is on line 6.
    Open

    <?php

    Function closing brace must go on the next line following the body; found 1 blank lines before brace
    Open

      }

    Inline control structures are not allowed
    Open

        if ($is_trial = $this->vindi_settings->get_is_active_sandbox())

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

          'subscription_payment_method_change',

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

        $this->init_form_fields();

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

      {

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

          'subscription_cancellation',

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

          'subscription_reactivation',

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

          'subscription_payment_method_change_customer',

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        if (empty($user_country)) {

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

      {

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

        $this->has_fields           = true;

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

        add_action('woocommerce_view_order', array(&$this, 'show_bank_slip_download'), -10, 1);

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

        add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page'));

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

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

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        if (!$this->routes->acceptBankSlip()) {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)

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

        $this->id                   = 'vindi-bank-slip';

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

          return;

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

          'products',

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

          'subscription_date_changes',

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

          'title'           => array(

    Line indented incorrectly; expected at least 4 spaces, found 2
    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->supports             = array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public $controllers;

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

          'multiple_subscriptions',

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function type()

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

          'enabled'         => array(

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

        );

    Line indented incorrectly; expected 8 spaces, found 6
    Open

          if ($order->get_payment_method() == 'vindi-bank-slip') {

    Line indented incorrectly; expected 8 spaces, found 6
    Open

          }

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

      exit;

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

          'subscription_payment_method_change_admin',

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

        return 'bank_slip';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function init_form_fields()

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

          $order = wc_get_order($order_id);

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

        );

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

      {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function payment_fields()

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

        $is_single_order = $this->is_single_order();

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

          $is_trial = $this->routes->isMerchantStatusTrialOrSandbox();

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

        $this->method_description   = __('Aceitar pagamentos via boleto bancário utilizando a Vindi.', VINDI);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

      {

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

        $this->form_fields = array(

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Line indented incorrectly; expected 8 spaces, found 4
    Open

        }

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

          'subscription_suspension',

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

          'subscription_amount_changes',

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

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

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

          ),

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

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

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

          _e('Selecione o País para visualizar as formas de pagamento.', VINDI);

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

          'subscriptions',

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

          'pre-orders'

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

          )

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

          _e('Este método de pagamento não é aceito.', VINDI);

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

        $this->init_settings();

    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

        if ($is_trial = $this->vindi_settings->get_is_active_sandbox())

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function thank_you_page($order_id)

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

                );

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public $vindi_settings;

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

        $this->method_title         = __('Vindi - Boleto Bancário', VINDI);

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

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

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

        $user_country = $this->get_country_code();

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

        $this->vindi_settings->get_template('bankslip-checkout.html.php', compact('is_trial', 'is_single_order'));

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    There are no issues that match your filters.

    Category
    Status