Method init_form_fields
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
Method __construct
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
{
global $woocommerce;
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;
- Read upRead up
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;
- Read upRead up
- Exclude checks
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 '$index'. Open
foreach ($cart->get_fees() as $index => $fee) {
- Read upRead up
- Exclude checks
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 $enable_interest_rate is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
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
*/
- Read upRead up
- Exclude checks
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
*/
- Read upRead up
- Exclude checks
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
*/
- Read upRead up
- Exclude checks
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 $verify_method is not named in camelCase. Open
class VindiCreditGateway extends VindiPaymentGateway
{
/**
* @var VindiSettings
*/
- Read upRead up
- Exclude checks
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
*/
- Read upRead up
- Exclude checks
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 8. Open
<?php
- Exclude checks
Inline control structures are not allowed Open
if ($this->is_single_order())
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
'description' => __('Número máximo de parcelas para vendas avulsas. Deixe em 1x para desativar o parcelamento.', VINDI),
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$user_payment_profile['card_number'] = sprintf('**** **** **** %s', $payment_profile['card_number_last_four']);
- Exclude checks
Inline control structures are not allowed Open
if ($installments != 0)
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
'description' => __(' Realiza a transação de verificação em todos os novos pedidos. (Taxas adicionais por verificação poderão ser cobradas).', VINDI),
- Exclude checks
Inline control structures are not allowed Open
else
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->form_fields = array(
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 12 Open
$installments = $plan['installments'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->has_fields = true;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
parent::__construct($vindi_settings, $controllers);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$installments = 0;
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 10 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->supports = array(
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->init_form_fields();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->enable_interest_rate = $this->get_option('enable_interest_rate');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->vindi_settings->get_template('creditcard-checkout.html.php', compact(
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return 1 === $old_payment_profile;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
$order_max_times = floor($order_total / $this->smallest_installment);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
foreach ($this->vindi_settings->woocommerce->cart->cart_contents as $item) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
if ($installments != 0)
- Exclude checks
Expected 1 space after ELSE keyword; newline found Open
else
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
global $woocommerce;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
return;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
return min($this->max_installments, $max_times, $this->get_installments());
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$user_payment_profile['payment_company'] = $payment_profile['payment_company']['code'];
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$user_payment_profile['card_number'] = sprintf('**** **** **** %s', $payment_profile['card_number_last_four']);
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 12 Open
$installments = $plan['installments'];
- Exclude checks
Multi-line function call not indented correctly; expected 10 spaces but found 8 Open
'vindi-old-cc-data-check',
- Exclude checks
Multi-line function call not indented correctly; expected 10 spaces but found 8 Open
FILTER_SANITIZE_NUMBER_INT
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 10 Open
$plan = $this->routes->getPlan($plan_id);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
exit;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->id = 'vindi-credit-card';
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->init_settings();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
$plan_id = $item['data']->get_meta('vindi_plan_id');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->method_title = __('Vindi - Cartão de Crédito', VINDI);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->method_description = __('Aceitar pagamentos via cartão de crédito utilizando a Vindi.', VINDI);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
));
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return 'yes' === $this->verify_method;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$payment_profile = $this->routes->getPaymentProfile($user_vindi_id);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
return $user_payment_profile;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
if ($this->is_single_order())
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->icon = apply_filters('vindi_woocommerce_credit_card_icon', '');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->installments = $this->get_option('installments');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->interest_rate = $this->get_option('interest_rate');
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 8 Open
if (!empty($plan_id)) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
$max_times = empty($order_max_times) ? 1 : $order_max_times;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 10 Open
$user_payment_profile['holder_name'] = $payment_profile['holder_name'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->smallest_installment = $this->get_option('smallest_installment');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->verify_method = $this->get_option('verify_method');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return 'cc';
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return floatval($this->interest_rate);
- Exclude checks
Multi-line function call not indented correctly; expected 10 spaces but found 8 Open
INPUT_POST,
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return 'yes' === $this->enable_interest_rate;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
return $this->get_installments();
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 10 Open
} elseif ($plan['installments'] < $installments) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
else
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$old_payment_profile = (int) filter_input(
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
if ($this->is_single_order()) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 10 Open
if ($installments == 0) {
- Exclude checks