wsssoftware/cakephp-datatables

View on GitHub
src/Table/Option/Section/OptionsOptionAOTrait.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function setOrderFixed(array $orderFixed) {
        if (getType(Functions::getInstance()->arrayKeyFirst($orderFixed)) === 'string') {
            foreach ($orderFixed as $key => $objectItem) {
                if (!in_array($key, ['pre', 'post'])) {
                    throw new InvalidArgumentException("You must use only 'pre' or 'post' key for objects type. Found: $key.");
Severity: Minor
Found in src/Table/Option/Section/OptionsOptionAOTrait.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 checkOrderDefault has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkOrderDefault(array $orderFixed) {
        Validator::getInstance()->checkKeysValueTypesOrFail($orderFixed, ['integer', 'string'], 'array', '$orderFixed');
        foreach ($orderFixed as $item) {
            Validator::getInstance()->checkArraySizeOrFail($item, 2, "In \$orderFixed you must pass the index and after the order (asc or desc). Eg.: [0, 'asc'].");
            $param1 = $item[Functions::getInstance()->arrayKeyFirst($item)];
Severity: Minor
Found in src/Table/Option/Section/OptionsOptionAOTrait.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 setOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function setOrder(array $order) {
        Validator::getInstance()->checkKeysValueTypesOrFail($order, 'integer', 'array', '$order');
        foreach ($order as $item) {
            Validator::getInstance()->checkArraySizeOrFail($item, 2, 'In setOrder($order) you must pass the index and order (asc or desc). Eg.: [0, \'asc\'].');
            Validator::getInstance()->checkKeysValueTypesOrFail($item, 'integer', ['integer', 'string'], '$order');
Severity: Minor
Found in src/Table/Option/Section/OptionsOptionAOTrait.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

There are no issues that match your filters.

Category
Status