File Manager.php
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WPDLib\FieldTypes\Manager class
*
* @package WPDLib
Function get_dependencies_and_script_vars
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function get_dependencies_and_script_vars( $fields = array() ) {
$dependencies = array();
$script_vars = array();
foreach ( $fields as $field ) {
- 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 make_html_attributes
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function make_html_attributes( $atts, $html5 = true, $echo = true ) {
$output = '';
$bool_atts = array_filter( $atts, 'is_bool' );
- 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
Manager
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
final class Manager {
/**
* Status whether the class has been initialized.
*
Function parse_bool
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private static function parse_bool( $value ) {
if ( is_int( $value ) ) {
if ( $value > 0 ) {
return true;
}
- 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_float
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function format_float( $value, $mode = 'input', $args = array() ) {
$positive_only = isset( $args['positive_only'] ) ? (bool) $args['positive_only'] : false;
$formatted = self::parse_float( $value );
if ( $positive_only ) {
- 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_default_datetime_format
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function get_default_datetime_format( $type, $mode = 'input' ) {
if ( 'output' === $mode ) {
if ( $type == 'date' ) {
return get_option( 'date_format' );
} elseif ( $type == 'time' ) {
- 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_html_data_attributes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private static function sort_html_data_attributes( $a, $b, $priorities = array() ) {
if ( strpos( $a, 'data-' ) === 0 && strpos( $b, 'data-' ) !== 0 ) {
if ( in_array( $b, $priorities ) ) {
return 1;
}
- 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
Method format
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function format( $value, $type, $mode = 'input', $args = array() ) {
$mode = 'output' === $mode ? 'output' : 'input';
$formatted = $value;
Method make_html_attributes
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function make_html_attributes( $atts, $html5 = true, $echo = true ) {
$output = '';
$bool_atts = array_filter( $atts, 'is_bool' );
Function sort_html_priority_attributes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function sort_html_priority_attributes( $a, $b, $priorities = array() ) {
if ( in_array( $a, $priorities ) && ! in_array( $b, $priorities ) ) {
return -1;
} elseif ( ! in_array( $a, $priorities ) && in_array( $b, $priorities ) ) {
return 1;
- 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 self::format_float( $value, $mode, $args );
Avoid too many return
statements within this method. Open
return 'His';
Avoid too many return
statements within this method. Open
return self::format_datetime( $value, $mode, $type, $args );
Avoid too many return
statements within this method. Open
return $formatted;
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return 'YmdHis';
Avoid too many return
statements within this method. Open
return self::format_int( $value, $mode, $args );
Avoid too many return
statements within this method. Open
return 0;
Avoid too many return
statements within this method. Open
return self::format_byte( $value, $mode, $args );
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return (bool) $value;
Function format_bool
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static function format_bool( $value, $mode = 'input' ) {
$formatted = self::parse_bool( $value );
if ( 'output' === $mode ) {
if ( $formatted ) {
- 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_instance
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function get_instance( $args, $repeatable = false ) {
if ( ! isset( $args['type'] ) ) {
return null;
}
- 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"