laravel/framework

View on GitHub
src/Illuminate/Translation/MessageSelector.php

Summary

Maintainability
D
3 days
Test Coverage

Method getPluralIndex has 299 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getPluralIndex($locale, $number)
    {
        switch ($locale) {
            case 'az':
            case 'az_AZ':
Severity: Major
Found in src/Illuminate/Translation/MessageSelector.php - About 1 day to fix

    File MessageSelector.php has 354 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Illuminate\Translation;
    
    class MessageSelector
    Severity: Minor
    Found in src/Illuminate/Translation/MessageSelector.php - About 4 hrs to fix

      Function getPluralIndex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getPluralIndex($locale, $number)
          {
              switch ($locale) {
                  case 'az':
                  case 'az_AZ':
      Severity: Minor
      Found in src/Illuminate/Translation/MessageSelector.php - About 55 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 extractFromString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extractFromString($part, $number)
          {
              preg_match('/^[\{\[]([^\[\]\{\}]*)[\}\]](.*)/s', $part, $matches);
      
              if (count($matches) !== 3) {
      Severity: Minor
      Found in src/Illuminate/Translation/MessageSelector.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

      Avoid too many return statements within this method.
      Open

                      return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
      Severity: Major
      Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $condition == $number ? $value : null;
        Severity: Major
        Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
          Severity: Major
          Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return ($number == 0) ? 0 : ((($number % 10 == 1) && ($number % 100 != 11)) ? 1 : 2);
            Severity: Major
            Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

                                return ($number % 10 == 1) ? 0 : 1;
                Severity: Major
                Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
                  Severity: Major
                  Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return ($number == 0) ? 0 : (($number == 1) ? 1 : (($number == 2) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
                    Severity: Major
                    Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
                      Severity: Major
                      Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return ($number == 1) ? 0 : (($number == 2) ? 1 : 2);
                        Severity: Major
                        Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return ($number % 100 == 1) ? 0 : (($number % 100 == 2) ? 1 : ((($number % 100 == 3) || ($number % 100 == 4)) ? 2 : 3));
                          Severity: Major
                          Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return ($number == 1) ? 0 : (($number == 2) ? 1 : ((($number == 8) || ($number == 11)) ? 2 : 3));
                            Severity: Major
                            Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
                              Severity: Major
                              Found in src/Illuminate/Translation/MessageSelector.php - About 30 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status