kwn/number-to-words

View on GitHub

Showing 131 of 207 total issues

Function toWords has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    protected function toWords($number, $currencyGender = -1)
    {
        if ($number === 0) {
            return $this->zero;
        }
Severity: Minor
Found in src/Legacy/Numbers/Words/Locale/Ru.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 transformToWords has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function transformToWords(int $number, int $power): string
    {
        $units = $number % 10;
        $tens = (int) ($number / 10) % 10;
        $hundreds = (int) ($number / 100) % 10;
Severity: Minor
Found in src/Language/German/GermanTripletTransformer.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 toWords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function toWords($num)
    {
        $neg = 0;
        $ret = [];

Severity: Minor
Found in src/Legacy/Numbers/Words/Locale/Pt/Br.php - About 1 hr to fix

    Method toCurrencyWords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function toCurrencyWords($currency, $decimal, $fraction = null)
        {
            $currency = strtoupper($currency);
    
            if (!array_key_exists($currency, static::$currencyNames)) {
    Severity: Minor
    Found in src/Legacy/Numbers/Words/Locale/Es.php - About 1 hr to fix

      Method toWords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function toWords($num)
          {
              $ret = '';
              $num = strval($num);
      
      
      Severity: Minor
      Found in src/Legacy/Numbers/Words/Locale/Uz.php - About 1 hr to fix

        Method toWords has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function toWords($num)
            {
                $ret = '';
                $num = strval($num);
        
        
        Severity: Minor
        Found in src/Legacy/Numbers/Words/Locale/Tr.php - About 1 hr to fix

          Method showDigitsGroup has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function showDigitsGroup($number, $noun, $forceNoun = false, $forcePlural = false)
              {
                  $ret = '';
          
                  $units = $number % 10;
          Severity: Minor
          Found in src/Legacy/Numbers/Words/Locale/Ro.php - About 1 hr to fix

            Method toWords has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function toWords($number, $currencyGender = -1)
                {
                    if ($number === 0) {
                        return $this->zero;
                    }
            Severity: Minor
            Found in src/Legacy/Numbers/Words/Locale/Ru.php - About 1 hr to fix

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

                  public function toCurrencyWords($currency, $decimal, $fraction = null)
                  {
                      $currency = strtoupper($currency);
              
                      if (!array_key_exists($currency, self::$currencyNames)) {
              Severity: Minor
              Found in src/Legacy/Numbers/Words/Locale/Hu.php - About 1 hr to fix

                Function getSubHundred has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getSubHundred($tens, $units, $power)
                    {
                        $words = [];
                
                        if ($tens === 1) {
                Severity: Minor
                Found in src/Language/Arabic/ArabicTripletTransformer.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 toWords has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function toWords($number)
                    {
                        if ($number === 0) {
                            return $this->zero;
                        }
                Severity: Minor
                Found in src/Legacy/Numbers/Words/Locale/Tk.php - About 1 hr to fix

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

                      public function transformToWords(int $number, int $power): string
                      {
                          $units = $number % 10;
                          $tens = (int) ($number / 10) % 10;
                          $hundreds = (int) ($number / 100) % 10;
                  Severity: Minor
                  Found in src/Language/Bulgarian/BulgarianTripletTransformer.php - About 1 hr to fix

                    Method toWords has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function toWords(int $amount, string $currency, $options = null): string
                        {
                            $dictionary = new ArabicDictionary();
                            $numberToTripletsConverter = new NumberToTripletsConverter();
                            $tripletTransformer = new ArabicTripletTransformer($dictionary);
                    Severity: Minor
                    Found in src/CurrencyTransformer/ArabicCurrencyTransformer.php - About 1 hr to fix

                      Method getWordsBySplittingIntoTriplets has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function getWordsBySplittingIntoTriplets(int $number): array
                          {
                              $words = [];
                              $triplets = $this->numberToTripletsConverter->convertToTriplets($number);
                      
                      
                      Severity: Minor
                      Found in src/NumberTransformer/GenericNumberTransformer.php - About 1 hr to fix

                        Method toWords has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function toWords($num)
                            {
                                $return = '';
                        
                                if ($num === 0) {
                        Severity: Minor
                        Found in src/Legacy/Numbers/Words/Locale/Fr/Be.php - About 1 hr to fix

                          Method toWords has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function toWords(int $amount, string $currency, ?CurrencyTransformerOptions $options = null): string
                              {
                                  $dictionary = new LatvianDictionary();
                                  $numberTransformer = new LatvianNumberTransformer();
                          
                          
                          Severity: Minor
                          Found in src/CurrencyTransformer/LatvianCurrencyTransformer.php - About 1 hr to fix

                            Method toWords has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function toWords(int $amount, string $currency, ?CurrencyTransformerOptions $options = null): string
                                {
                                    $dictionary = new LithuanianDictionary();
                                    $numberTransformer = new LithuanianNumberTransformer();
                            
                            
                            Severity: Minor
                            Found in src/CurrencyTransformer/LithuanianCurrencyTransformer.php - About 1 hr to fix

                              Method toWords has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function toWords($number)
                                  {
                                      $ret = '';
                              
                                      if ($number === 0) {
                              Severity: Minor
                              Found in src/Legacy/Numbers/Words/Locale/Fr.php - About 1 hr to fix

                                Method transformToWords has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function transformToWords(int $number, int $power): string
                                    {
                                        $units = $number % 10;
                                        $tens = (int) ($number / 10) % 10;
                                        $hundreds = (int) ($number / 100) % 10;
                                Severity: Minor
                                Found in src/Language/German/GermanTripletTransformer.php - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                                      if ($pow == 1) {
                                                          $ret[$j] .= $this->showDigitsGroup(
                                                                  $numGroups[$i],
                                                                  0,
                                                                  !$this->lastAnd && $i
                                  Severity: Major
                                  Found in src/Legacy/Numbers/Words/Locale/Mk.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language