misantron/php-utils

View on GitHub

Showing 8 of 8 total issues

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

    public static function mergeRecursive($firstArr, $secondArr)
    {
        $args = func_get_args();
        $result = array_shift($args);
        while (sizeof($args) > 0) {
Severity: Minor
Found in src/UArray.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

Method timeDiff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function timeDiff($periodStartDate, $periodEndDate)
    {
        /**
         * @var \DateTime $fromDate
         * @var \DateTime $toDate
Severity: Minor
Found in src/UTime.php - About 1 hr to fix

    Function timeDiff has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function timeDiff($periodStartDate, $periodEndDate)
        {
            /**
             * @var \DateTime $fromDate
             * @var \DateTime $toDate
    Severity: Minor
    Found in src/UTime.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 secondsDiff has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function secondsDiff($periodStartDate, $periodEndDate)
        {
            /**
             * @var \DateTime $fromDate
             * @var \DateTime $toDate
    Severity: Minor
    Found in src/UTime.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 prepareArguments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function prepareArguments(&$arr, &$key, &$direction = SORT_ASC, &$sortFlag = SORT_REGULAR)
        {
            $keys = is_array($key) ? $key : [$key];
            $keysCount = sizeof($keys);
            if ($keysCount < 1 || empty($arr)) {
    Severity: Minor
    Found in src/UArray.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 getRange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRange($format = 'Y-m-d')
        {
            $range = [];
            $rangeBegin = clone $this->rangeBegin;
            if ($this->rangeBegin->format($format) > $this->rangeEnd->format($format)) {
    Severity: Minor
    Found in src/Object/DateRange.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 filterValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function filterValues(&$arr, $type = self::TYPE_INTEGER, $preserveKeys = false)
        {
            switch($type) {
                case self::TYPE_INTEGER:
                    $callback = 'is_int';
    Severity: Minor
    Found in src/UArray.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 map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function map(&$arr, $keyColumn, $valColumn = null)
        {
            $result = [];
            foreach ($arr as $val) {
                if (!isset($val[$keyColumn]) || ($valColumn !== null && !isset($val[$valColumn]))) {
    Severity: Minor
    Found in src/UArray.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