YetiForceCompany/YetiForceCRM

View on GitHub
app/Mail/ScannerEngine/Outlook.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
0%

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

    public function getNumberFields(?string $searchModuleName = null): array
    {
        $cacheKey = $searchModuleName ?? '-';
        if (isset($this->numberFieldsCache[$cacheKey])) {
            return $this->numberFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 getEmailsFields has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getEmailsFields(?string $searchModuleName = null): array
    {
        $cacheKey = $searchModuleName ?? '-';
        if (isset($this->emailsFieldsCache[$cacheKey])) {
            return $this->emailsFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 getMailType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMailType(): int
    {
        if ($this->has('mailType')) {
            return $this->get('mailType');
        }
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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

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

    public function findRelatedRecords(bool $onlyId = false): array
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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

Avoid using static access to class '\App\TextUtils' in method 'initFromRequest'.
Open

        $this->set('subject', $request->isEmpty('mailSubject') ? '-' : \App\TextUtils::textTruncate($request->getByType('mailSubject', 'Text'), 65535, false));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 '156', column '7').
Open

    public function getEmailsFields(?string $searchModuleName = null): array
    {
        $cacheKey = $searchModuleName ?? '-';
        if (isset($this->emailsFieldsCache[$cacheKey])) {
            return $this->emailsFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'getMailType'.
Open

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($this->get('cc_email'));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'findRelatedRecordsByEmail'.
Open

        return $this->processData['findByEmail'] = \App\Utils::flatten(\App\Mail\RecordFinder::findByEmail($emails, $this->getEmailsFields()));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 'getEmailsFields'.
Open

        $user = \App\User::getCurrentUserModel();
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'getMailType'.
Open

        $from = (bool) \App\Mail\RecordFinder::findUserEmail([$this->get('from_email')]);
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'getMailType'.
Open

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($this->get('bcc_email'));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\TextUtils' in method 'initFromRequest'.
Open

        $this->set('headers', $request->isEmpty('mailHeaders') ? '' : \App\TextUtils::textTruncate($request->getRaw('mailHeaders'), 16777215, false));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 'getUserId'.
Open

        return \App\User::getCurrentUserRealId();
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 '178', column '7').
Open

    public function getNumberFields(?string $searchModuleName = null): array
    {
        $cacheKey = $searchModuleName ?? '-';
        if (isset($this->numberFieldsCache[$cacheKey])) {
            return $this->numberFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'findRelatedRecordsBySubject'.
Open

        return $this->processData['findBySubject'] = \App\Mail\RecordFinder::findBySubject($this->get('subject'), $this->getNumberFields());
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Record' in method 'findRelatedRecords'.
Open

                    'label' => \App\Record::getLabel($id),
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 'findRelatedRecordsByEmail'.
Open

        return $this->processData['findByEmail'] = \App\Utils::flatten(\App\Mail\RecordFinder::findByEmail($emails, $this->getEmailsFields()));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 'getNumberFields'.
Open

        $user = \App\User::getCurrentUserModel();
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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 '106', column '7').
Open

    public function findRelatedRecords(bool $onlyId = false): array
    {
        $ids = $this->findRelatedRecordsByEmail();
        if ($idsBySubject = $this->findRelatedRecordsBySubject()) {
            $ids[] = current($idsBySubject);
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Record' in method 'findRelatedRecords'.
Open

                    'module' => \App\Record::getType($id),
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\Message' in method 'getMailCrmId'.
Open

        $mailCrmId = \App\Mail\Message::findByCid($this->getCid());
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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\Mail\RecordFinder' in method 'getMailType'.
Open

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($this->get('to_email'));
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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

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

        } elseif ($this->has('cc_email')) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "findByEmail" 3 times.
Open

        if (isset($this->processData['findByEmail'])) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "from_email" 3 times.
Open

        $from = (bool) \App\Mail\RecordFinder::findUserEmail([$this->get('from_email')]);
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "findBySubject" 3 times.
Open

        if (isset($this->processData['findBySubject'])) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "to_email" 4 times.
Open

        if ($this->has('to_email')) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "mailType" 3 times.
Open

        if ($this->has('mailType')) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "bcc_email" 5 times.
Open

        } elseif ($this->has('bcc_email')) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "Email" 4 times.
Open

        $this->set('from_email', $request->getByType('mailFrom', 'Email'));
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 "mailCrmId" 3 times.
Open

        if ($this->has('mailCrmId')) {
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.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 getCurrentUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $user = \App\User::getCurrentUserModel();
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.php by phan

Returning type bool|int but getMailCrmId() is declared to return array
Open

        return $mailCrmId;
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.php by phan

Returning type string but getNumberFields() is declared to return array
Open

            return $this->numberFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.php by phan

Assigning array<string>&gt;&gt;&gt;|array<string></string></string> to property but \App\Mail\ScannerEngine\Outlook->numberFieldsCache is string[]
Open

        $this->numberFieldsCache[$cacheKey] = $fields;
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.php by phan

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

        return array_filter(explode(',', \App\User::getCurrentUserModel()->getDetail('mail_scanner_actions')));
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.php by phan

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

        $user = \App\User::getCurrentUserModel();
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.php by phan

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

        return \App\User::getCurrentUserRealId();
Severity: Critical
Found in app/Mail/ScannerEngine/Outlook.php by phan

Returning type string but getEmailsFields() is declared to return array
Open

            return $this->emailsFieldsCache[$cacheKey];
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.php by phan

Assigning array<string>&gt;&gt;&gt;|array<string></string></string> to property but \App\Mail\ScannerEngine\Outlook->emailsFieldsCache is string[]
Open

        $this->emailsFieldsCache[$cacheKey] = $fields;
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.php by phan

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

        $to = false;
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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

            foreach ($ids as &$id) {
Severity: Minor
Found in app/Mail/ScannerEngine/Outlook.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

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

    {

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

        $mailCrmId = \App\Mail\Message::findByCid($this->getCid());

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

            $key = self::MAIL_TYPE_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

     * @param \App\Request $request

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

        $this->set('message_id', $request->getByType('mailMessageId', 'MailId'));

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

            $this->set('to_email', $request->getArray('mailTo', 'Email'));

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

        if (!$request->isEmpty('mailCc', true)) {

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

                    'module' => \App\Record::getType($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

        }

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

     * Scanner engine name.

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 \App\User::getCurrentUserRealId();

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

     * Initialize with request data.

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

            $this->set('body', $request->getForHtml('mailBody'));

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 findRelatedRecords(bool $onlyId = false): array

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

        $ids = $this->findRelatedRecordsByEmail();

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

        if (!$onlyId) {

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

    public function findRelatedRecordsBySubject(): array

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

        $cacheKey = $searchModuleName ?? '-';

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

        if (isset($this->emailsFieldsCache[$cacheKey])) {

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

                $field = explode('|', $field);

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

                if (($searchModuleName && $searchModuleName !== $field[1]) || !\in_array($field[3], [13, 319])) {

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

    /** {@inheritdoc} */

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

        } elseif ($this->has('cc_email')) {

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

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($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

        if (!$request->isEmpty('mailBcc', true)) {

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

            $this->set('bcc_email', $request->getArray('mailBcc', 'Email'));

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

        $emails[] = $this->get('from_email');

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

    /** {@inheritdoc} */

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

        $key = self::MAIL_TYPE_RECEIVED;

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

        } elseif ($from) {

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

    {

Line exceeds 120 characters; contains 150 characters
Open

        $this->set('headers', $request->isEmpty('mailHeaders') ? '' : \App\TextUtils::textTruncate($request->getRaw('mailHeaders'), 16777215, false));

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

        $this->set('from_email', $request->getByType('mailFrom', 'Email'));

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

    /** {@inheritdoc} */

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 findRelatedRecordsByEmail(): array

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

        return $this->processData['findByEmail'] = \App\Utils::flatten(\App\Mail\RecordFinder::findByEmail($emails, $this->getEmailsFields()));

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

     */

Line exceeds 120 characters; contains 159 characters
Open

        $this->set('subject', $request->isEmpty('mailSubject') ? '-' : \App\TextUtils::textTruncate($request->getByType('mailSubject', 'Text'), 65535, 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

    public $name = 'Outlook';

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

    {

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

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($this->get('to_email'));

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

        if (!$request->isEmpty('mailTo')) {

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

    {

Line exceeds 120 characters; contains 143 characters
Open

        return $this->processData['findByEmail'] = \App\Utils::flatten(\App\Mail\RecordFinder::findByEmail($emails, $this->getEmailsFields()));

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

        $user = \App\User::getCurrentUserModel();

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

        return $fields;

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

    public function getNumberFields(?string $searchModuleName = null): array

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

        return array_filter(explode(',', \App\User::getCurrentUserModel()->getDetail('mail_scanner_actions')));

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

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

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

    public function getMailType(): int

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

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

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

        $this->set('headers', $request->isEmpty('mailHeaders') ? '' : \App\TextUtils::textTruncate($request->getRaw('mailHeaders'), 16777215, 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

                    'label' => \App\Record::getLabel($id),

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

            return $this->emailsFieldsCache[$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

        $this->set('mailCrmId', $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

        }

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

                    'id' => $id,

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

        if (isset($this->processData['findByEmail'])) {

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 (isset($this->processData['findBySubject'])) {

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

        if ($mailScannerFields = $user->getDetail('mail_scanner_fields')) {

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

                $fields[$field[1]][$field[3]][] = $field[2];

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

        $from = (bool) \App\Mail\RecordFinder::findUserEmail([$this->get('from_email')]);

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

            $to = (bool) \App\Mail\RecordFinder::findUserEmail($this->get('bcc_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 $ids;

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

    /** {@inheritdoc} */

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

        $cacheKey = $searchModuleName ?? '-';

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

        $this->set('subject', $request->isEmpty('mailSubject') ? '-' : \App\TextUtils::textTruncate($request->getByType('mailSubject', 'Text'), 65535, false));

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

        if ($idsBySubject = $this->findRelatedRecordsBySubject()) {

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

            foreach ($ids as &$id) {

Line exceeds 120 characters; contains 140 characters
Open

        return $this->processData['findBySubject'] = \App\Mail\RecordFinder::findBySubject($this->get('subject'), $this->getNumberFields());

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

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

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

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

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

        $this->set('date', $request->getByType('mailDateTimeCreated', 'DateTimeInIsoFormat'));

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 (!$request->isEmpty('mailBody', true)) {

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

                $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

     * @var string

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

        return $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

        if ($from && $to) {

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

    /** {@inheritdoc} */

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('cc_email', $request->getArray('mailCc', 'Email'));

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

            $emails = array_merge($emails, $this->get('cc_email'));

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

            return $this->processData['findBySubject'];

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->emailsFieldsCache[$cacheKey] = $fields;

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

                $field = explode('|', $field);

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

    public function getExceptions(): 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

            foreach (explode(',', trim($mailScannerFields, ',')) as $field) {

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

        $this->numberFieldsCache[$cacheKey] = $fields;

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

    /** {@inheritdoc} */

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

        $user = \App\User::getCurrentUserModel();

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

        if ($mailScannerFields = $user->getDetail('mail_scanner_fields')) {

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 getActions(): array

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

    /** {@inheritdoc} */

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

        $to = false;

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

        $this->set('mailType', $key);

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

        $emails = $this->get('to_email');

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

            $emails = array_merge($emails, $this->get('bcc_email'));

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

    public function getEmailsFields(?string $searchModuleName = null): array

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

            foreach (explode(',', trim($mailScannerFields, ',')) as $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

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

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

        } elseif ($this->has('bcc_email')) {

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

    public function getUserId(): int

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

     * @return void

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

        $fields = [];

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

                if (($searchModuleName && $searchModuleName !== $field[1]) || 4 !== (int) $field[3]) {

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

    /** {@inheritdoc} */

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

            $key = self::MAIL_TYPE_SENT;

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->processData['findByEmail'];

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('bcc_email')) {

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

        return $this->processData['findBySubject'] = \App\Mail\RecordFinder::findBySubject($this->get('subject'), $this->getNumberFields());

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

    {

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

    /** {@inheritdoc} */

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 initFromRequest(\App\Request $request)

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

            $ids[] = current($idsBySubject);

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('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

    /** {@inheritdoc} */

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

        $fields = [];

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

                $fields[$field[1]][$field[3]][] = $field[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

        if (isset($this->numberFieldsCache[$cacheKey])) {

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

            return $this->numberFieldsCache[$cacheKey];

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

        return $fields;

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

            }

There are no issues that match your filters.

Category
Status