get_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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
installments accesses the super-global variable $_POST. Open
protected function installments()
{
if (
'credit_card' == $this->payment_method_code() &&
isset($_POST['vindi_cc_installments'])
- 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_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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
installments accesses the super-global variable $_POST. Open
protected function installments()
{
if (
'credit_card' == $this->payment_method_code() &&
isset($_POST['vindi_cc_installments'])
- 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_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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_cc_payment_type accesses the super-global variable $_POST. Open
public function get_cc_payment_type($customer_id)
{
if ($this->gateway->verify_user_payment_profile()) {
return false;
}
- 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
File PaymentProcessor.php
has 949 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace VindiPaymentGateways;
use DateTime;
VindiPaymentProcessor
has 62 functions (exceeds 20 allowed). Consider refactoring. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
Function process_order
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function process_order()
{
$this->check_trial_and_single_product();
$customer = $this->get_customer();
$order_items = $this->order->get_items();
- 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
The class VindiPaymentProcessor has 45 non-getter- and setter-methods. Consider refactoring VindiPaymentProcessor to keep number of methods under 25. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- Read upRead up
- Exclude checks
TooManyMethods
Since: 0.1
A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
The default was changed from 10 to 25 in PHPMD 2.3.
Example
Source https://phpmd.org/rules/codesize.html#toomanymethods
The class VindiPaymentProcessor has an overall complexity of 234 which is very high. The configured complexity threshold is 50. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- Exclude checks
Method process_order
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process_order()
{
$this->check_trial_and_single_product();
$customer = $this->get_customer();
$order_items = $this->order->get_items();
Function build_tax_item
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function build_tax_item($order_items)
{
$total_tax = 0;
$taxItem = [];
- 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
Function order_has_trial_and_simple_product
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function order_has_trial_and_simple_product()
{
$has_trial = false;
$has_simple_product = false;
$order_items = $this->order->get_items();
- 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
Function get_cycle_from_product_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function get_cycle_from_product_type($item)
{
$cycles = null;
$product = is_object($item) && method_exists($item, 'get_product') ? $item->get_product() : false;
- 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
Function build_sign_up_fee_item
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function build_sign_up_fee_item($order_items)
{
foreach ($order_items as $order_item) {
if (!is_object($order_item) || !method_exists($order_item, 'get_product')) {
continue;
- 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
Function get_plan_from_order_item
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_plan_from_order_item($order_item)
{
$product = $order_item->get_product();
if (isset($order_item['variation_id']) && $order_item['variation_id'] != 0) {
- 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
Function get_product
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function get_product($order_item)
{
$product = $order_item->get_product();
$product_id = $order_item->get_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
Function build_product_items_for_subscription
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function build_product_items_for_subscription($order_item)
{
$plan_cycles = $this->get_cycle_from_product_type($order_item);
$product_item = array(
'product_id' => $order_item['vindi_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
Function build_shipping_item
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function build_shipping_item($order_items)
{
$shipping_item = [];
$shipping_method = $this->order->get_shipping_method();
$get_total_shipping = $this->order->get_shipping_total();
- 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 too many return
statements within this method. Open
return $cycles > 0 ? $cycles : null;
Function coupon_supports_product
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function coupon_supports_product($order_item, $coupon)
{
$product_id = $order_item->get_product()->get_id();
$included_products = $coupon->get_product_ids();
$excluded_products = $coupon->get_excluded_product_ids();
- 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
The class VindiPaymentProcessor has 1495 lines of code. Current threshold is 1000. Avoid really long classes. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- Exclude checks
The method get_cycle_from_product_type() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
private function get_cycle_from_product_type($item)
{
$cycles = null;
$product = is_object($item) && method_exists($item, 'get_product') ? $item->get_product() : false;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method process_order() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function process_order()
{
$this->check_trial_and_single_product();
$customer = $this->get_customer();
$order_items = $this->order->get_items();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method abort has a boolean flag argument $throw_exception, which is a certain sign of a Single Responsibility Principle violation. Open
public function abort($message, $throw_exception = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'. Open
$subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
- 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 method build_tax_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
!empty($order_item['type']) && $total_tax += ($order_item['type'] === 'shipping' ? (float) $this->order->get_shipping_tax() : (float) $order_item->get_total_tax());
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method get_plan_from_order_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$vindi_plan = get_post_meta($product->get_id(), 'vindi_plan_id', true);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method get_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$vindi_product = $this->controllers->plans->create($product_id, '', '', true);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method build_product_from_order_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$order_items['price'] = (float) $order_items['subtotal'] / $order_items['qty'];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\WC_Subscriptions_Product' in method 'subscription_has_trial'. Open
return $this->is_subscription_type($product) && class_exists('WC_Subscriptions_Product') && WC_Subscriptions_Product::get_trial_length($product->get_id()) > 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
The method add_additional_items uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$order_items[] = $this->build_product_from_order_item($order_type, $product);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'build_shipping_item'. Open
$wc_subscription = VindiHelpers::get_matching_subscription($this->order, $order_item);
- 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 method build_tax_item uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$total_tax += (float) ($order_item->get_total_tax());
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'VindiPaymentGateways\VindiHelpers' in method 'get_trial_matching_subscription_item'. Open
$matching_item = VindiHelpers::get_matching_subscription_item($subscription, $order_item);
- 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 method order_has_trial_and_simple_product uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$has_simple_product = true;
if ($has_trial) {
return true;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused parameters such as '$order_items'. Open
protected function build_interest_rate_item($order_items)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
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
Avoid unused local variables such as '$orderType'. Open
switch ($orderType = $this->get_order_type()) {
- 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 $vindi_settings is not named in camelCase. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- 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 $single_freight is not named in camelCase. Open
class VindiPaymentProcessor
{
/**
* Order type is invalid.
*/
- 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 CASE body must start on the line following the statement Open
case static::ORDER_TYPE_SUBSCRIPTION:
- Exclude checks
The DEFAULT body must start on the line following the statement Open
default:
- Exclude checks
Blank line found at start of control structure Open
if ($sign_up_fee != null && $sign_up_fee > 0) {
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$this->abort(__('Falha ao registrar o método de pagamento. Verifique os dados e tente novamente.', VINDI), true);
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
'tax' == $order_item['type'] || 'interest_rate' == $order_item['type'] || 'sign_up_fee' == $order_item['type']
- Exclude checks
Inline control structures are not allowed Open
if ($product->id === null) $product->id = 63;
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
public function __construct(WC_Order $order, VindiPaymentGateway $gateway, VindiSettings $vindi_settings, VindiControllers $controllers)
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
return $this->is_subscription_type($product) && class_exists('WC_Subscriptions_Product') && WC_Subscriptions_Product::get_trial_length($product->get_id()) > 0;
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$this->abort(__('Falha ao registrar o método de pagamento. Verifique os dados e tente novamente.', VINDI), true);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($this->order, array('any'))) {
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
return $this->abort(__('Falha ao recuperar informações sobre o produto na Vindi. Verifique os dados e tente novamente.', VINDI), true);
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
'card_expiration' => filter_var($_POST['vindi_cc_monthexpiry'], FILTER_SANITIZE_NUMBER_INT) . '/' . filter_var($_POST['vindi_cc_yearexpiry'], FILTER_SANITIZE_NUMBER_INT),
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
return $this->abort(__('Falha ao processar carrinho de compras. Verifique os itens escolhidos e tente novamente.', VINDI), true);
- Exclude checks
Line exceeds 120 characters; contains 180 characters Open
!empty($order_item['type']) && $total_tax += ($order_item['type'] === 'shipping' ? (float) $this->order->get_shipping_tax() : (float) $order_item->get_total_tax());
- Exclude checks
Line exceeds 120 characters; contains 169 characters Open
* @param WC_Order_Item_Product|WC_Order_Item_Product[] $product The product to be built. If the order type is 'bill' this will be an array of WC_Order_Item_Product,
- Exclude checks
Inline control structures are not allowed Open
if (empty($subscription_order_item))
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
* @param WC_Order_Item_Product|WC_Order_Item_Product[] $order_items. Subscriptions will pass only one order_item and
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks