Fleshgrinder/php-assertion

View on GitHub

Showing 5 of 22 total issues

Variable has 47 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Variable {

    const BC_MATH_DEFAULT_SCALE = 1000;

    /**
Severity: Minor
Found in src/Variable.php - About 6 hrs to fix

Function isRealNumber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    final public static function isRealNumber($var, $scale = self::BC_MATH_DEFAULT_SCALE) {
        assert(Variable::isScalarNaturalNumber($scale), 'BC Math scale must be a natural number (ℕ₀) of type int');

        if (is_numeric($var)) {
            if (filter_var($var, FILTER_VALIDATE_FLOAT) !== false) {
Severity: Minor
Found in src/Variable.php - About 35 mins to fix

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 isStrictArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    final public static function isStrictArray($var) {
        if ($var instanceof \SplFixedArray) {
            return true;
        }

Severity: Minor
Found in src/Variable.php - About 35 mins to fix

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 applyCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public static function applyCallback($var, callable $callback, $pass_delta = true) {
        assert(is_bool($pass_delta), 'Third argument must be of type bool.');

        if (is_iterable($var)) {
            /** @noinspection ForeachSourceInspection */
Severity: Minor
Found in src/Variable.php - About 25 mins to fix

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 hasKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    final public static function hasKeys($var, ...$keys) {
        if (is_iterable($var)) {
            foreach ($keys as $key) {
                if (!array_key_exists($key, $var)) {
                    return false;
Severity: Minor
Found in src/Variable.php - About 25 mins to fix

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

Severity
Category
Status
Source
Language