get_country_code accesses the super-global variable $_GET. Open
public function get_country_code()
{
if (isset($_GET['order_id'])) {
$order = new WC_Order(filter_var($_GET['order_id'], FILTER_SANITIZE_NUMBER_INT));
return $order->billing_country;
- Read upRead up
- Exclude checks
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_country_code accesses the super-global variable $_GET. Open
public function get_country_code()
{
if (isset($_GET['order_id'])) {
$order = new WC_Order(filter_var($_GET['order_id'], FILTER_SANITIZE_NUMBER_INT));
return $order->billing_country;
- Read upRead up
- Exclude checks
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
Method get_level3_data_from_order
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_level3_data_from_order($order)
{
// WC Versions before 3.0 don't support postcodes and are
// incompatible with level3 data.
if (VindiHelpers::is_wc_lt('3.0')) {
Method process_refund
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process_refund($order_id, $amount = null, $reason = '') {
$order_id = filter_var($order_id, FILTER_SANITIZE_NUMBER_INT);
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
$reason = sanitize_text_field($reason);
$order = wc_get_order($order_id);
Function process_refund
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process_refund($order_id, $amount = null, $reason = '') {
$order_id = filter_var($order_id, FILTER_SANITIZE_NUMBER_INT);
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
$reason = sanitize_text_field($reason);
$order = wc_get_order($order_id);
- 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 '$key'. Open
foreach ($order_meta as $key => $order_item) {
- 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 '$results'. Open
$results = [];
- 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 using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_level3_data_from_order'. Open
$discount_amount = VindiHelpers::get_vindi_amount($item->get_subtotal() - $item->get_total(), $currency);
- Read upRead up
- Exclude checks
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_level3_data_from_order'. Open
if (VindiHelpers::is_wc_lt('3.0')) {
- Read upRead up
- Exclude checks
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_level3_data_from_order'. Open
$unit_cost = VindiHelpers::get_vindi_amount(($item->get_subtotal() / $quantity), $currency);
- Read upRead up
- Exclude checks
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_level3_data_from_order'. Open
$tax_amount = VindiHelpers::get_vindi_amount($item->get_total_tax(), $currency);
- Read upRead up
- Exclude checks
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_level3_data_from_order'. Open
'shipping_amount' => VindiHelpers::get_vindi_amount($order->get_shipping_total() + $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
- Read upRead up
- Exclude checks
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 property $vindi_settings is not named in camelCase. Open
abstract class VindiPaymentGateway extends WC_Payment_Gateway_CC
{
/**
* @var bool
*/
- 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 24 and the first side effect is on line 11. Open
<?php
- Exclude checks
The abstract declaration must precede the visibility declaration Open
public abstract function type();
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Blank line found at start of control structure Open
if ($this->is_valid_br_zip_code($shipping_address_zip)) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!is_null($amount) ) {
- Exclude checks
Closing class brace must be on a line by itself Open
};
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
'tax_amount' => $tax_amount, // The amount of tax this item had added to it, in cents, as a non-negative integer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
'discount_amount' => $discount_amount, // The amount an item was discounted—if there was a sale,for example, as a non-negative integer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request['amount'] = substr($amount, 0, strlen($amount)-2) . "." . substr($amount, -2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get refund request args.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function refund_transaction($bill_id, $amount = null, $reason = '') {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return apply_filters('vindi_refund_request', $request, $bill_id, $request['amount'], $reason);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $amount Refund amount.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $reason Refund reason.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function get_refund_request($bill_id, $amount = null, $reason = '') {
- Exclude checks
Line exceeds 120 characters; contains 209 characters Open
'merchant_reference' => $order->get_id(), // An alphanumeric string of up to characters in length. This unique value is assigned by the merchant to identify the order. Also known as an “Order ID”.
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
return $payment->abort(__('O Pagamento foi cancelado devido a erro de configuração do meio de pagamento.', VINDI));
- Exclude checks
Line exceeds 120 characters; contains 157 characters Open
return new WP_Error('error', __('Não é possível realizar reembolsos parciais, faça um reembolso manual caso você opte por esta opção.', VINDI));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $bill_id Order object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return object Either an object of name value pairs for a success, or a WP_ERROR object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $bill_id Order object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $refund['last_transaction'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = array(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!is_null($amount) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($refund)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $amount Refund amount.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Refund an order via PayPal.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $reason Refund reason.
- 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 4 Open
$this->vindi_settings = $vindi_settings;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->routes = $vindi_settings->routes;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
protected $validated = true;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public $vindi_settings;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'tax_amount' => $tax_amount, // The amount of tax this item had added to it, in cents, as a non-negative integer.
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->controllers = $controllers;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function get_level3_data_from_order($order)
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'unit_cost' => $unit_cost, // Cost of the product, in cents, as a non-negative integer.
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$level3_data['shipping_from_zip'] = $store_postcode;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
$this->vindi_settings->get_template('admin-gateway-settings.html.php', array('gateway' => $this));
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$currency = get_option('woocommerce_currency');
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
try {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public $controllers;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->enabled = $this->get_option('enabled');
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$order_items = array_values($order->get_items());
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$product_description = substr($item->get_name(), 0, 26);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$vindi_line_items = array_map(function ($item) use ($currency) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'product_description' => $product_description, // Up to 26 characters long describing the product.
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return in_array($currency, ['BRL']) && ! empty($api_key);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$payment = new VindiPaymentProcessor($order, $this, $this->vindi_settings, $this->controllers);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return $payment->abort(__('O Pagamento foi cancelado devido a erro de configuração do meio de pagamento.', VINDI));
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$order->reduce_order_stock();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$currency = $order->get_currency();
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function is_valid_br_zip_code($zip)
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function get_country_code()
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$response = $payment->process();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
: $item->get_product_id();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'discount_amount' => $discount_amount, // The amount an item was discounted—if there was a sale,for example, as a non-negative integer.
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->logger->log(sprintf('Processando pedido %s.', $order_id));
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (! $this->validate_settings()) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (VindiHelpers::is_wc_lt('3.0')) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return array();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return (object) array(
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}, $order_items);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$store_postcode = get_option('woocommerce_store_postcode');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$order = wc_get_order($order_id);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (isset($_GET['order_id'])) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function process_payment($order_id)
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'result' => 'fail',
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 12 Open
sprintf(__('[Transação #%2$s]: reembolsado R$%1$s', VINDI), $result['amount'], $result['id'])
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public abstract function type();
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->logger = $this->vindi_settings->logger;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$quantity = $item->get_quantity();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$unit_cost = VindiHelpers::get_vindi_amount(($item->get_subtotal() / $quantity), $currency);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$order_id = filter_var($order_id, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (! $this->validated) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
case 'success':
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 10 Open
$order->add_order_note(
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private function find_bill_last_charge($bill_id)
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
protected $routes;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (is_admin()) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$product_id = $item->get_variation_id()
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$tax_amount = VindiHelpers::get_vindi_amount($item->get_total_tax(), $currency);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function admin_options()
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function validate_settings()
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
? $item->get_variation_id()
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$reason = sanitize_text_field($reason);
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 8 Open
throw new Exception($result->errors[0]->message);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $level3_data;
- Exclude checks
Opening brace should be on a new line Open
public function refund_transaction($bill_id, $amount = null, $reason = '') {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return end($charges);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$reason = sanitize_text_field($reason);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$charge_id = $last_charge['id'];
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function __construct(VindiSettings $vindi_settings, VindiControllers $controllers)
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->title = $this->get_option('title');
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if ($this->is_valid_br_zip_code($store_postcode)) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$order = new WC_Order(filter_var($_GET['order_id'], FILTER_SANITIZE_NUMBER_INT));
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$result = $this->refund_transaction($bill_id, $amount, $reason);
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
if(isset($result->errors)) {
- Exclude checks
Opening brace should be on a new line Open
public function get_refund_request($bill_id, $amount = null, $reason = '') {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$bill_id = filter_var($bill_id, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$bill_id = filter_var($bill_id, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$last_charge = $this->find_bill_last_charge($bill_id);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return $this->vindi_settings->woocommerce->customer->get_billing_country();
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
protected function is_single_order()
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$bill_id = $order_item['bill']['id'];
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(isset($result->errors)) {
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 8 Open
return false;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$discount_amount = VindiHelpers::get_vindi_amount($item->get_subtotal() - $item->get_total(), $currency);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$shipping_address_zip = $order->get_shipping_postcode();
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if ($this->is_valid_br_zip_code($shipping_address_zip)) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$api_key = $this->vindi_settings->get_api_key();
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'redirect' => '',
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if($amount < $order->get_total()) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$bill = $this->routes->findBillById($bill_id);
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($amount < $order->get_total()) {
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
/* translators: 1: Refund amount, 2: Refund ID */
- Exclude checks
Line indented incorrectly; expected at least 28 spaces, found 10 Open
);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return true;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$reason = sanitize_text_field($reason);
- Exclude checks
Closing brace indented incorrectly; expected 2 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $response;
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'shipping_amount' => VindiHelpers::get_vindi_amount($order->get_shipping_total() + $order->get_shipping_tax(), $currency), // The shipping cost, in cents, as a non-negative integer.
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$level3_data['shipping_address_zip'] = $shipping_address_zip;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
} elseif ($this->vindi_settings->woocommerce->customer->get_billing_country()) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return false;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$response = array(
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$types = [];
- Exclude checks
Opening brace should be on a new line Open
public function process_refund($order_id, $amount = null, $reason = '') {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$this->logger->log('Resultado do reembolso: ' . wc_print_r($result, true));
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$data = $this->get_refund_request($bill_id, $amount, $reason);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!$bill) {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'quantity' => $quantity, // The number of items of this type sold, as a non-negative integer.
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$level3_data = array(
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'merchant_reference' => $order->get_id(), // An alphanumeric string of up to characters in length. This unique value is assigned by the merchant to identify the order. Also known as an “Order ID”.
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'line_items' => $vindi_line_items,
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
} catch (Exception $e) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function process_refund($order_id, $amount = null, $reason = '') {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$order = wc_get_order($order_id);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return new WP_Error('error', __('Reembolso falhou.', VINDI));
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$amount = filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT);
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$bill_id = filter_var($bill_id, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
protected $logger;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 8 Open
'product_code' => (string) $product_id, // Up to 12 characters that uniquely identify the product.
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return !empty($zip) && preg_match('/^[0-9]{5,5}([- ]?[0-9]{3,3})?$/', $zip);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
{
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return $order->billing_country;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$types[] = $item['data']->get_type();
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (!$this->can_refund_order($order)) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
foreach ($order_meta as $key => $order_item) {
- Exclude checks
Multi-line function call not indented correctly; expected 14 spaces but found 12 Open
sprintf(__('[Transação #%2$s]: reembolsado R$%1$s', VINDI), $result['amount'], $result['id'])
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
throw new Exception(sprintf(__('A fatura com bill_id #%s não foi encontrada!', VINDI), $bill_id), 2);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return !(boolean) preg_grep('/subscription/', $types);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$results = [];
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if(!$bill) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
foreach ($this->vindi_settings->woocommerce->cart->cart_contents as $item) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$order_id = filter_var($order_id, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
return new WP_Error('error', __('Não é possível realizar reembolsos parciais, faça um reembolso manual caso você opte por esta opção.', VINDI));
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
switch (strtolower($result['status'])) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$charges = $bill['charges'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$refund = $this->routes->refundCharge($charge_id, $data);
- Exclude checks