YetiForceCompany/YetiForceCRM

View on GitHub
app/Mail/Message.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            throw new \App\Exceptions\NotAllowedMethod('ERR_PARAMETER_DOES_NOT_EXIST|$engineName|' . $engineName, 406);
Severity: Minor
Found in app/Mail/Message.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 '47', column '21').
Open

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $cid])->scalar();
Severity: Minor
Found in app/Mail/Message.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 '67', column '21').
Open

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $messageId, 'rc_user' => $rcUser])->scalar();
Severity: Minor
Found in app/Mail/Message.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

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

        if (\App\Cache::staticHas('App\Mail\Message::findByCid', $cid)) {
Severity: Minor
Found in app/Mail/Message.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 'findByMessageId'.
Open

        if (\App\Cache::staticHas('App\Mail\Message::findByMessageId', $key)) {
Severity: Minor
Found in app/Mail/Message.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 'findByMessageId'.
Open

            return \App\Cache::staticGet('App\Mail\Message::findByMessageId', $key);
Severity: Minor
Found in app/Mail/Message.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 'findByCid'.
Open

            return \App\Cache::staticGet('App\Mail\Message::findByCid', $cid);
Severity: Minor
Found in app/Mail/Message.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 'findByMessageId'.
Open

        \App\Cache::staticSave('App\Mail\Message::findByMessageId', $key, $mailCrmId);
Severity: Minor
Found in app/Mail/Message.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 'findByCid'.
Open

        \App\Cache::staticSave('App\Mail\Message::findByCid', $cid, $mailCrmId);
Severity: Minor
Found in app/Mail/Message.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 "App\Mail\Message::findByMessageId" 3 times.
Open

        if (\App\Cache::staticHas('App\Mail\Message::findByMessageId', $key)) {
Severity: Critical
Found in app/Mail/Message.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 "App\Mail\Message::findByCid" 3 times.
Open

        if (\App\Cache::staticHas('App\Mail\Message::findByCid', $cid)) {
Severity: Critical
Found in app/Mail/Message.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.

Saw an @param annotation for cid, but it was not found in the param list of function findByMessageId(string $messageId, int $rcUser) : bool|int
Open

     * @param string $cid
Severity: Info
Found in app/Mail/Message.php by phan

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

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $cid])->scalar();
Severity: Critical
Found in app/Mail/Message.php by phan

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

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $messageId, 'rc_user' => $rcUser])->scalar();
Severity: Critical
Found in app/Mail/Message.php by phan

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

     * @param string $engineName
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        return new $class();
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @param string $cid
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        if (!class_exists($class)) {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * Get instance by scanner engine.
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    public static function getScannerByEngine(string $engineName): ScannerEngine\Base
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @return \App\Mail\ScannerEngine\Base
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * Find by crm unique id.
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

            throw new \App\Exceptions\NotAllowedMethod('ERR_PARAMETER_DOES_NOT_EXIST|$engineName|' . $engineName, 406);
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        $class = "App\\Mail\\ScannerEngine\\{$engineName}";
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    public static function findByMessageId(string $messageId, int $rcUser)
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        \App\Cache::staticSave('App\Mail\Message::findByCid', $cid, $mailCrmId);
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @return int|bool
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        return $mailCrmId;
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        $key = "$messageId|$rcUser";
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

            return \App\Cache::staticGet('App\Mail\Message::findByCid', $cid);
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

            return \App\Cache::staticGet('App\Mail\Message::findByMessageId', $key);
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $messageId, 'rc_user' => $rcUser])->scalar();
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    public static function findByCid(string $cid)
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        return $mailCrmId;
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @return int|bool
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $cid])->scalar();
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @param int    $rcUser
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        if (\App\Cache::staticHas('App\Mail\Message::findByMessageId', $key)) {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

Line exceeds 120 characters; contains 160 characters
Open

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['uid' => $messageId, 'rc_user' => $rcUser])->scalar();
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

Line exceeds 120 characters; contains 132 characters
Open

        $mailCrmId = (new \App\Db\Query())->select(['ossmailviewid'])->from('vtiger_ossmailview')->where(['cid' => $cid])->scalar();
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        }
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        if (\App\Cache::staticHas('App\Mail\Message::findByCid', $cid)) {
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

        \App\Cache::staticSave('App\Mail\Message::findByMessageId', $key, $mailCrmId);
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * Find by message id and rc user id.
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @param string $cid
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

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

     * @param string $messageId
Severity: Minor
Found in app/Mail/Message.php by phpcodesniffer

There are no issues that match your filters.

Category
Status