Andre-487/php_rutils

View on GitHub
Dt.php

Summary

Maintainability
C
1 day
Test Coverage

File Dt.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace php_rutils;

use php_rutils\struct\TimeParams;

Severity: Minor
Found in Dt.php - About 2 hrs to fix

    Function distanceOfTimeInWords has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function distanceOfTimeInWords($toTime, $fromTime = null, $accuracy = RUtils::ACCURACY_YEAR)
        {
            $accuracy = (int)$accuracy;
            if ($accuracy < 1 || $accuracy > 5) {
                throw new \InvalidArgumentException('Wrong accuracy value (must be 1..5)');
    Severity: Minor
    Found in Dt.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 ruStrFTime has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function ruStrFTime($params = null)
        {
            //Params handle
            if ($params === null) {
                $params = new TimeParams();
    Severity: Minor
    Found in Dt.php - About 1 hr to fix

      Method distanceOfTimeInWords has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function distanceOfTimeInWords($toTime, $fromTime = null, $accuracy = RUtils::ACCURACY_YEAR)
          {
              $accuracy = (int)$accuracy;
              if ($accuracy < 1 || $accuracy > 5) {
                  throw new \InvalidArgumentException('Wrong accuracy value (must be 1..5)');
      Severity: Minor
      Found in Dt.php - About 1 hr to fix

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

            private function _getTwoDaysResult(\DateInterval $interval, \DateTime $toTime, \DateTimeZone $timeZone = null)
            {
                $result = null;
                $days = $interval->days;
        
        
        Severity: Minor
        Found in Dt.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 ruStrFTime has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function ruStrFTime($params = null)
            {
                //Params handle
                if ($params === null) {
                    $params = new TimeParams();
        Severity: Minor
        Found in Dt.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 _getLevelResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _getLevelResult($fieldCode, array $distanceData, array $words = array(), $borderField = -1)
            {
                $curPos = array_search($fieldCode, self::$_DISTANCE_FIELDS);
                if ($borderField >= $curPos) {
                    return array($words, $borderField);
        Severity: Minor
        Found in Dt.php - About 45 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 _getResultWords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _getResultWords($accuracy, $distanceData)
            {
                switch ($accuracy) {
                    case RUtils::ACCURACY_YEAR:
                        list($words,) = $this->_getYearResult($distanceData);
        Severity: Minor
        Found in Dt.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 _getOneWordResult has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _getOneWordResult(\DateInterval $interval)
            {
                $result = null;
                if ($interval->days == 0 && $interval->h == 0 && $interval->i == 1) {
                    $result = 'минуту';
        Severity: Minor
        Found in Dt.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