YetiForceCompany/YetiForceCRM

View on GitHub
modules/Documents/relations/GetRelatedRecord.php

Summary

Maintainability
A
0 mins
Test Coverage
F
22%

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

        $modules = (new \App\Db\Query())->select(['vtiger_tab.name'])

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\Privilege' in method 'getConfigAdvancedConditionsByColumns'.
Open

            if (!\App\Privilege::isPermitted($moduleName)) {

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 method addJoin from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator->addJoin(['INNER JOIN', $tableName, "{$tableName}.notesid = vtiger_crmentity.crmid"])

Parameter $queryGenerator has undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

    public function loadAdvancedConditionsByColumns(App\QueryGenerator $queryGenerator, array $searchParam): void

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

        $queryGenerator->addNativeCondition(["{$tableName}.notesid" => $this->relationModel->get('parentRecord')->getId()]);

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

        return (bool) App\Db::getInstance()->createCommand()->delete(self::TABLE_NAME, [

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

        $queryGenerator->addJoin(['INNER JOIN', $tableName, "{$tableName}.crmid = vtiger_crmentity.crmid"]);

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

        $modules = (new \App\Db\Query())->select(['vtiger_tab.name'])

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

class Documents_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction

The class Documents_GetRelatedRecord_Relation is not named in CamelCase.
Open

class Documents_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction
{
    /**
     * @var string Name of the table that stores relations.
     */

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

    {

Line exceeds 120 characters; contains 124 characters
Open

        $queryGenerator->addNativeCondition(["{$tableName}.notesid" => $this->relationModel->get('parentRecord')->getId()]);

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

     * @param App\QueryGenerator $queryGenerator QueryGenerator for the list of records to be tapered based on the relationship

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

    public function getConfigAdvancedConditionsByColumns(): array

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

            ->column();

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

        return ['relatedModules' => $modules];

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

    /** {@inheritdoc} */

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

    /** {@inheritdoc} */

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

     * Load advanced conditions relationship by custom 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

    public function loadAdvancedConditionsByColumns(App\QueryGenerator $queryGenerator, array $searchParam): void

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

            ->addNativeCondition(["{$tableName}.crmid" => $searchParam['value']]);

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

    public function create(int $sourceRecordId, int $destinationRecordId): bool

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

    {

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

        }

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 function getRelationType(): int

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

        $queryGenerator->addJoin(['INNER JOIN', $tableName, "{$tableName}.crmid = vtiger_crmentity.crmid"]);

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

                unset($modules[$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

            ->innerJoin('vtiger_tab', 'vtiger_tab.tabid = vtiger_relatedlists.tabid')

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

    }

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

        $queryGenerator->addNativeCondition(["{$tableName}.notesid" => $this->relationModel->get('parentRecord')->getId()]);

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

        $queryGenerator->addJoin(['INNER JOIN', $tableName, "{$tableName}.notesid = vtiger_crmentity.crmid"])

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

    {

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

        $modules = (new \App\Db\Query())->select(['vtiger_tab.name'])

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

            ->where(['and', ['vtiger_tab.presence' => 0], ['vtiger_relatedlists.name' => 'getAttachments']])

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

        foreach ($modules as $key => $moduleName) {

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

            'crmid' => $destinationRecordId,

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 Name of the table that stores relations.

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

        $queryGenerator = $this->relationModel->getQueryGenerator();

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

        $tableName = self::TABLE_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

     * Get configuration advanced conditions relationship by custom 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

            ->from('vtiger_relatedlists')

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

            if (!\App\Privilege::isPermitted($moduleName)) {

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

            'notesid' => $sourceRecordId,

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

        return Vtiger_Relation_Model::RELATION_M2M;

Line exceeds 120 characters; contains 127 characters
Open

     * @param App\QueryGenerator $queryGenerator QueryGenerator for the list of records to be tapered based on the relationship

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

        return (bool) App\Db::getInstance()->createCommand()->delete(self::TABLE_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

    public function transfer(int $relatedRecordId, int $fromRecordId, int $toRecordId): bool

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

    public const TABLE_NAME = 'vtiger_senotesrel';

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

    public function getQuery()

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

     * @param array              $searchParam    Related record for which we are filtering the list of records

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

        $tableName = static::TABLE_NAME;

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

    public function delete(int $sourceRecordId, int $destinationRecordId): bool

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

class Documents_GetRelatedRecord_Relation extends \App\Relation\RelationAbstraction

There are no issues that match your filters.

Category
Status