YetiForceCompany/YetiForceCRM

View on GitHub
modules/API/handlers/CardDAV.php

Summary

Maintainability
A
0 mins
Test Coverage
F
52%

Avoid using static access to class '\App\Integrations\Dav\Card' in method 'entityAfterDelete'.
Open

        \App\Integrations\Dav\Card::deleteByCrmId($eventHandler->getRecordModel()->getId());
Severity: Minor
Found in modules/API/handlers/CardDAV.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

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

                \App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/API/handlers/CardDAV.php by phan

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

            \App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/API/handlers/CardDAV.php by phan

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

class API_CardDAV_Handler

The class API_CardDAV_Handler is not named in CamelCase.
Open

class API_CardDAV_Handler
{
    /**
     * @var array CardDav fields structure.
     */
Severity: Minor
Found in modules/API/handlers/CardDAV.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

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

     * @var array CardDav fields structure.

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

    const TABLES = [

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

        if ($isNew) {

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

    }

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

        $moduleName = $eventHandler->getModuleName();

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

    /**

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

            'firstname', 'lastname', 'email', 'secondary_email', 'phone', 'mobile', 'description', 'jobtitle', 'addresslevel1a', 'addresslevel2a', 'addresslevel3a', 'addresslevel4a', 'addresslevel5a', 'addresslevel6a', 'addresslevel7a', 'addresslevel8a', 'addresslevel1b', 'addresslevel2b', 'addresslevel3b', 'addresslevel4b', 'addresslevel5b', 'addresslevel6b', 'addresslevel7b', 'addresslevel8b', 'localnumbera', 'localnumberb'

Line exceeds 120 characters; contains 266 characters
Open

            'name', 'last_name', 'business_phone', 'business_mail', 'private_phone', 'private_mail', 'description', 'company_name', 'street', 'city', 'state', 'code', 'country', 'ship_street', 'ship_city', 'ship_state', 'ship_code', 'ship_country', 'secondary_phone'

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

     * @var array CardDav tables structure.

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

     * EntityAfterSave handler function.

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 entityAfterSave(App\EventHandler $eventHandler)

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

                $info = static::TABLES[$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

            \App\Db::getInstance()->createCommand()

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

     */

Line exceeds 120 characters; contains 429 characters
Open

            'firstname', 'lastname', 'email', 'secondary_email', 'phone', 'mobile', 'description', 'jobtitle', 'addresslevel1a', 'addresslevel2a', 'addresslevel3a', 'addresslevel4a', 'addresslevel5a', 'addresslevel6a', 'addresslevel7a', 'addresslevel8a', 'addresslevel1b', 'addresslevel2b', 'addresslevel3b', 'addresslevel4b', 'addresslevel5b', 'addresslevel6b', 'addresslevel7b', 'addresslevel8b', 'localnumbera', 'localnumberb'

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

     *

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

        $moduleName = $eventHandler->getModuleName();

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

        $isNew = $recordModel->isNew();

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

                \App\Db::getInstance()->createCommand()

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

                return 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

     * EntityAfterDelete handler function.

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 (isset(static::TABLES[$moduleName])) {

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

    const FIELDS = [

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

            'name', 'last_name', 'business_phone', 'business_mail', 'private_phone', 'private_mail', 'description', 'company_name', 'street', 'city', 'state', 'code', 'country', 'ship_street', 'ship_city', 'ship_state', 'ship_code', 'ship_country', 'secondary_phone'

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

        $recordModel = $eventHandler->getRecordModel();

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

        foreach (static::FIELDS[$moduleName] as $fieldName) {

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

                    ->update($info[0], ['dav_status' => 1], [$info[1] => $recordModel->getId()])->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

     * @param App\EventHandler $eventHandler

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

     * @param \App\EventHandler $eventHandler

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

    public function entityChangeState(App\EventHandler $eventHandler)

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 entityAfterDelete(App\EventHandler $eventHandler)

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

     * EntityChangeState handler function.

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\EventHandler $eventHandler

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

            $row = static::TABLES[$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

                ->update($row[0], ['dav_status' => 1], [$row[1] => $eventHandler->getRecordModel()->getId()])->execute();

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

        'Contacts' => ['vtiger_contactdetails', 'contactid'],

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

            return true;

Line exceeds 120 characters; contains 121 characters
Open

                ->update($row[0], ['dav_status' => 1], [$row[1] => $eventHandler->getRecordModel()->getId()])->execute();

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

        'OSSEmployees' => [

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

        'Contacts' => [

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

        $delta = $recordModel->getPreviousValue();

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

            if (isset($delta[$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

        'OSSEmployees' => ['vtiger_ossemployees', 'ossemployeesid'],

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\Integrations\Dav\Card::deleteByCrmId($eventHandler->getRecordModel()->getId());

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

class API_CardDAV_Handler

There are no issues that match your filters.

Category
Status