plugins/email/classes/yf_email.class.php

Summary

Maintainability
D
2 days
Test Coverage

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

<?php

/**
 * High level html emails wrapper.
 */
Severity: Minor
Found in plugins/email/classes/yf_email.class.php - About 3 hrs to fix

    Method _send_email_safe has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _send_email_safe($email_to, $name_to, $template_name, $data = [], $old_param1 = null, $override = [])
        {
            $is_test = (defined('TEST_MODE') && TEST_MODE)
                && empty($override['force_send'])
                && empty($this->FORCE_SEND);
    Severity: Major
    Found in plugins/email/classes/yf_email.class.php - About 2 hrs to fix

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

          public function _send_copies($params = [])
          {
              if ( ! $params) {
                  return false;
              }
      Severity: Minor
      Found in plugins/email/classes/yf_email.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 _send_email_safe has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _send_email_safe($email_to, $name_to, $template_name, $data = [], $old_param1 = null, $override = [])
          {
              $is_test = (defined('TEST_MODE') && TEST_MODE)
                  && empty($override['force_send'])
                  && empty($this->FORCE_SEND);
      Severity: Minor
      Found in plugins/email/classes/yf_email.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 _send_email_to_user has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _send_email_to_user($user_id, $template_name, $data = [], $instant_send = true, $require_verified_email = false, $is_wall_update = true, $template_group = '')
          {
              $instant_send = false;
              $user_data = db()->from('user')->whereid($user_id)->get();
              if (empty($user_data)) {
      Severity: Minor
      Found in plugins/email/classes/yf_email.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 _get_email_text has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _get_email_text($replace = [], $extra = [])
          {
              if ($extra['tpl_name']) {
                  $lang = $extra['locale'] ?: conf('language');
                  $a = db()->from(self::table_tpls)->where('name', $extra['tpl_name'])->where('locale', $lang)->get();
      Severity: Minor
      Found in plugins/email/classes/yf_email.class.php - About 1 hr to fix

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

            public function _send_email_to_user($user_id, $template_name, $data = [], $instant_send = true, $require_verified_email = false, $is_wall_update = true, $template_group = '')
            {
                $instant_send = false;
                $user_data = db()->from('user')->whereid($user_id)->get();
                if (empty($user_data)) {
        Severity: Minor
        Found in plugins/email/classes/yf_email.class.php - About 1 hr to fix

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

              public function _send_copies($params = [])
              {
                  if ( ! $params) {
                      return false;
                  }
          Severity: Minor
          Found in plugins/email/classes/yf_email.class.php - About 1 hr to fix

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

                public function _get_email_text($replace = [], $extra = [])
                {
                    if ($extra['tpl_name']) {
                        $lang = $extra['locale'] ?: conf('language');
                        $a = db()->from(self::table_tpls)->where('name', $extra['tpl_name'])->where('locale', $lang)->get();
            Severity: Minor
            Found in plugins/email/classes/yf_email.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 dequeue has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function dequeue($extra = [])
                {
                    queue()->listen($this->QUEUE_NAME, function ($data) use ($extra) {
                        $data = json_decode($data, true);
                        if ($data) {
            Severity: Minor
            Found in plugins/email/classes/yf_email.class.php - About 1 hr to fix

              Method _send_email_to_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function _send_email_to_user($user_id, $template_name, $data = [], $instant_send = true, $require_verified_email = false, $is_wall_update = true, $template_group = '')
              Severity: Major
              Found in plugins/email/classes/yf_email.class.php - About 50 mins to fix

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

                    public function _send_email_safe($email_to, $name_to, $template_name, $data = [], $old_param1 = null, $override = [])
                Severity: Minor
                Found in plugins/email/classes/yf_email.class.php - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return false;
                  Severity: Major
                  Found in plugins/email/classes/yf_email.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return false;
                    Severity: Major
                    Found in plugins/email/classes/yf_email.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $this->_send_email_safe($user_data['email'], $user_data['name'], $template_name, $data, $instant_send);
                      Severity: Major
                      Found in plugins/email/classes/yf_email.class.php - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status