YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/AutomaticAssignment/actions/SaveAjax.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            throw new \App\Exceptions\NoPermittedForAdmin('LBL_PERMISSION_DENIED');

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 '64', column '19').
Open

        $response = new Vtiger_Response();

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 '19').
Open

        $response = new Vtiger_Response();

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

The method getRecordModelFromRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($request->getInteger('record'));
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\App\YetiForce\Shop' in method 'checkPermission'.
Open

        if (!\App\YetiForce\Shop::check('YetiForceAutoAssignment')) {

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 'Settings_AutomaticAssignment_Record_Model' in method 'getRecordModelFromRequest'.
Open

            $recordModel = Settings_AutomaticAssignment_Record_Model::getCleanInstance();

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 'Settings_AutomaticAssignment_Record_Model' in method 'getRecordModelFromRequest'.
Open

            $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($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 '\Settings_Vtiger_Tracker_Model' in method 'save'.
Open

            \Settings_Vtiger_Tracker_Model::addDetail($recordModel->getPreviousValue(), $recordId ? array_intersect_key($recordModel->getData(), $recordModel->getPreviousValue()) : $recordModel->getData());

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 check from undeclared class \App\YetiForce\Shop
Open

        if (!\App\YetiForce\Shop::check('YetiForceAutoAssignment')) {

Returning type \Settings_AutomaticAssignment_Record_Model|\Settings_AutomaticAssignment_SaveAjax_Action|\self but getRecordModelFromRequest() is declared to return \Vtiger_Record_Model
Open

        return $recordModel;

Call to undeclared method \Vtiger_Record_Model::validate
Open

        $response->setResult($recordModel->validate());

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

class Settings_AutomaticAssignment_SaveAjax_Action extends Settings_Vtiger_Save_Action
{
    /** {@inheritdoc} */
    public function __construct()
    {

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 Settings_AutomaticAssignment_SaveAjax_Action extends Settings_Vtiger_Save_Action

The class Settings_AutomaticAssignment_SaveAjax_Action is not named in CamelCase.
Open

class Settings_AutomaticAssignment_SaveAjax_Action extends Settings_Vtiger_Save_Action
{
    /** {@inheritdoc} */
    public function __construct()
    {

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

        $this->exposeMethod('preSaveValidation');

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

            $recordModel = $this->getRecordModelFromRequest($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

     *

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 save(App\Request $request)

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

        try {

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

            $result = ['success' => false, 'message' => $e->getDisplayMessage()];

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

        $response->emit();

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

            $result = ['success' => true, 'url' => $recordModel->getModule()->getDefaultUrl()];

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

        $response->setResult($result);

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

            $recordId = $recordModel->getId();

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\YetiForce\Shop::check('YetiForceAutoAssignment')) {

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

    /** {@inheritdoc} */

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

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

    }

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

     *

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

     * Save function.

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

     * @return Vtiger_Record_Model or Module specific 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

        $response->setResult($recordModel->validate());

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

     * @param App\Request $request

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

    public function checkPermission(App\Request $request)

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

            \Settings_Vtiger_Tracker_Model::addDetail($recordModel->getPreviousValue(), $recordId ? array_intersect_key($recordModel->getData(), $recordModel->getPreviousValue()) : $recordModel->getData());

Line exceeds 120 characters; contains 206 characters
Open

            \Settings_Vtiger_Tracker_Model::addDetail($recordModel->getPreviousValue(), $recordId ? array_intersect_key($recordModel->getData(), $recordModel->getPreviousValue()) : $recordModel->getData());

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

        $response = new Vtiger_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

    {

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

        $response->emit();

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

     * Function to get the record model based on the request parameters.

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

     * @return void

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

        $recordModel = $this->getRecordModelFromRequest($request);

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

        $response = new Vtiger_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

            $recordModel->save();

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

    }

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

     * PreSave validation function.

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

     * @param \App\Request $request

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

        $this->exposeMethod('save');

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

        parent::checkPermission($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

    /**

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

            throw new \App\Exceptions\NoPermittedForAdmin('LBL_PERMISSION_DENIED');

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

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

        } catch (\App\Exceptions\AppException $e) {

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 = Settings_AutomaticAssignment_Record_Model::getCleanInstance();

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

    }

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

        } else {

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

        $recordModel->setDataFromRequest($request);

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

        return $recordModel;

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

        if ($request->isEmpty('record')) {

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

            $recordModel = Settings_AutomaticAssignment_Record_Model::getInstanceById($request->getInteger('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

    protected function getRecordModelFromRequest(App\Request $request)

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

class Settings_AutomaticAssignment_SaveAjax_Action extends Settings_Vtiger_Save_Action

There are no issues that match your filters.

Category
Status