GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Mail/MailerAbstract.php

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Gems_Mail_MailerAbstract has 34 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Gems_Mail_MailerAbstract extends \MUtil_Registry_TargetAbstract
{
    use TranslateableTrait;

    /**
Severity: Minor
Found in classes/Gems/Mail/MailerAbstract.php - About 4 hrs to fix

    File MailerAbstract.php has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     *
     * @package    Gems
    Severity: Minor
    Found in classes/Gems/Mail/MailerAbstract.php - About 3 hrs to fix

      The class Gems_Mail_MailerAbstract has an overall complexity of 73 which is very high. The configured complexity threshold is 50.
      Open

      abstract class Gems_Mail_MailerAbstract extends \MUtil_Registry_TargetAbstract
      {
          use TranslateableTrait;
      
          /**
      Severity: Minor
      Found in classes/Gems/Mail/MailerAbstract.php by phpmd

      The class Gems_Mail_MailerAbstract has 22 fields. Consider redesigning Gems_Mail_MailerAbstract to keep the number of fields under 15.
      Open

      abstract class Gems_Mail_MailerAbstract extends \MUtil_Registry_TargetAbstract
      {
          use TranslateableTrait;
      
          /**
      Severity: Minor
      Found in classes/Gems/Mail/MailerAbstract.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

      Source https://phpmd.org/rules/codesize.html#toomanyfields

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

          public function getTemplate($templateId, $language=null)
          {
              if (!$language) {
                  $language = $this->getLanguage();
              }
      Severity: Minor
      Found in classes/Gems/Mail/MailerAbstract.php - About 1 hr to fix

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

            public function getTemplate($templateId, $language=null)
            {
                if (!$language) {
                    $language = $this->getLanguage();
                }
        Severity: Minor
        Found in classes/Gems/Mail/MailerAbstract.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

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

            public function getPresetTargetData()
            {
                $targetData = array();
                if ($this->to) {
                    $fullDisplay = array();
        Severity: Minor
        Found in classes/Gems/Mail/MailerAbstract.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 variables with short names like $db. Configured minimum length is 3.
        Open

            protected $db;
        Severity: Minor
        Found in classes/Gems/Mail/MailerAbstract.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        Avoid variables with short names like $to. Configured minimum length is 3.
        Open

            protected $to = array();
        Severity: Minor
        Found in classes/Gems/Mail/MailerAbstract.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        There are no issues that match your filters.

        Category
        Status