src/includes/gateways/BankSlipPayment.php
Method __construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Avoid assigning values to variables in if clauses and the like (line '127', column '9'). Open
Open
public function payment_fields()
{
$user_country = $this->get_country_code();
if (empty($user_country)) {
- Read upRead up
- Exclude checks
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
Open
class VindiBankSlipGateway 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 18 and the first side effect is on line 6. Open
Open
<?php
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
Open
}
- Exclude checks
Inline control structures are not allowed Open
Open
if ($is_trial = $this->vindi_settings->get_is_active_sandbox())
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_payment_method_change',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->init_form_fields();
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_cancellation',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_reactivation',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_payment_method_change_customer',
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
if (empty($user_country)) {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->has_fields = true;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
add_action('woocommerce_view_order', array(&$this, 'show_bank_slip_download'), -10, 1);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
add_action('woocommerce_thankyou_' . $this->id, array(&$this, 'thank_you_page'));
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->enabled = $this->get_option('enabled');
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
if (!$this->routes->acceptBankSlip()) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->id = 'vindi-bank-slip';
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
return;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'products',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_date_changes',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'title' => array(
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
{
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
return;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->supports = array(
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public $controllers;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'multiple_subscriptions',
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function type()
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'enabled' => array(
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
Open
if ($order->get_payment_method() == 'vindi-bank-slip') {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 6 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
exit;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_payment_method_change_admin',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
return 'bank_slip';
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function init_form_fields()
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$order = wc_get_order($order_id);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
{
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function payment_fields()
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$is_single_order = $this->is_single_order();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
$is_trial = $this->routes->isMerchantStatusTrialOrSandbox();
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->method_description = __('Aceitar pagamentos via boleto bancário utilizando a Vindi.', VINDI);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->form_fields = array(
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_suspension',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscription_amount_changes',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->title = $this->get_option('title');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
),
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->icon = apply_filters('vindi_woocommerce_bank_slip_icon', '');
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
_e('Selecione o País para visualizar as formas de pagamento.', VINDI);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'subscriptions',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
'pre-orders'
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
Open
)
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
_e('Este método de pagamento não é aceito.', VINDI);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->init_settings();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
parent::__construct($vindi_settings, $controllers);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
if ($is_trial = $this->vindi_settings->get_is_active_sandbox())
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function thank_you_page($order_id)
- Exclude checks
Line indented incorrectly; expected at least 14 spaces, found 12 Open
Open
);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public $vindi_settings;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->method_title = __('Vindi - Boleto Bancário', VINDI);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->description = $this->get_option('description');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$user_country = $this->get_country_code();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->vindi_settings->get_template('bankslip-checkout.html.php', compact('is_trial', 'is_single_order'));
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks