Andre-487/php_rutils

View on GitHub

Showing 13 of 13 total issues

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 sumString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sumString($amount, $gender, array $variants = null)
          {
              if ($variants === null) {
                  $variants = array_fill(0, 3, '');
              }
      Severity: Minor
      Found in Numeral.php - About 1 hr to fix

        Method _sumStringOneOrder has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function _sumStringOneOrder($prevResult, $tmpVal, $gender, array $variants)
            {
                if ($tmpVal == 0) {
                    return array($prevResult, $tmpVal);
                }
        Severity: Minor
        Found in Numeral.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 _sumStringOneOrder has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _sumStringOneOrder($prevResult, $tmpVal, $gender, array $variants)
                {
                    if ($tmpVal == 0) {
                        return array($prevResult, $tmpVal);
                    }
            Severity: Minor
            Found in Numeral.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 getRubles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRubles($amount, $zeroForKopeck = false)
                {
                    if ($amount < 0) {
                        throw new \InvalidArgumentException('Amount must be positive or 0');
                    }
            Severity: Minor
            Found in Numeral.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 _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

            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

            Severity
            Category
            Status
            Source
            Language