Function object_array_merge_split
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function object_array_merge_split( $arrs, $sort_by ) {
$sortables = array();
$nulls = array();
foreach ( $arrs as $arr ) {
- 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_users_options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function get_users_options( $role = 'any' ) {
if ( is_array( $role ) ) {
if ( count( $role ) > 0 ) {
$role = $role[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 format_unit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function format_unit( $value, $units, $base, $base_unit = '', $decimals = 2 ) {
$value = floatval( $value );
if ( empty( $base_unit ) ) {
$base_unit = $units[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 object_array_merge_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static function object_array_merge_items( $items, $result, &$instance_counts, $key = 'slug' ) {
foreach ( $items as $item ) {
if ( ! isset( $result[ $item->$key ] ) ) {
$result[ $item->$key ] = $item;
} else {
- 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 object_array_insert_sorted
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static function object_array_insert_sorted( $arr, $item, $sort_by, $key = 'slug' ) {
$new_arr = array();
$new_arr[ $item->$key ] = $item;
$split_key = 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 sort_objects_callback
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function sort_objects_callback( $a, $b ) {
$sort_by = self::$sort_by;
if ( ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) && ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) ) {
return 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 mod
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function mod( $divident, $divisor ) {
if ( is_int( $divident ) && is_int( $divisor ) ) {
// prevent division by zero
if ( 0 === $divisor ) {
return 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 is_rest_zero
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function is_rest_zero( $divident, $divisor ) {
$divident = abs( $divident );
$divisor = abs( $divisor );
if ( is_int( $divident ) && is_int( $divisor ) ) {
- 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
Consider simplifying this complex logical expression. Open
if ( ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) && ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) ) {
return 0;
} elseif ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) {
return 1;
} elseif ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) {
Method format_unit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function format_unit( $value, $units, $base, $base_unit = '', $decimals = 2 ) {
Avoid too many return
statements within this method. Open
return ( $a->$sort_by < $b->$sort_by ? -1 : 1 );
Function get_posts_options
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function get_posts_options( $post_type = 'any' ) {
if ( ! is_string( $post_type ) && ! is_array( $post_type ) || empty( $post_type ) ) {
$post_type = 'any';
}
- 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 object_array_sort
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function object_array_sort( $arr, $sort_by, $associative = false ) {
if ( ! empty( $sort_by ) ) {
self::$sort_by = $sort_by;
if ( $associative ) {
- 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"