allanmcarvalho/cakephp-datatables

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

Summary

Maintainability
D
1 day
Test Coverage

OptionsOption has 51 functions (exceeds 20 allowed). Consider refactoring.
Open

final class OptionsOption extends ChildOptionAbstract {

    const ALLOWED_PAGING_TYPES = [
        'numbers',
        'simple',
Severity: Major
Found in src/Table/Option/Section/OptionsOption.php - About 7 hrs to fix

    File OptionsOption.php has 319 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Copyright (c) Allan Carvalho 2020.
     * Under Mit License
     * php version 7.2
    Severity: Minor
    Found in src/Table/Option/Section/OptionsOption.php - About 3 hrs to fix

      Function setSearchCols has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setSearchCols(array $searchCols): MainOption {
              Validator::getInstance()->checkKeysValueTypesOrFail($searchCols, ['integer'], ['array', 'NULL'], '$searchCols');
              foreach ($searchCols as $searchCol) {
                  if ($searchCol !== null) {
                      foreach ($searchCol as $key => $item) {
      Severity: Minor
      Found in src/Table/Option/Section/OptionsOption.php - About 1 hr 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 setRenderer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setRenderer($renderer): MainOption {
              $rendererType = getType($renderer);
              if (!in_array($rendererType, ['string', 'array'])) {
                  throw new InvalidArgumentException("\$renderer must be a string or array. Found: $rendererType.");
              }
      Severity: Minor
      Found in src/Table/Option/Section/OptionsOption.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 setOrderFixed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setOrderFixed(array $orderFixed): MainOption {
              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/OptionsOption.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 setOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setOrder(array $order): MainOption {
              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/OptionsOption.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 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/OptionsOption.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