swashata/php-number-to-word-india

View on GitHub

Showing 10 of 10 total issues

Method convertNumber has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function convertNumber( $number ) {
        // Init the return
        $word = array();
        // Lets start with crore
        $crore_quotient = floor( $number / $this->croreDivisor );
Severity: Minor
Found in src/NTWIndia.php - About 1 hr to fix

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

        private function convertNumber( $number ) {
            // Init the return
            $word = array();
            // Lets start with crore
            $crore_quotient = floor( $number / $this->croreDivisor );
    Severity: Minor
    Found in src/NTWIndia.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 numToWordSmall has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function numToWordSmall( $number ) {
            // Check if number is numeric
            if ( ! is_numeric( $number ) ) {
                throw new Exception\NTWIndiaInvalidNumber( 'Valid number not given.' );
            }
    Severity: Minor
    Found in src/NTWIndia.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 numToWordSmall has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function numToWordSmall( $number ) {
            // Check if number is numeric
            if ( ! is_numeric( $number ) ) {
                throw new Exception\NTWIndiaInvalidNumber( 'Valid number not given.' );
            }
    Severity: Minor
    Found in src/NTWIndia.php - About 1 hr to fix

      Function numToWord has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function numToWord( $number ) {
              /**
               * Check if a valid number is passed
               *
               * If not then log a warning
      Severity: Minor
      Found in src/NTWIndia.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

      Avoid too many return statements within this method.
      Open

                  return $this->numToWord['50'] . ' ' . $this->numToWord[ $lastCharacter ];
      Severity: Major
      Found in src/NTWIndia.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $this->numToWord['60'] . ' ' . $this->numToWord[ $lastCharacter ];
        Severity: Major
        Found in src/NTWIndia.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $this->numToWord['80'] . ' ' . $this->numToWord[ $lastCharacter ];
          Severity: Major
          Found in src/NTWIndia.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->numToWord['90'] . ' ' . $this->numToWord[ $lastCharacter ];
            Severity: Major
            Found in src/NTWIndia.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return $this->numToWord['70'] . ' ' . $this->numToWord[ $lastCharacter ];
              Severity: Major
              Found in src/NTWIndia.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language