YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSMail/models/Mail.php

Summary

Maintainability
F
4 days
Test Coverage

File Mail.php has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Mail Scanner bind email action.
 *
 * @package Model
Severity: Minor
Found in modules/OSSMail/models/Mail.php - About 5 hrs to fix

    Function getFileFromImage has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
        {
            $src = trim($element->getAttribute('src'), '\'');
            $element->removeAttribute('src');
            $file = [];
    Severity: Minor
    Found in modules/OSSMail/models/Mail.php - About 4 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

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

    class OSSMail_Mail_Model extends \App\Base
    {
        /** @var string[] Ignored mail addresses */
        public const IGNORED_MAILS = ['@', 'undisclosed-recipients',  'Undisclosed-recipients', 'undisclosed-recipients@', 'Undisclosed-recipients@', 'Undisclosed recipients@,@', 'undisclosed recipients@,@'];
    
    
    Severity: Minor
    Found in modules/OSSMail/models/Mail.php by phpmd

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

        public function findEmailAddress($field, $searchModule = false, $returnArray = true)
        {
            $return = [];
            $emails = $this->get($field);
            if (empty($emails)) {
    Severity: Minor
    Found in modules/OSSMail/models/Mail.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 getContent has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getContent(): string
        {
            if ($this->has('parsedContent')) {
                return $this->get('parsedContent');
            }
    Severity: Major
    Found in modules/OSSMail/models/Mail.php - About 2 hrs to fix

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

          public function searchByEmails(string $moduleName, string $fieldName, array $emails)
          {
              $return = [];
              $cacheKey = 'MailSearchByEmails' . $moduleName . '_' . $fieldName;
              foreach ($emails as $email) {
      Severity: Minor
      Found in modules/OSSMail/models/Mail.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 getFileFromImage has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
          {
              $src = trim($element->getAttribute('src'), '\'');
              $element->removeAttribute('src');
              $file = [];
      Severity: Major
      Found in modules/OSSMail/models/Mail.php - About 2 hrs to fix

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

            public function getContent(): string
            {
                if ($this->has('parsedContent')) {
                    return $this->get('parsedContent');
                }
        Severity: Minor
        Found in modules/OSSMail/models/Mail.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 getTypeEmail has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTypeEmail($returnText = false)
            {
                if (isset($this->mailType)) {
                    if ($returnText) {
                        $cacheKey = 'Received';
        Severity: Minor
        Found in modules/OSSMail/models/Mail.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 searchByDomains has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function searchByDomains(string $moduleName, string $fieldName, array $emails)
            {
                $cacheKey = 'MailSearchByDomains' . $moduleName . '_' . $fieldName;
                $crmids = [];
                foreach ($emails as $email) {
        Severity: Minor
        Found in modules/OSSMail/models/Mail.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 getTypeEmail has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getTypeEmail($returnText = false)
            {
                if (isset($this->mailType)) {
                    if ($returnText) {
                        $cacheKey = 'Received';
        Severity: Minor
        Found in modules/OSSMail/models/Mail.php - About 1 hr to fix

          Function saveAttachments has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function saveAttachments()
              {
                  $userId = $this->getAccountOwner();
                  $useTime = $this->get('date');
                  $files = $this->get('files');
          Severity: Minor
          Found in modules/OSSMail/models/Mail.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 saveAttachments has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function saveAttachments()
              {
                  $userId = $this->getAccountOwner();
                  $useTime = $this->get('date');
                  $files = $this->get('files');
          Severity: Minor
          Found in modules/OSSMail/models/Mail.php - About 1 hr to fix

            Method findEmailAddress has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                {
                    $return = [];
                    $emails = $this->get($field);
                    if (empty($emails)) {
            Severity: Minor
            Found in modules/OSSMail/models/Mail.php - About 1 hr to fix

              Method searchByEmails has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function searchByEmails(string $moduleName, string $fieldName, array $emails)
                  {
                      $return = [];
                      $cacheKey = 'MailSearchByEmails' . $moduleName . '_' . $fieldName;
                      foreach ($emails as $email) {
              Severity: Minor
              Found in modules/OSSMail/models/Mail.php - About 1 hr to fix

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

                    public function getEmail($cacheKey)
                    {
                        $header = $this->get('header');
                        $text = '';
                        if (property_exists($header, $cacheKey)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.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 findEmailUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function findEmailUser($emails)
                    {
                        $notFound = 0;
                        if (!empty($emails)) {
                            foreach (explode(',', $emails) as $email) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.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

                The method getContent() has an NPath complexity of 324. The configured NPath complexity threshold is 200.
                Open

                    public function getContent(): string
                    {
                        if ($this->has('parsedContent')) {
                            return $this->get('parsedContent');
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

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

                The method getContent() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                Open

                    public function getContent(): string
                    {
                        if ($this->has('parsedContent')) {
                            return $this->get('parsedContent');
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

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

                The method getTypeEmail() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                Open

                    public function getTypeEmail($returnText = false)
                    {
                        if (isset($this->mailType)) {
                            if ($returnText) {
                                $cacheKey = 'Received';
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

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

                The method getFileFromImage() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                    {
                        $src = trim($element->getAttribute('src'), '\'');
                        $element->removeAttribute('src');
                        $file = [];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

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

                The method findEmailAddress() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                    {
                        $return = [];
                        $emails = $this->get($field);
                        if (empty($emails)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

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

                Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                Reduce the number of returns of this function 4, down to the maximum allowed 3.
                Open

                    public function getTypeEmail($returnText = false)
                Severity: Major
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                Noncompliant Code Example

                With the default threshold of 3:

                function myFunction(){ // Noncompliant as there are 4 return statements
                  if (condition1) {
                    return true;
                  } else {
                    if (condition2) {
                      return false;
                    } else {
                      return true;
                    }
                  }
                  return false;
                }
                

                Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                Open

                    public function getTypeEmail($returnText = false)
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                Open

                    public function searchByEmails(string $moduleName, string $fieldName, array $emails)
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                Refactor this function to reduce its Cognitive Complexity from 31 to the 15 allowed.
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.
                Open

                    public function getContent(): string
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                The class OSSMail_Mail_Model has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13.
                Open

                class OSSMail_Mail_Model extends \App\Base
                {
                    /** @var string[] Ignored mail addresses */
                    public const IGNORED_MAILS = ['@', 'undisclosed-recipients',  'Undisclosed-recipients', 'undisclosed-recipients@', 'Undisclosed-recipients@', 'Undisclosed recipients@,@', 'undisclosed recipients@,@'];
                
                
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CouplingBetweenObjects

                Since: 1.1.0

                A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                Example

                class Foo {
                    /**
                     * @var \foo\bar\X
                     */
                    private $x = null;
                
                    /**
                     * @var \foo\bar\Y
                     */
                    private $y = null;
                
                    /**
                     * @var \foo\bar\Z
                     */
                    private $z = null;
                
                    public function setFoo(\Foo $foo) {}
                    public function setBar(\Bar $bar) {}
                    public function setBaz(\Baz $baz) {}
                
                    /**
                     * @return \SplObjectStorage
                     * @throws \OutOfRangeException
                     * @throws \InvalidArgumentException
                     * @throws \ErrorException
                     */
                    public function process(\Iterator $it) {}
                
                    // ...
                }

                Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                The method findEmailAddress has a boolean flag argument $searchModule, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                BooleanArgumentFlag

                Since: 1.4.0

                A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                Example

                class Foo {
                    public function bar($flag = true) {
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                The method getActionResult has a boolean flag argument $action, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function getActionResult($action = false)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                BooleanArgumentFlag

                Since: 1.4.0

                A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                Example

                class Foo {
                    public function bar($flag = true) {
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                Missing class import via use statement (line '281', column '27').
                Open

                                $queryGenerator = new \App\QueryGenerator($moduleName);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

                Source http://phpmd.org/rules/cleancode.html#MissingImport

                Missing class import via use statement (line '214', column '18').
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

                Source http://phpmd.org/rules/cleancode.html#MissingImport

                The method findEmailAddress has a boolean flag argument $returnArray, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                BooleanArgumentFlag

                Since: 1.4.0

                A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                Example

                class Foo {
                    public function bar($flag = true) {
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                Missing class import via use statement (line '457', column '14').
                Open

                        $doc = new \DOMDocument('1.0', 'UTF-8');
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

                Source http://phpmd.org/rules/cleancode.html#MissingImport

                The method getTypeEmail has a boolean flag argument $returnText, which is a certain sign of a Single Responsibility Principle violation.
                Open

                    public function getTypeEmail($returnText = false)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                BooleanArgumentFlag

                Since: 1.4.0

                A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                Example

                class Foo {
                    public function bar($flag = true) {
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                Missing class import via use statement (line '216', column '18').
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                MissingImport

                Since: 2.7.0

                Importing all external classes in a file through use statements makes them clearly visible.

                Example

                function make() {
                    return new \stdClass();
                }

                Source http://phpmd.org/rules/cleancode.html#MissingImport

                The method getTypeEmail uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $key = 1;
                            $cacheKey = 'Received';
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid using static access to class '\Users_Module_Model' in method 'findEmailUser'.
                Open

                                if (!\Users_Module_Model::checkMailExist($email)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'OSSMailScanner_Record_Model' in method 'findEmailAddress'.
                Open

                        $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                The method findEmailAddress uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                    } else {
                                        $return = array_merge($return, $this->searchByEmails($moduleName, $fieldName, $emails));
                                    }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid assigning values to variables in if clauses and the like (line '527', column '10').
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                    {
                        $src = trim($element->getAttribute('src'), '\'');
                        $element->removeAttribute('src');
                        $file = [];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid using static access to class 'App\Fields\MultiDomain' in method 'searchByDomains'.
                Open

                                $crmids = App\Fields\MultiDomain::findIdByDomain($moduleName, $fieldName, $domain);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                The method getFileFromImage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            \App\Log::warning("Unsupported photo type, requires verification. ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method searchByDomains uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $crmids = App\Fields\MultiDomain::findIdByDomain($moduleName, $fieldName, $domain);
                                App\Cache::staticSave($cacheKey, $domain, $crmids);
                            }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid using static access to class '\App\Config' in method 'saveAttachments'.
                Open

                            $maxSize = \App\Config::getMaxUploadSize();
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '472', column '8').
                Open

                    public function getContent(): string
                    {
                        if ($this->has('parsedContent')) {
                            return $this->get('parsedContent');
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid using static access to class '\App\Purifier' in method 'getContent'.
                Open

                        $html = \App\Purifier::purifyHtml(str_replace('<?xml encoding="utf-8"?>', '', $html));
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '502', column '8').
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                    {
                        $src = trim($element->getAttribute('src'), '\'');
                        $element->removeAttribute('src');
                        $file = [];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                The method getFileFromImage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $yetiforceTag->setAttribute('type', 'Documents');
                                $yetiforceTag->setAttribute('crm-id', $file['crmid']);
                                $yetiforceTag->setAttribute('attachment-id', $file['attachmentsId']);
                            }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method getMailCrmId uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method saveAttachments uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                                } else {
                                    \App\Log::error("Error downloading the file '{$attachment['filename']}' in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                                }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid using static access to class '\App\Log' in method 'saveAttachments'.
                Open

                                    \App\Log::error("Error downloading the file '{$attachment['filename']}' in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\Utils' in method 'getContent'.
                Open

                        if (!\App\Utils::isHtml($html) || !$this->get('isHtml')) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\Fields\File' in method 'getFileFromImage'.
                Open

                            if ($fileInstance = \App\Fields\File::saveFromString($src, ['validateAllowedFormat' => 'image'])) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Cache' in method 'searchByDomains'.
                Open

                                App\Cache::staticSave($cacheKey, $domain, $crmids);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '397', column '21').
                Open

                    public function saveAttachments()
                    {
                        $userId = $this->getAccountOwner();
                        $useTime = $this->get('date');
                        $files = $this->get('files');
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid using static access to class 'App\Cache' in method 'searchByEmails'.
                Open

                            if (App\Cache::staticHas($cacheKey, $email)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Fields\File' in method 'getFileFromImage'.
                Open

                                $fileInstance = App\Fields\File::loadFromContent($attachments[$src]['attachment'], $attachments[$src]['filename'], ['validateAllowedFormat' => 'image']);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Fields\File' in method 'getFileFromImage'.
                Open

                                    if ($file = App\Fields\File::saveFromContent($fileInstance, $params)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\Log' in method 'getFileFromImage'.
                Open

                                \App\Log::warning("There is no attachment with ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '394', column '7').
                Open

                    public function saveAttachments()
                    {
                        $userId = $this->getAccountOwner();
                        $useTime = $this->get('date');
                        $files = $this->get('files');
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid assigning values to variables in if clauses and the like (line '402', column '65').
                Open

                    public function saveAttachments()
                    {
                        $userId = $this->getAccountOwner();
                        $useTime = $this->get('date');
                        $files = $this->get('files');
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid using static access to class '\App\Log' in method 'getFileFromImage'.
                Open

                            \App\Log::warning("Unsupported photo type, requires verification. ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Cache' in method 'searchByEmails'.
                Open

                                $cache = App\Cache::staticGet($cacheKey, $email);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                The method findEmailAddress uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $emails = (array) $emails;
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid using static access to class '\App\Fields\File' in method 'getFileFromImage'.
                Open

                                if ($file = \App\Fields\File::saveFromContent($fileInstance, $params)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                The method getFileFromImage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $file = [
                                    'srcType' => 'url',
                                    'url' => $src,
                                ];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method getFileFromImage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                \App\Log::warning("There is no attachment with ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                            }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method searchByEmails uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                $ids = [];
                                $queryGenerator = new \App\QueryGenerator($moduleName);
                                if ($queryGenerator->getModuleField($fieldName)) {
                                    $queryGenerator->setFields(['id']);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Avoid using static access to class 'App\Cache' in method 'searchByDomains'.
                Open

                            if (App\Cache::staticHas($cacheKey, $domain)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Cache' in method 'searchByEmails'.
                Open

                                App\Cache::staticSave($cacheKey, $email, $ids);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\Fields\File' in method 'saveAttachments'.
                Open

                                $fileInstance = \App\Fields\File::loadFromContent($attachment['attachment'], $attachment['filename'], ['validateAllCodeInjection' => true]);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Fields\File' in method 'saveAttachments'.
                Open

                                if ($fileInstance && $fileInstance->validateAndSecure() && ($id = App\Fields\File::saveFromContent($fileInstance, $params))) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '512', column '9').
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                    {
                        $src = trim($element->getAttribute('src'), '\'');
                        $element->removeAttribute('src');
                        $file = [];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                Avoid using static access to class 'OSSMailScanner_Record_Model' in method 'getTypeEmail'.
                Open

                        foreach (OSSMailScanner_Record_Model::getIdentities($account['user_id']) as $identitie) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Cache' in method 'searchByDomains'.
                Open

                                $cache = App\Cache::staticGet($cacheKey, $domain);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\Log' in method 'saveAttachments'.
                Open

                                    \App\Log::error("Error - downloaded the file is too big '{$attachment['filename']}', size: {$size}, in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Fields\File' in method 'getFileFromImage'.
                Open

                                if ($file = App\Fields\File::saveFromUrl($src, $params)) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class '\App\User' in method 'getAccountOwner'.
                Open

                        return \App\User::getCurrentUserId();
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid using static access to class 'App\Db' in method 'saveAttachments'.
                Open

                        $db = App\Db::getInstance();
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                StaticAccess

                Since: 1.4.0

                Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                Example

                class Foo
                {
                    public function bar()
                    {
                        Bar::baz();
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#staticaccess

                Avoid assigning values to variables in if clauses and the like (line '504', column '9').
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array
                    {
                        $src = trim($element->getAttribute('src'), '\'');
                        $element->removeAttribute('src');
                        $file = [];
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                IfStatementAssignment

                Since: 2.7.0

                Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($foo = 'bar') { // possible typo
                            // ...
                        }
                        if ($baz = 0) { // always false
                            // ...
                        }
                    }
                }

                Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

                The method getFileFromImage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            $file = [];
                        }
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Define a constant instead of duplicating this literal "filename" 6 times.
                Open

                                    \App\Log::error("Error - downloaded the file is too big '{$attachment['filename']}', size: {$size}, in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "srcType" 5 times.
                Open

                                    $file['srcType'] = 'base64';
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "validateAllowedFormat" 3 times.
                Open

                            if ($fileInstance = \App\Fields\File::saveFromString($src, ['validateAllowedFormat' => 'image'])) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "parsedContent" 3 times.
                Open

                        if ($this->has('parsedContent')) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "message_id" 3 times.
                Open

                        $uid = hash('sha256', $this->get('from_email') . '|' . $this->get('date') . '|' . $this->get('subject') . '|' . $this->get('message_id'));
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "UTF-8" 3 times.
                Open

                        if ($encoding && 'UTF-8' !== $encoding) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "ossmailviewid" 3 times.
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "attachment" 4 times.
                Open

                                if ($maxSize < ($size = \strlen($attachment['attachment']))) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "titlePrefix" 3 times.
                Open

                                $params['titlePrefix'] = 'base64_';
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "attachments" 3 times.
                Open

                        if ($attachments = $this->get('attachments')) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Add a "case default" clause to this "switch" statement.
                Open

                                switch ($this->mailType) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

                Noncompliant Code Example

                switch ($param) {  //missing default clause
                  case 0:
                    do_something();
                    break;
                  case 1:
                    do_something_else();
                    break;
                }
                
                switch ($param) {
                  default: // default clause should be the last one
                    error();
                    break;
                  case 0:
                    do_something();
                    break;
                  case 1:
                    do_something_else();
                    break;
                }
                

                Compliant Solution

                switch ($param) {
                  case 0:
                    do_something();
                    break;
                  case 1:
                    do_something_else();
                    break;
                  default:
                    error();
                    break;
                }
                

                See

                • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
                • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
                • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
                • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
                • MISRA C:2012, 16.1 - All switch statements shall be well-formed
                • MISRA C:2012, 16.4 - Every switch statement shall have a default label
                • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
                • MITRE, CWE-478 - Missing Default Case in Switch Statement
                • CERT, MSC01-C. - Strive for logical completeness
                • CERT, MSC01-CPP. - Strive for logical completeness

                Define a constant instead of duplicating this literal "from_email" 3 times.
                Open

                        $fromEmailUser = $this->findEmailUser($this->get('from_email'));
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "image" 4 times.
                Open

                            if ($fileInstance = \App\Fields\File::saveFromString($src, ['validateAllowedFormat' => 'image'])) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
                Open

                                    $queryGenerator->setFields(['id']);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method warning from undeclared class \App\Log
                Open

                            \App\Log::warning("Unsupported photo type, requires verification. ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Default value for string $action can't be false
                Open

                    public function getActionResult($action = false)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method getModuleField from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
                Open

                                if ($queryGenerator->getModuleField($fieldName)) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method getIdentities from undeclared class \OSSMailScanner_Record_Model
                Open

                        foreach (OSSMailScanner_Record_Model::getIdentities($account['user_id']) as $identitie) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
                Open

                                $queryGenerator = new \App\QueryGenerator($moduleName);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method addCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
                Open

                                    $queryGenerator->addCondition($fieldName, $email, 'e');
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Argument 3 (param) is array{validateAllCodeInjection:true} but \App\Fields\File::loadFromContent() takes string[] defined at /code/app/Fields/File.php:216
                Open

                                $fileInstance = \App\Fields\File::loadFromContent($attachment['attachment'], $attachment['filename'], ['validateAllCodeInjection' => true]);
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
                Open

                                    $ids = $queryGenerator->createQuery()->column();
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method getEmailSearchList from undeclared class \OSSMailScanner_Record_Model
                Open

                        $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method warning from undeclared class \App\Log
                Open

                                \App\Log::warning("There is no attachment with ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Default value for string $searchModule can't be false
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method error from undeclared class \App\Log
                Open

                                    \App\Log::error("Error - downloaded the file is too big '{$attachment['filename']}', size: {$size}, in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method error from undeclared class \App\Log
                Open

                                    \App\Log::error("Error downloading the file '{$attachment['filename']}' in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Reference to static property ONE_MAIL_FOR_MULTIPLE_RECIPIENTS from undeclared class \Config\Modules\OSSMailScanner
                Open

                        if (empty($this->get('message_id')) || \Config\Modules\OSSMailScanner::$ONE_MAIL_FOR_MULTIPLE_RECIPIENTS) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Reference to static property attachMailBodyGraphicUrl from undeclared class \Config\Modules\OSSMailScanner
                Open

                            if (\Config\Modules\OSSMailScanner::$attachMailBodyGraphicUrl ?? true) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to undeclared method \App\Db\Query::select
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
                Open

                        return \App\User::getCurrentUserId();
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to undeclared method \App\Db::createCommand
                Open

                            $db->createCommand()->insert('vtiger_ossmailview_files', [
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Reference to static property attachHtmlAndTxtToMessageBody from undeclared class \Config\Modules\OSSMailScanner
                Open

                        if (\Config\Modules\OSSMailScanner::$attachHtmlAndTxtToMessageBody && \count($attachments) < 2) {
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Call to undeclared method \App\Db\Query::select
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Reference to static property mailBodyGraphicDocumentsFolder from undeclared class \Config\Modules\OSSMailScanner
                Open

                            'folderid' => \Config\Modules\OSSMailScanner::$mailBodyGraphicDocumentsFolder ?? 'T2',
                Severity: Critical
                Found in modules/OSSMail/models/Mail.php by phan

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        if (empty($this->get('message_id')) || \Config\Modules\OSSMailScanner::$ONE_MAIL_FOR_MULTIPLE_RECIPIENTS) {
                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);
                        } else {
                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);
                        }
                Severity: Major
                Found in modules/OSSMail/models/Mail.php and 1 other location - About 2 hrs to fix
                app/Mail/ScannerEngine/Imap.php on lines 74..80

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 130.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    public function getUniqueId()
                    {
                        if ($this->has('cid')) {
                            return $this->get('cid');
                        }
                Severity: Major
                Found in modules/OSSMail/models/Mail.php and 1 other location - About 1 hr to fix
                app/Mail/ScannerEngine/Base.php on lines 170..178

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 104.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Each class must be in a namespace of at least one level (a top-level vendor name)
                Open

                class OSSMail_Mail_Model extends \App\Base

                The class OSSMail_Mail_Model is not named in CamelCase.
                Open

                class OSSMail_Mail_Model extends \App\Base
                {
                    /** @var string[] Ignored mail addresses */
                    public const IGNORED_MAILS = ['@', 'undisclosed-recipients',  'Undisclosed-recipients', 'undisclosed-recipients@', 'Undisclosed-recipients@', 'Undisclosed recipients@,@', 'undisclosed recipients@,@'];
                
                
                Severity: Minor
                Found in modules/OSSMail/models/Mail.php by phpmd

                CamelCaseClassName

                Since: 0.2

                It is considered best practice to use the CamelCase notation to name classes.

                Example

                class class_name {
                }

                Source

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

                    public function setMailCrmId($id)
                Severity: Minor
                Found in modules/OSSMail/models/Mail.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 $id. Configured minimum length is 3.
                Open

                                if ($fileInstance && $fileInstance->validateAndSecure() && ($id = App\Fields\File::saveFromContent($fileInstance, $params))) {
                Severity: Minor
                Found in modules/OSSMail/models/Mail.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 $db. Configured minimum length is 3.
                Open

                        $db = App\Db::getInstance();
                Severity: Minor
                Found in modules/OSSMail/models/Mail.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

                Only one argument is allowed per line in a multi-line function call
                Open

                            ], ['', '', '', '', '', '', '', ''], $html);

                Only one argument is allowed per line in a multi-line function call
                Open

                            ], ['', '', '', '', '', '', '', ''], $html);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    protected $mailFolder = '';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Set account.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $this->mailFolder;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        foreach (OSSMailScanner_Record_Model::getIdentities($account['user_id']) as $identitie) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $cacheKey = 'Sent';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var int Mail type. */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param array $account

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get account.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    protected $mailAccount = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $bccEmailUser = $this->findEmailUser($this->get('bcc_email'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $key = 1;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->mailType = $key;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function setFolder($folder)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function addActionResult($type, $result)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        $cacheKey = 'Sent';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    case 2:

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $result

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($action && isset($this->actionResult[$action])) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    case 0:

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $existIdentitie = false;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    protected $mailCrmId = false;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return array

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get folder.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $this->actionResult;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($fromEmailUser && ($toEmailUser || $ccEmailUser || $bccEmailUser)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $cacheKey = 'Received';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($returnText) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $uid;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $ids = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $queryGenerator->setFields(['id']);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $ids = 0;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string[] $emails

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var string Mail folder. */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    protected $actionResult = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Set folder.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Add action result.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getAccount()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get type email.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if ($identitie['email'] == $this->get('from_email')) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get account owner.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->mailCrmId = $id;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function searchByEmails(string $moduleName, string $fieldName, array $emails)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                continue;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (App\Cache::staticHas($cacheKey, $email)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $return;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function setAccount($account)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->mailAccount = $account;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getActionResult($action = false)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                return $cacheKey;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getAccountOwner()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Line exceeds 120 characters; contains 146 characters
                Open

                        $uid = hash('sha256', $this->get('from_email') . '|' . $this->get('date') . '|' . $this->get('subject') . '|' . $this->get('message_id'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get mail crm id.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $text = '';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $return .= $row->mailbox . '@' . $row->host;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            } else {

                Line exceeds 120 characters; contains 204 characters
                Open

                    public const IGNORED_MAILS = ['@', 'undisclosed-recipients',  'Undisclosed-recipients', 'undisclosed-recipients@', 'Undisclosed-recipients@', 'Undisclosed recipients@,@', 'undisclosed recipients@,@'];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var bool|int Mail crm id. */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if ($returnText) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } elseif ($existIdentitie || $fromEmailUser) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $emails

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    ++$notFound;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return \App\User::getCurrentUserId();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getMailCrmId()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ('' != $return) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if (empty($ids)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $cacheKey = 'MailSearchByDomains' . $moduleName . '_' . $fieldName;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var array Mail account. */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    protected $mailType;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param bool $returnText

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                switch ($this->mailType) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        $cacheKey = 'Internal';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $account = $this->getAccount();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $ccEmailUser = $this->findEmailUser($this->get('cc_email'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Line exceeds 120 characters; contains 148 characters
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Set mail crm id.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $cacheKey

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Search crmids by emails.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        foreach ($emails as $email) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Search crmids from domains.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->actionResult[$type] = $result;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $this->mailAccount;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if (!\Users_Module_Model::checkMailExist($email)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($account['crm_user_id']) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $crmids = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var string[] Ignored mail addresses */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $type

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        break;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $existIdentitie = true;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $key;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (!empty($emails)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return int

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $account = $this->getAccount();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $this->get('cid');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $this->mailCrmId;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function setMailCrmId($id)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $text = $header->{$cacheKey};

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $return = '';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $return;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $cache = App\Cache::staticGet($cacheKey, $email);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function searchByDomains(string $moduleName, string $fieldName, array $emails)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public const IGNORED_MAILS = ['@', 'undisclosed-recipients',  'Undisclosed-recipients', 'undisclosed-recipients@', 'Undisclosed-recipients@', 'Undisclosed recipients@,@', 'undisclosed recipients@,@'];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getFolder()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $action

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $this->actionResult[$action];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        break;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $toEmailUser = $this->findEmailUser($this->get('to_email'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $cacheKey = 'Internal';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->set('cid', $uid);

                Line exceeds 120 characters; contains 191 characters
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $this->get('message_id'), 'rc_user' => $this->getAccountOwner()])->limit(1);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (property_exists($header, $cacheKey)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if (0 != $cache) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string   $fieldName

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return array

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            foreach (explode(',', $emails) as $email) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $account['crm_user_id'];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $header = $this->get('header');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string[] $emails

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $cacheKey = 'MailSearchByEmails' . $moduleName . '_' . $fieldName;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string   $moduleName

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param int $id

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string   $moduleName

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $ids = $queryGenerator->createQuery()->column();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get action result.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $fromEmailUser = $this->findEmailUser($this->get('from_email'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $key = 2;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $cacheKey;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Find email user.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return bool

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $notFound = 0;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $return .= ',';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($queryGenerator->getModuleField($fieldName)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $return = array_merge($return, $ids);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                App\Cache::staticSave($cacheKey, $email, $ids);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (empty($email) || \in_array($email, self::IGNORED_MAILS)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return int|string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $cacheKey = 'Received';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $key = 0;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public static function findEmailUser($emails)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Generation crm unique id.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        foreach ($emails as $email) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /** @var array Action result. */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $folder

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->mailFolder = $folder;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getTypeEmail($returnText = false)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (isset($this->mailType)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $this->mailType;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $uid = hash('sha256', $this->get('from_email') . '|' . $this->get('date') . '|' . $this->get('subject') . '|' . $this->get('message_id'));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return bool|int

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $this->mailCrmId = $query->scalar();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (empty($email) || \in_array($email, self::IGNORED_MAILS)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $queryGenerator->addCondition($fieldName, $email, 'e');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($this->has('cid')) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $return = array_merge($return, $cache);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (App\Cache::staticHas($cacheKey, $domain)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $fieldModel = Vtiger_Module_Model::getInstance($moduleName)->getField($row[0]);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    if (319 === $fieldModel->getUIType()) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $params = [

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $fileInstance = \App\Fields\File::loadFromContent($attachment['attachment'], $attachment['filename'], ['validateAllCodeInjection' => true]);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $db = App\Db::getInstance();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getContent(): string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Function to saving attachments.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $useTime = $this->get('date');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $html .= $attachment['attachment'] . '<hr />';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $encoding = mb_detect_encoding($html, mb_list_encodings(), true);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($encoding && 'UTF-8' !== $encoding) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                ':<\?[^>]+>:', // remove <?xml version="1.0" ... >

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                '~</?o:[^>]*>~', // remove mso tags

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                App\Cache::staticSave($cacheKey, $domain, $crmids);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (empty($emails)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (strpos($emails, ',')) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return implode(',', $return);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $userId = $this->getAccountOwner();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    \App\Log::error("Error - downloaded the file is too big '{$attachment['filename']}', size: {$size}, in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $files;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return 0 === $notFound;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getUniqueId()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($this->mailCrmId) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (empty($this->get('message_id')) || \Config\Modules\OSSMailScanner::$ONE_MAIL_FOR_MULTIPLE_RECIPIENTS) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $query = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $this->getUniqueId()])->limit(1);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $return = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                continue;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $crmids;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $moduleName = $row[1];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $enableFind = false;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($maxSize < ($size = \strlen($attachment['attachment']))) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        foreach ($files as $file) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                'attachmentsid' => $file['attachmentsId'],

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            ])->execute();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $html = preg_replace(

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                ':<!\[[^]<]+\]>:', // remove <![if !mso]and friends

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get email.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function getEmail($cacheKey)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (\is_array($text)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            foreach ($text as $row) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string   $fieldName

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return array crmids

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $queryGenerator = new \App\QueryGenerator($moduleName);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return int[] CRM ids

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $cache = App\Cache::staticGet($cacheKey, $domain);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $enableFind = true;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $fieldName = $row[0];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        $return = array_merge($return, $this->searchByDomains($moduleName, $fieldName, $emails));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $return;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($attachments = $this->get('attachments')) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $html = nl2br($html);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $html = mb_convert_encoding($html, 'UTF-8', $encoding);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'folderid' => \Config\Modules\OSSMailScanner::$mailBodyGraphicDocumentsFolder ?? 'T2',

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    'srcType' => 'url',

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $element->parentNode->replaceChild($yetiforceTag, $element);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $emails = explode(',', $emails);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $emails = (array) $emails;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                } else {

                Line exceeds 120 characters; contains 191 characters
                Open

                                    \App\Log::error("Error downloading the file '{$attachment['filename']}' in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $db->createCommand()->insert('vtiger_ossmailview_files', [

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                'documentsid' => $file['crmid'],

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (!\App\Utils::isHtml($html) || !$this->get('isHtml')) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (\Config\Modules\OSSMailScanner::$attachHtmlAndTxtToMessageBody && \count($attachments) < 2) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if (('.html' === substr($attachment['filename'], -5)) || ('.txt' === substr($attachment['filename'], -4))) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            ], ['', '', '', '', '', '', '', ''], $html);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        libxml_clear_errors();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($file) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $yetiforceTag->textContent = $file['url'];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $yetiforceTag->setAttribute('crm-id', $file['crmid']);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param bool   $returnArray

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function findEmailAddress($field, $searchModule = false, $returnArray = true)

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        $return = array_merge($return, $this->searchByEmails($moduleName, $fieldName, $emails));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'folderid' => 'T2',

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        ];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    continue;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                ':<!DOCTYPE[^>]+>:', // remove <!DOCTYPE ... >

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $searchModule

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $emails = $this->get($field);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'modifiedby' => $userId,

                Line exceeds 120 characters; contains 142 characters
                Open

                                if ($fileInstance && $fileInstance->validateAndSecure() && ($id = App\Fields\File::saveFromContent($fileInstance, $params))) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            return $this->get('parsedContent');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                '~</?body[^>]*>~', // remove body tags

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $previousValue = libxml_use_internal_errors(true);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (!$domain) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if (0 != $cache) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $emailSearchList = OSSMailScanner_Record_Model::getEmailSearchList();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'assigned_user_id' => $userId,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                'ossmailviewid' => $this->mailCrmId,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            foreach ($attachments as $key => $attachment) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                '~\sclass=[\'|\"][^\'\"]+[\'|\"]~i', // remove class attributes

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if ($file = $this->getFileFromImage($img, $params, $attachments)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($file = \App\Fields\File::saveFromContent($fileInstance, $params)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($file = App\Fields\File::saveFromUrl($src, $params)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $file['srcType'] = 'image';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            foreach ($emailSearchList as $field) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $row = explode('=', $field);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function saveAttachments()

                Line exceeds 120 characters; contains 156 characters
                Open

                                $fileInstance = \App\Fields\File::loadFromContent($attachment['attachment'], $attachment['filename'], ['validateAllCodeInjection' => true]);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    \App\Log::error("Error downloading the file '{$attachment['filename']}' in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        libxml_clear_errors();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'created_user_id' => $this->getAccountOwner(),

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        foreach ($doc->getElementsByTagName('img') as $img) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $html;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $element->removeAttribute('src');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if ($fileInstance = \App\Fields\File::saveFromString($src, ['validateAllowedFormat' => 'image'])) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $params['param'] = ['validateAllowedFormat' => 'image'];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            \App\Log::warning("Unsupported photo type, requires verification. ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    public function postProcess()

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $maxSize = \App\Config::getMaxUploadSize();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $files[] = $id;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Treatment mail content with all images and unnecessary trash.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $attachments = $this->get('attachments');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $doc->loadHTML('<?xml encoding="utf-8"?>' . $html);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param array      $attachments

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $fileInstance = App\Fields\File::loadFromContent($attachments[$src]['attachment'], $attachments[$src]['filename'], ['validateAllowedFormat' => 'image']);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                \App\Log::warning("There is no attachment with ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $domain = mb_strtolower(explode('@', $email)[1]);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $crmids = App\Fields\MultiDomain::findIdByDomain($moduleName, $fieldName, $domain);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Find email address.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($searchModule && $searchModule !== $moduleName) {

                Line exceeds 120 characters; contains 219 characters
                Open

                                    \App\Log::error("Error - downloaded the file is too big '{$attachment['filename']}', size: {$size}, in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($fileInstance && $fileInstance->validateAndSecure() && ($id = App\Fields\File::saveFromContent($fileInstance, $params))) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $html = $this->get('body');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $html = \App\Purifier::purifyHtml(str_replace('<?xml encoding="utf-8"?>', '', $html));

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $file = [

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $src = substr($src, 4);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return array|string

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($enableFind) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'createdtime' => $useTime,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                '~</?html[^>]*>~', // remove html tags

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        libxml_use_internal_errors($previousValue);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } elseif (filter_var($src, FILTER_VALIDATE_URL)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if ('url' === $file['srcType']) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $yetiforceTag->setAttribute('attachment-id', $file['attachmentsId']);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    private function getFileFromImage(DOMElement $element, array $params, array &$attachments): array

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $file = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } elseif ('cid:' === substr($src, 0, 4)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $crmids = array_merge($crmids, $cache);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (!empty($emailSearchList)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'modifiedtime' => $useTime,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            foreach ($attachments as $attachment) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            [':<(head|style|script).+?</\1>:is', // remove <head>, <styleand <scriptsections

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $doc = new \DOMDocument('1.0', 'UTF-8');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        libxml_use_internal_errors($previousValue);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                        $file['srcType'] = 'cid';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Post process function.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $html = $doc->saveHTML();

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $file['srcType'] = 'base64';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $params['titlePrefix'] = 'url_';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (isset($attachments[$src])) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                if ($fileInstance && $fileInstance->validateAndSecure()) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    unset($attachments[$src]);

                Line exceeds 120 characters; contains 188 characters
                Open

                            \App\Log::warning("Unsupported photo type, requires verification. ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            } else {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     */

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $return = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if (!$returnArray) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $files = $this->get('files');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'created_user_id' => $userId,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $previousValue = libxml_use_internal_errors(true);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'createdtime' => $this->get('date'),

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $files = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->set('parsedContent', $html);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * Get file from image.

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @return array

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $params['titlePrefix'] = 'base64_';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                continue;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param string $field

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     *

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ($this->has('parsedContent')) {

                Line exceeds 120 characters; contains 124 characters
                Open

                                if (('.html' === substr($attachment['filename'], -5)) || ('.txt' === substr($attachment['filename'], -4))) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    unset($attachments[$key]);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'modifiedby' => $this->getAccountOwner(),

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param array      $params

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        if ('data:' === substr($src, 0, 5)) {

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            if (\Config\Modules\OSSMailScanner::$attachMailBodyGraphicUrl ?? true) {

                Line exceeds 120 characters; contains 169 characters
                Open

                                $fileInstance = App\Fields\File::loadFromContent($attachments[$src]['attachment'], $attachments[$src]['filename'], ['validateAllowedFormat' => 'image']);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $yetiforceTag = $element->ownerDocument->createElement('yetiforce');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        return $file;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'assigned_user_id' => $this->getAccountOwner(),

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $files[] = $file;

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    $params['titlePrefix'] = 'content_';

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                $yetiforceTag->setAttribute('type', 'Documents');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $params = [

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            'modifiedtime' => $this->get('date'),

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        ];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->set('files', $files);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                     * @param DOMElement $element

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $src = trim($element->getAttribute('src'), '\'');

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    'url' => $src,

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                ];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                            $file = [];

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        }

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        $this->set('attachments', $attachments);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                    /**

                Spaces must be used to indent lines; tabs are not allowed
                Open

                                    if ($file = App\Fields\File::saveFromContent($fileInstance, $params)) {

                Line exceeds 120 characters; contains 173 characters
                Open

                                \App\Log::warning("There is no attachment with ID: $src , in mail: {$this->get('date')} | Folder: {$this->getFolder()} | ID: {$this->get('id')}", __CLASS__);

                Spaces must be used to indent lines; tabs are not allowed
                Open

                        } else {

                Class name "OSSMail_Mail_Model" is not in camel caps format
                Open

                class OSSMail_Mail_Model extends \App\Base

                Closing parenthesis of a multi-line function call must be on a line by itself
                Open

                            ], ['', '', '', '', '', '', '', ''], $html);

                Multi-line function call not indented correctly; expected 8 spaces but found 12
                Open

                            ], ['', '', '', '', '', '', '', ''], $html);

                There are no issues that match your filters.

                Category
                Status