YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSTimeControl/handlers/TimeControl.php

Summary

Maintainability
A
0 mins
Test Coverage
F
42%

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

        $wfs = new VTWorkflowManager();

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 '41', column '14').
Open

        $wfs = new VTWorkflowManager();

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 'Vtiger_Record_Model' in method 'entityAfterUnLink'.
Open

        $recordModel = Vtiger_Record_Model::getInstanceById($params['destinationRecordId'], $params['destinationModule']);

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\Language' in method 'editViewPreSave'.
Open

                'message' => App\Language::translate('LBL_DATE_NOT_SHOULD_BE_GREATER_THAN_24H', $recordModel->getModuleName())

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\DateTime' in method 'editViewPreSave'.
Open

        if (\App\Fields\DateTime::getDiff($start, $end, 'minutes') > 24 * 60) {

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

Argument 2 (executionCondition) is int but \VTWorkflowManager::getWorkflowsForModule() takes false|string defined at /code/modules/com_vtiger_workflow/VTWorkflowManager.php:180
Open

        $workflows = $wfs->getWorkflowsForModule($params['destinationModule'], VTWorkflowManager::$MANUAL);

Argument 2 (executionCondition) is int but \VTWorkflowManager::getWorkflowsForModule() takes false|string defined at /code/modules/com_vtiger_workflow/VTWorkflowManager.php:180
Open

        $workflows = $wfs->getWorkflowsForModule($eventHandler->getModuleName(), VTWorkflowManager::$MANUAL);

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

class OSSTimeControl_TimeControl_Handler

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 10.
Open

<?php

The class OSSTimeControl_TimeControl_Handler is not named in CamelCase.
Open

class OSSTimeControl_TimeControl_Handler
{
    /**
     * EntityAfterUnLink handler function.
     *

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

     * @param App\EventHandler $eventHandler

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

    public function entityAfterUnLink(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 entityAfterDelete(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

        $recordModel = $eventHandler->getRecordModel();

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

    }

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

        $params = $eventHandler->getParams();

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

        $recordModel = Vtiger_Record_Model::getInstanceById($params['destinationRecordId'], $params['destinationModule']);

Line exceeds 120 characters; contains 122 characters
Open

        $recordModel = Vtiger_Record_Model::getInstanceById($params['destinationRecordId'], $params['destinationModule']);

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

                $workflow->performTasks($recordModel);

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

                $workflow->performTasks($recordModel);

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

     * EntityBeforeSave 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

        $response = [

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

                'result' => 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

            $response = [

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

        foreach ($workflows as &$workflow) {

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

        $wfs = new VTWorkflowManager();

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

    /**

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

     * EditViewPreSave 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

     * 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

        $workflows = $wfs->getWorkflowsForModule($eventHandler->getModuleName(), VTWorkflowManager::$MANUAL);

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

    public function editViewPreSave(App\EventHandler $eventHandler)

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

        $start = $recordModel->get('date_start') . ' ' . $recordModel->get('time_start');

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

            if ($workflow->evaluate($recordModel)) {

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

    }

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

        $workflows = $wfs->getWorkflowsForModule($params['destinationModule'], VTWorkflowManager::$MANUAL);

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

        foreach ($workflows as &$workflow) {

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

        $this->entityAfterSave($eventHandler);

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

    public function entityBeforeSave(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

    }

Line exceeds 120 characters; contains 126 characters
Open

                'message' => App\Language::translate('LBL_DATE_NOT_SHOULD_BE_GREATER_THAN_24H', $recordModel->getModuleName())

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

        return $response;

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

        $wfs = new VTWorkflowManager();

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 (\App\Fields\DateTime::getDiff($start, $end, 'minutes') > 24 * 60) {

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

        $end = strtotime($recordModel->get('due_date') . ' ' . $recordModel->get('time_end'));

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

        $recordModel->set('sum_time', round(abs(ceil((($end - $start) / 60) * 100) / 100), 0));

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

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

            if ($workflow->evaluate($recordModel)) {

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

    }

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

    public function entityChangeState(App\EventHandler $eventHandler)

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

     * EntityAfterUnLink 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

    {

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

     */

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

        $end = $recordModel->get('due_date') . ' ' . $recordModel->get('time_end');

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

                'message' => App\Language::translate('LBL_DATE_NOT_SHOULD_BE_GREATER_THAN_24H', $recordModel->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

    {

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

    /**

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

        $start = strtotime($recordModel->get('date_start') . ' ' . $recordModel->get('time_start'));

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

        $this->entityAfterSave($eventHandler);

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

            'result' => true,

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

            ];

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

class OSSTimeControl_TimeControl_Handler

There are no issues that match your filters.

Category
Status