Function array_sort
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
public static function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = array();
Function get_matching_subscription_item
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
public static function get_matching_subscription_item($subscription, $order_item, $match_type = 'match_attributes')
{
$matching_item = false;
if ('match_attributes' === $match_type) {
Method array_sort
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
public static function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = array();
Function get_matching_subscription
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
public static function get_matching_subscription($order, $order_item)
{
$subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
$matching_subscription = null;
foreach ($subscriptions as $subscription) {
The method array_sort uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$sortable_array[$k] = $v;
}
Avoid unused local variables such as '$match_type'.
$line_item = wcs_find_matching_line_item($order, $subscription_item, $match_type = 'match_attributes');
Avoid variables with short names like $i. Configured minimum length is 3.
$i = 0;
Avoid variables with short names like $on. Configured minimum length is 3.
public static function array_sort($array, $on, $order=SORT_ASC)
Blank line found at start of control structure
foreach ($custom_attributes as $name => $value) {
Visibility must be declared on method "__construct"
function __construct()
Function closing brace must go on the next line following the body; found 1 blank lines before brace
}
Expected 1 blank line at end of file; 3 found
}
Incorrect spacing between argument "$order" and equals sign; expected 1 but found 0
public static function array_sort($array, $on, $order=SORT_ASC)
Incorrect spacing between default value and equals sign for argument "$order"; expected 1 but found 0
public static function array_sort($array, $on, $order=SORT_ASC)
Terminating statement must be indented to the same level as the CASE body
break;
Terminating statement must be indented to the same level as the CASE body
break;
Spaces must be used to indent lines; tabs are not allowed
if (null === $matching_subscription && !empty($subscriptions)) {
Spaces must be used to indent lines; tabs are not allowed
}
Spaces must be used to indent lines; tabs are not allowed
$subscriptions = wcs_get_subscriptions_for_order($order, array('order_type' => 'parent'));
Spaces must be used to indent lines; tabs are not allowed
$matching_subscription = array_pop($subscriptions);
Spaces must be used to indent lines; tabs are not allowed
$matching_item = false;
Spaces must be used to indent lines; tabs are not allowed
return $matching_item;
Line exceeds 120 characters; contains 162 characters
if ('match_attributes' === $match_type && wp_list_pluck($subscription_item->get_formatted_meta_data('_', true), 'value', 'key') != $order_item_attributes) {
Spaces must be used to indent lines; tabs are not allowed
}
Line exceeds 120 characters; contains 249 characters
* @param string $match_type Optional. The type of comparison to make. Can be 'match_product_ids' to compare product|variation IDs or 'match_attributes' to also compare by item attributes on top of matching product IDs. Default 'match_attributes'.
Spaces must be used to indent lines; tabs are not allowed
return $matching_subscription;
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 4
return htmlspecialchars(strip_tags($value));
Line indented incorrectly; expected 8 spaces, found 4
if ('match_attributes' === $match_type) {
Line indented incorrectly; expected 8 spaces, found 4
foreach ($subscriptions as $subscription) {
Line indented incorrectly; expected 12 spaces, found 6
foreach ($subscription->get_items() as $subscription_item) {
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 4
return $statement_descriptor;
Line indented incorrectly; expected 4 spaces, found 2
public static function is_wc_lt($version)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 16 spaces, found 8
$line_item = wcs_find_matching_line_item($order, $subscription_item, $match_type = 'match_attributes');
Line indented incorrectly; expected 12 spaces, found 6
if ('match_attributes' === $match_type && wp_list_pluck($subscription_item->get_formatted_meta_data('_', true), 'value', 'key') != $order_item_attributes) {
Line indented incorrectly; expected at least 12 spaces, found 6
$matching_item = $subscription_item;
Line indented incorrectly; expected 4 spaces, found 2
public static function sanitize_xss($value) {
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 20 spaces, found 10
break 2;
Line indented incorrectly; expected at least 12 spaces, found 6
break;
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$matching_subscription = null;
Line indented incorrectly; expected 4 spaces, found 2
public static function get_matching_subscription_item($subscription, $order_item, $match_type = 'match_attributes')
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
function __construct()
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 8 spaces, found 4
foreach ($custom_attributes as $name => $value) {
Line indented incorrectly; expected at least 16 spaces, found 8
continue;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
$statement_descriptor = substr(trim($statement_descriptor), 0, 22);
Line indented incorrectly; expected at least 8 spaces, found 4
$order_item_canonical_product_id = wcs_get_canonical_product_id($order_item);
Line indented incorrectly; expected at least 8 spaces, found 4
add_action('woocommerce_process_product_meta', array($this, 'wc_post_meta'));
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
return version_compare(WC_VERSION, $version, '<');
Line indented incorrectly; expected 4 spaces, found 2
public static function get_matching_subscription($order, $order_item)
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected 4 spaces, found 2
public static function get_vindi_amount($total, $currency = '')
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 12 spaces, found 6
$product->update_meta_data($name, $value);
Line indented incorrectly; expected at least 8 spaces, found 4
$product->save();
Line indented incorrectly; expected 16 spaces, found 8
if($order_item === $line_item) {
Expected 1 space after IF keyword; 0 found
if($order_item === $line_item) {
Line indented incorrectly; expected 12 spaces, found 6
if (wcs_get_canonical_product_id($subscription_item) !== $order_item_canonical_product_id) {
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 16 spaces, found 8
}
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
foreach ($subscription->get_items() as $subscription_item) {
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected 8 spaces, found 4
if (!$currency) {
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals()));
Line indented incorrectly; expected 4 spaces, found 2
public static function wc_post_meta($post_id, $custom_attributes)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 4
$statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor);
Line indented incorrectly; expected at least 12 spaces, found 6
$currency = get_woocommerce_currency();
Line indented incorrectly; expected at least 4 spaces, found 2
{
Closing brace indented incorrectly; expected 2 spaces, found 4
}
Opening brace should be on a new line
public static function sanitize_xss($value) {
Line indented incorrectly; expected at least 8 spaces, found 4
$disallowed_characters = array('<', '>', '"', "'");
Line indented incorrectly; expected at least 8 spaces, found 4
$product = wc_get_product($post_id);
Line indented incorrectly; expected at least 8 spaces, found 4
$i = 0;
Line indented incorrectly; expected at least 12 spaces, found 6
$i++;
Line indented incorrectly; expected at least 16 spaces, found 8
continue;
Line indented incorrectly; expected 8 spaces, found 6
if (count($array) > 0) {
Line indented incorrectly; expected at least 20 spaces, found 10
$matching_subscription = $subscription;
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected 24 spaces, found 22
if ($k2 == $on) {
Line indented incorrectly; expected at least 16 spaces, found 14
$new_array[$k] = $array[$k];
Line indented incorrectly; expected 4 spaces, found 2
public static function clean_statement_descriptor($statement_descriptor = '')
Line indented incorrectly; expected at least 12 spaces, found 6
$order_item_attributes = wp_list_pluck($order_item->get_formatted_meta_data('_', true), 'value', 'key');
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected 24 spaces, found 22
}
Line indented incorrectly; expected 16 spaces, found 14
} else {
Line indented incorrectly; expected 12 spaces, found 10
switch ($order) {
Line indented incorrectly; expected at least 20 spaces, found 18
arsort($sortable_array);
Line indented incorrectly; expected 8 spaces, found 6
}
Line indented incorrectly; expected 12 spaces, found 10
foreach ($array as $k => $v) {
Line indented incorrectly; expected 12 spaces, found 10
}
Line indented incorrectly; expected at least 20 spaces, found 18
asort($sortable_array);
Line indented incorrectly; expected 12 spaces, found 10
}
Line indented incorrectly; expected 12 spaces, found 10
}
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 20 spaces, found 18
$sortable_array[$k] = $v;
Line indented incorrectly; expected 16 spaces, found 14
case SORT_DESC:
Line indented incorrectly; expected at least 8 spaces, found 6
$new_array = array();
Line indented incorrectly; expected at least 8 spaces, found 6
$sortable_array = array();
Line indented incorrectly; expected 20 spaces, found 18
foreach ($v as $k2 => $v2) {
Line indented incorrectly; expected at least 28 spaces, found 26
$sortable_array[$k] = $v2;
Line indented incorrectly; expected 16 spaces, found 14
case SORT_ASC:
Line indented incorrectly; expected 4 spaces, found 2
public static function array_sort($array, $on, $order=SORT_ASC)
Whitespace found at end of line
*
Whitespace found at end of line
*
Line indented incorrectly; expected 20 spaces, found 18
}
Line indented incorrectly; expected 16 spaces, found 14
}
Line indented incorrectly; expected at least 8 spaces, found 6
return $new_array;
Line indented incorrectly; expected 16 spaces, found 14
if (is_array($v)) {
Line indented incorrectly; expected 12 spaces, found 10
foreach ($sortable_array as $k => $v) {
There are no issues that match your filters.