YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '42', column '19').
Open

                ->orderBy(new \yii\db\Expression("CASE WHEN setype = 'OSSEmployees' THEN 1 WHEN setype = 'Contacts' THEN 2 ELSE 3 END"))->distinct()->column();

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 '39', column '18').
Open

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])

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 '39', column '48').
Open

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])

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\Db' in method 'createABFile'.
Open

        $db = \App\Db::getInstance();

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\Owner' in method 'createABFile'.
Open

        $usersIds = \App\Fields\Owner::getUsersIds();

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 'createABFile'.
Open

                \App\Utils::saveToFile("cache/addressBook/mails_{$userId}.php", '$bookMails =' . App\Utils::varExport($mails) . ';');

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 'saveLastRecord'.
Open

        \App\Utils::saveToFile(self::LAST_RECORD_CACHE, ['module' => $module, 'record' => $record], '', 0, true);

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 'createABFile'.
Open

                \App\Utils::saveToFile("cache/addressBook/mails_{$userId}.php", '$bookMails =' . App\Utils::varExport($mails) . ';');

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

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

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])
Severity: Critical
Found in modules/OSSMail/models/AddressBook.php by phan

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

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])
Severity: Critical
Found in modules/OSSMail/models/AddressBook.php by phan

Call to method getUsersIds from undeclared class \App\Fields\Owner
Open

        $usersIds = \App\Fields\Owner::getUsersIds();
Severity: Critical
Found in modules/OSSMail/models/AddressBook.php by phan

Call to method __construct from undeclared class \yii\db\Expression
Open

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])
Severity: Critical
Found in modules/OSSMail/models/AddressBook.php by phan

Call to method __construct from undeclared class \yii\db\Expression
Open

                ->orderBy(new \yii\db\Expression("CASE WHEN setype = 'OSSEmployees' THEN 1 WHEN setype = 'Contacts' THEN 2 ELSE 3 END"))->distinct()->column();
Severity: Critical
Found in modules/OSSMail/models/AddressBook.php by phan

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

class OSSMail_AddressBook_Model

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

        $db = \App\Db::getInstance();

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

The class OSSMail_AddressBook_Model is not named in CamelCase.
Open

class OSSMail_AddressBook_Model
{
    /**
     * Table.
     *

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

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

     */

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

    const LAST_RECORD_CACHE = 'cache/addressBook.php';

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

     * Create address book 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

     * @param string $module

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

     * Table.

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

                \App\Utils::saveToFile("cache/addressBook/mails_{$userId}.php", '$bookMails =' . App\Utils::varExport($mails) . ';');

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 false;

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

     * Last record 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

        }

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

    public static function getLastRecord()

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

    /**

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

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])

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

     */

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

    const TABLE = 'u_#__mail_address_book';

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

     * @var string

Line exceeds 120 characters; contains 133 characters
Open

                \App\Utils::saveToFile("cache/addressBook/mails_{$userId}.php", '$bookMails =' . App\Utils::varExport($mails) . ';');

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

     * Clear last record.

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

    public static function clearLastRecord()

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 136 characters
Open

                ->where(['or', ['like', self::TABLE . '.users', ",{$userId},"], ['like', self::TABLE . '.users', "%,{$userId}", false]])

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

                ->orderBy(new \yii\db\Expression("CASE WHEN setype = 'OSSEmployees' THEN 1 WHEN setype = 'Contacts' THEN 2 ELSE 3 END"))->distinct()->column();

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

     * @return int|bool

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

     * Save last record.

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

    public static function saveLastRecord($record, $module)

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

        $mails = [];

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

     * Get last record cache.

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

        $usersIds = \App\Fields\Owner::getUsersIds();

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

     * @var 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

            if ($mails || file_exists("cache/addressBook/mails_{$userId}.php")) {

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

    public static function createABFile()

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

        foreach ($usersIds as $userId) {

Line exceeds 120 characters; contains 159 characters
Open

                ->orderBy(new \yii\db\Expression("CASE WHEN setype = 'OSSEmployees' THEN 1 WHEN setype = 'Contacts' THEN 2 ELSE 3 END"))->distinct()->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

            return require self::LAST_RECORD_CACHE;

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

    /**

Line exceeds 120 characters; contains 184 characters
Open

            $mails = (new \App\Db\Query())->select([new \yii\db\Expression('CONCAT(name,' . $db->quoteValue(' <') . ',email,' . $db->quoteValue('>') . ')'), 'vtiger_crmentity.setype'])

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

                ->from(self::TABLE)->innerJoin('vtiger_crmentity', self::TABLE . '.id = vtiger_crmentity.crmid')

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

                ->where(['or', ['like', self::TABLE . '.users', ",{$userId},"], ['like', self::TABLE . '.users', "%,{$userId}", false]])

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

        if (file_exists(self::LAST_RECORD_CACHE)) {

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

        \App\Utils::saveToFile(self::LAST_RECORD_CACHE, ['module' => $module, 'record' => $record], '', 0, true);

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

     * @param int    $record

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

        unlink(self::LAST_RECORD_CACHE);

Class name "OSSMail_AddressBook_Model" is not in camel caps format
Open

class OSSMail_AddressBook_Model

There are no issues that match your filters.

Category
Status