Admidio/admidio

View on GitHub
adm_program/system/classes/TableMessage.php

Summary

Maintainability
D
2 days
Test Coverage

File TableMessage.php has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
use Admidio\Exception;

/**
 * @brief Class manages access to database table adm_messages
Severity: Minor
Found in adm_program/system/classes/TableMessage.php - About 4 hrs to fix

    Function getRecipientsNamesString has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRecipientsNamesString(bool $showFullUserNames = true): string
        {
            global $gProfileFields, $gL10n;
    
            $recipients = $this->readRecipientsData();
    Severity: Minor
    Found in adm_program/system/classes/TableMessage.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

    TableMessage has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TableMessage extends TableAccess
    {
        public const MESSAGE_TYPE_EMAIL = 'EMAIL';
        public const MESSAGE_TYPE_PM    = 'PM';
    
    
    Severity: Minor
    Found in adm_program/system/classes/TableMessage.php - About 2 hrs to fix

      Method readRecipientsData has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function readRecipientsData(): array
          {
              global $gProfileFields;
      
              if (count($this->msgRecipientsArray) === 0) {
      Severity: Minor
      Found in adm_program/system/classes/TableMessage.php - About 1 hr to fix

        Method getRecipientsNamesString has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRecipientsNamesString(bool $showFullUserNames = true): string
            {
                global $gProfileFields, $gL10n;
        
                $recipients = $this->readRecipientsData();
        Severity: Minor
        Found in adm_program/system/classes/TableMessage.php - About 1 hr to fix

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

              public function getConversationPartner()
              {
                  if ($this->getValue('msg_type') === self::MESSAGE_TYPE_PM) {
                      if($this->msgConversationPartnerId === 0) {
                          $recipients = $this->readRecipientsData();
          Severity: Minor
          Found in adm_program/system/classes/TableMessage.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

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

              public function addUser(int $userID, string $fullName = '')
              {
                  // PM always update the recipient if the message exists
                  if ($this->getValue('msg_type') === self::MESSAGE_TYPE_PM) {
                      if (count($this->msgRecipientsObjectArray) === 1) {
          Severity: Minor
          Found in adm_program/system/classes/TableMessage.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 readRecipientsData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function readRecipientsData(): array
              {
                  global $gProfileFields;
          
                  if (count($this->msgRecipientsArray) === 0) {
          Severity: Minor
          Found in adm_program/system/classes/TableMessage.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function save(bool $updateFingerPrint = true): bool
              {
                  if ($this->newRecord) {
                      // Insert
                      $this->setValue('msg_timestamp', DATETIME_NOW);
          Severity: Minor
          Found in adm_program/system/classes/TableMessage.php - About 25 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 saveAttachments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function saveAttachments()
              {
                  global $gSettingsManager;
          
                  if ($gSettingsManager->getBool('mail_save_attachments')) {
          Severity: Minor
          Found in adm_program/system/classes/TableMessage.php - About 25 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