plugins/locale/classes/yf_i18n.class.php

Summary

Maintainability
F
5 days
Test Coverage

File yf_i18n.class.php has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Locale handler.
 *
Severity: Major
Found in plugins/locale/classes/yf_i18n.class.php - About 1 day to fix

    Function translate_string has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        public function translate_string($in, $args = 0, $lang = '')
        {
            if ( ! $in) {
                return $in;
            }
    Severity: Minor
    Found in plugins/locale/classes/yf_i18n.class.php - About 7 hrs 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 _process_sub_patterns has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _process_sub_patterns($text = '', $args = [])
        {
            if (false === strpos($text, '{') || ! is_array($args)) {
                return $text;
            }
    Severity: Minor
    Found in plugins/locale/classes/yf_i18n.class.php - About 5 hrs 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 translate_string has 119 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function translate_string($in, $args = 0, $lang = '')
        {
            if ( ! $in) {
                return $in;
            }
    Severity: Major
    Found in plugins/locale/classes/yf_i18n.class.php - About 4 hrs to fix

      Method _get_current_lang has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _get_current_lang($force = false)
          {
              $langs = $this->LANGUAGES ?: $this->_get_langs();
      
              $FORCE_LOCALE = conf('FORCE_LOCALE');
      Severity: Major
      Found in plugins/locale/classes/yf_i18n.class.php - About 3 hrs to fix

        Function _get_current_lang has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            public function _get_current_lang($force = false)
            {
                $langs = $this->LANGUAGES ?: $this->_get_langs();
        
                $FORCE_LOCALE = conf('FORCE_LOCALE');
        Severity: Minor
        Found in plugins/locale/classes/yf_i18n.class.php - About 3 hrs 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 _load_lang_get_vars_from_files has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function _load_lang_get_vars_from_files($lang)
            {
                $files = [];
                // Auto-find shared language vars. They will be connected in order of file system
                // Names can be any, but better to include lang name into file name. Examples:
        Severity: Minor
        Found in plugins/locale/classes/yf_i18n.class.php - About 2 hrs 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 _process_sub_patterns has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _process_sub_patterns($text = '', $args = [])
            {
                if (false === strpos($text, '{') || ! is_array($args)) {
                    return $text;
                }
        Severity: Major
        Found in plugins/locale/classes/yf_i18n.class.php - About 2 hrs to fix

          Method _load_lang_get_vars_from_files has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _load_lang_get_vars_from_files($lang)
              {
                  $files = [];
                  // Auto-find shared language vars. They will be connected in order of file system
                  // Names can be any, but better to include lang name into file name. Examples:
          Severity: Minor
          Found in plugins/locale/classes/yf_i18n.class.php - About 1 hr to fix

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

                public function init_locale()
                {
                    $langs = $this->LANGUAGES ?: $this->_get_langs();
                    $lang = strtolower($this->_get_current_lang());
                    $charset = strtolower($this->_get_current_charset());
            Severity: Minor
            Found in plugins/locale/classes/yf_i18n.class.php - About 1 hr to fix

              Function _load_lang has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _load_lang($lang = '')
                  {
                      if ( ! $this->TRANSLATE_ENABLED) {
                          return false;
                      }
              Severity: Minor
              Found in plugins/locale/classes/yf_i18n.class.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 $lang;
              Severity: Major
              Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return $a['locale'];
                Severity: Major
                Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $this->CUR_LOCALE;
                  Severity: Major
                  Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return $lang;
                    Severity: Major
                    Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $out;
                      Severity: Major
                      Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return $lang;
                        Severity: Major
                        Found in plugins/locale/classes/yf_i18n.class.php - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status