classes/yf_utils.class.php

Summary

Maintainability
F
5 days
Test Coverage

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

<?php

class yf_utils
{
    /**
Severity: Major
Found in classes/yf_utils.class.php - About 1 day to fix

    yf_utils has 53 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_utils
    {
        /**
         * Catch missing method call.
         * @param mixed $name
    Severity: Major
    Found in classes/yf_utils.class.php - About 7 hrs to fix

      Function my_array_merge has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function my_array_merge($a1, $a2)
          {
              foreach ((array) $a2 as $k => $v) {
                  if (isset($a1[$k]) && is_array($a1[$k])) {
                      if (is_array($a2[$k])) {
      Severity: Minor
      Found in classes/yf_utils.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

      Function _server_info has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _server_info($server_id)
          {
              $cached_server_info = &main()->_cached_server_info;
              if (is_numeric($server_id)) {
                  $server_id = (int) $server_id;
      Severity: Minor
      Found in classes/yf_utils.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

      Function _check_words_length has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _check_words_length($text, $length = 0, $do_encode_email = false)
          {
              if (empty($length)) {
                  $length = 60;
                  if (SITE_MAX_WORD_LENGTH != 'SITE_MAX_WORD_LENGTH' && SITE_MAX_WORD_LENGTH != '') {
      Severity: Minor
      Found in classes/yf_utils.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

      Function _account_info has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _account_info($account_id)
          {
              $cached_account_info = &main()->_cached_account_info;
              if (is_numeric($account_id)) {
                  $account_id = (int) $account_id;
      Severity: Minor
      Found in classes/yf_utils.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

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

          public function _format_date($input_date = '', $type = 'short')
          {
              if ( ! strlen($input_date)) {
                  return '';
              }
      Severity: Minor
      Found in classes/yf_utils.class.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 _check_words_length has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _check_words_length($text, $length = 0, $do_encode_email = false)
          {
              if (empty($length)) {
                  $length = 60;
                  if (SITE_MAX_WORD_LENGTH != 'SITE_MAX_WORD_LENGTH' && SITE_MAX_WORD_LENGTH != '') {
      Severity: Minor
      Found in classes/yf_utils.class.php - About 1 hr to fix

        Method _format_date has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _format_date($input_date = '', $type = 'short')
            {
                if ( ! strlen($input_date)) {
                    return '';
                }
        Severity: Minor
        Found in classes/yf_utils.class.php - About 1 hr to fix

          Method _account_info has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _account_info($account_id)
              {
                  $cached_account_info = &main()->_cached_account_info;
                  if (is_numeric($account_id)) {
                      $account_id = (int) $account_id;
          Severity: Minor
          Found in classes/yf_utils.class.php - About 1 hr to fix

            Method _server_info has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function _server_info($server_id)
                {
                    $cached_server_info = &main()->_cached_server_info;
                    if (is_numeric($server_id)) {
                        $server_id = (int) $server_id;
            Severity: Minor
            Found in classes/yf_utils.class.php - About 1 hr to fix

              Function _prepare_html has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function _prepare_html($text = '', $need_strip_slashes = 1, $use_smart_function = 1)
                  {
                      if (is_array($text)) {
                          foreach ((array) $text as $k => $v) {
                              $text[$k] = $this->_prepare_html($v);
              Severity: Minor
              Found in classes/yf_utils.class.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 _show_avatar has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _show_avatar($user_id = 0, $user_name = '', $as_link = 0, $is_middle = 0, $only_img_src = 0, $force_link = '')
                  {
                      if (is_array($user_name)) {
                          $user_info = $user_name;
                          $user_name = _display_name($user_info);
              Severity: Minor
              Found in classes/yf_utils.class.php - About 1 hr to fix

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

                    public function _prepare_html($text = '', $need_strip_slashes = 1, $use_smart_function = 1)
                    {
                        if (is_array($text)) {
                            foreach ((array) $text as $k => $v) {
                                $text[$k] = $this->_prepare_html($v);
                Severity: Minor
                Found in classes/yf_utils.class.php - About 1 hr to fix

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

                      public function checkdnsrr($hostName, $recType = '')
                      {
                          if ( ! empty($hostName)) {
                              if ($recType == '') {
                                  $recType = 'MX';
                  Severity: Minor
                  Found in classes/yf_utils.class.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

                  Method _show_avatar has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function _show_avatar($user_id = 0, $user_name = '', $as_link = 0, $is_middle = 0, $only_img_src = 0, $force_link = '')
                  Severity: Minor
                  Found in classes/yf_utils.class.php - About 45 mins to fix

                    Method _gen_dir_path has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 0755, $create_index_htmls = 1)
                    Severity: Minor
                    Found in classes/yf_utils.class.php - About 35 mins to fix

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

                          public function text_filter($str)
                          {
                              $str = htmlspecialchars($str);
                              if (defined('SITE_BAD_WORD_FILTER') && SITE_BAD_WORD_FILTER == 1) {
                                  $bad_words = conf('BAD_WORDS_ARRAY');
                      Severity: Minor
                      Found in classes/yf_utils.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

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

                          public function highlight($string, $search_words, $tag = 'span', $class = 's_word')
                          {
                              if (empty($string) || empty($search_words)) {
                                  return $string;
                              }
                      Severity: Minor
                      Found in classes/yf_utils.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

                      There are no issues that match your filters.

                      Category
                      Status