YetiForceCompany/YetiForceCRM

View on GitHub
modules/ServiceContracts/views/PolicyTemplatesAjax.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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\Module' in method 'slaPolicyTemplate'.
Open

        $viewer->assign('TARGET_MODULE_ID', \App\Module::getModuleId($request->getByType('targetModule', \App\Purifier::ALNUM)));

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\ServiceContracts' in method 'slaPolicyTemplate'.
Open

        $sla = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'));

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

        $this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

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\ServiceContracts' in method 'slaPolicyCustom'.
Open

        $viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());

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

        if (!$this->record->isViewable() || !$this->record->isPermitted('ServiceContractsSla') || !App\Privilege::isPermitted($request->getByType('targetModule', \App\Purifier::ALNUM))) {

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 \Vtiger_Viewer::assign
Open

        $viewer->assign('SELECTED_TEMPLATE', $slaId);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('TARGET_MODULE_ID', \App\Module::getModuleId($request->getByType('targetModule', \App\Purifier::ALNUM)));

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('RECORD', $this->record);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('SLA_POLICY_ROWS', [$index => $defaultEmptyData]);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());

Avoid excessively long class names like ServiceContracts_PolicyTemplatesAjax_View. Keep class name length under 40.
Open

class ServiceContracts_PolicyTemplatesAjax_View extends Vtiger_Index_View
{
    use \App\Controller\ExposeMethod;

    /** @var Vtiger_Record_Model Record model instance. */

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

Source https://phpmd.org/rules/naming.html#longclassname

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

class ServiceContracts_PolicyTemplatesAjax_View extends Vtiger_Index_View

The class ServiceContracts_PolicyTemplatesAjax_View is not named in CamelCase.
Open

class ServiceContracts_PolicyTemplatesAjax_View extends Vtiger_Index_View
{
    use \App\Controller\ExposeMethod;

    /** @var Vtiger_Record_Model Record model instance. */

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

     * Construct.

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

    public function checkPermission(App\Request $request)

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

    {

Line exceeds 120 characters; contains 129 characters
Open

        $viewer->assign('TARGET_MODULE_ID', \App\Module::getModuleId($request->getByType('targetModule', \App\Purifier::ALNUM)));

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

            'idle_time' => '1:d',

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

    {

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

            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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

        $this->exposeMethod('slaPolicyTemplate');

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

    public function slaPolicyTemplate(App\Request $request)

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

        $index = $request->getInteger('index', time());

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

            'policy_type' => 2,

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

    }

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

    use \App\Controller\ExposeMethod;

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

    public function __construct()

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

        parent::__construct();

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

    public $record;

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

        $slaId = $sla[0]['sla_policy_id'] ?? 0;

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

            'business_hours' => '',

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

        $viewer = $this->getViewer($request);

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

    /** @var Vtiger_Record_Model Record model instance. */

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

        $viewer->assign('ALL_BUSINESS_HOURS', \App\Utils\ServiceContracts::getAllBusinessHours());

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

        $viewer->assign('SLA_POLICY_ROWS', [$index => $defaultEmptyData]);

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 $viewer->view('SlaPolicyTemplate.tpl', $moduleName);

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

        $this->exposeMethod('slaPolicyCustom');

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

        $defaultEmptyData = [

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

            'resolve_time' => '1:d',

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

        $this->record = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $request->getModule());

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

        $moduleName = $request->getModule();

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

        return $viewer->view('CustomConditions.tpl', $moduleName);

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

        $viewer = $this->getViewer($request);

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

    public function slaPolicyCustom(App\Request $request)

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

    /**

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

        $sla = \App\Utils\ServiceContracts::getSlaPolicyForServiceContracts($request->getInteger('record'));

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

        $viewer->assign('TARGET_MODULE_ID', \App\Module::getModuleId($request->getByType('targetModule', \App\Purifier::ALNUM)));

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

        $moduleName = $request->getModule();

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

            'id' => 0,

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

            'conditions' => '[]',

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

        if (!$this->record->isViewable() || !$this->record->isPermitted('ServiceContractsSla') || !App\Privilege::isPermitted($request->getByType('targetModule', \App\Purifier::ALNUM))) {

Line exceeds 120 characters; contains 187 characters
Open

        if (!$this->record->isViewable() || !$this->record->isPermitted('ServiceContractsSla') || !App\Privilege::isPermitted($request->getByType('targetModule', \App\Purifier::ALNUM))) {

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

        $viewer->assign('SELECTED_TEMPLATE', $slaId);

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

            'reaction_time' => '1:d',

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

        $viewer->assign('RECORD', $this->record);

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

class ServiceContracts_PolicyTemplatesAjax_View extends Vtiger_Index_View

There are no issues that match your filters.

Category
Status