hnhdigital-os/php-number-converter

View on GitHub

Showing 12 of 12 total issues

File NumberConverter.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\PhpNumberConverter;

/**
Severity: Minor
Found in src/NumberConverter.php - About 3 hrs to fix

    Method convertToRoman has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function convertToRoman($number)
        {
            $error_code = $this->checkParamaters($number, 'r');
    
            if ($error_code > 0) {
    Severity: Major
    Found in src/NumberConverter.php - About 2 hrs to fix

      Method convertToWord has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function convertToWord($number)
          {
              $error_code = $this->checkParamaters($number, 'w');
      
              if ($error_code > 0) {
      Severity: Major
      Found in src/NumberConverter.php - About 2 hrs to fix

        Function convertToWord has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private function convertToWord($number)
            {
                $error_code = $this->checkParamaters($number, 'w');
        
                if ($error_code > 0) {
        Severity: Minor
        Found in src/NumberConverter.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 convertToRoman has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function convertToRoman($number)
            {
                $error_code = $this->checkParamaters($number, 'r');
        
                if ($error_code > 0) {
        Severity: Minor
        Found in src/NumberConverter.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 checkParamaters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function checkParamaters($number, $type)
            {
                if ($number === '' || !is_numeric($number)) {
                    return 101;
                }
        Severity: Minor
        Found in src/NumberConverter.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

        Avoid too many return statements within this method.
        Open

                return $number.'th';
        Severity: Major
        Found in src/NumberConverter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return 106;
          Severity: Major
          Found in src/NumberConverter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return 0;
            Severity: Major
            Found in src/NumberConverter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return $number.'rd';
              Severity: Major
              Found in src/NumberConverter.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return 105;
                Severity: Major
                Found in src/NumberConverter.php - About 30 mins to fix

                  Function convertToOrdinal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function convertToOrdinal($number)
                      {
                          $error_code = $this->checkParamaters($number, 'o');
                  
                          if ($error_code > 0) {
                  Severity: Minor
                  Found in src/NumberConverter.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