YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/BusinessHours/views/Edit.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\App\Language' in method 'getBreadcrumbTitle'.
Open

        return \App\Language::translate('LBL_BUSINESS_HOURS', $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 'Settings_BusinessHours_Record_Model' in method 'initialize'.
Open

            $recordModel = Settings_BusinessHours_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 '\App\Fields\Date' in method 'initialize'.
Open

        $viewer->assign('DAYS_OF_THE_WEEK', \App\Fields\Date::getShortDaysOfWeek());

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

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

        } else {
            $recordModel = Settings_BusinessHours_Record_Model::getCleanInstance();
            $viewer->assign('MODE', '');
        }

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 'Settings_BusinessHours_Record_Model' in method 'initialize'.
Open

            $recordModel = Settings_BusinessHours_Record_Model::getInstanceById($recordId);

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

Define a constant instead of duplicating this literal "record" 3 times.
Open

        if ($request->has('record') && !$request->isEmpty('record', true)) {

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('DAYS_OF_THE_WEEK', \App\Fields\Date::getShortDaysOfWeek());

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('QUALIFIED_MODULE', $request->getModule(false));

Call to undeclared method \Vtiger_Viewer::assign
Open

            $viewer->assign('MODE', 'edit');

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('RECORD_MODEL', $recordModel);

Call to undeclared method \Vtiger_Viewer::assign
Open

            $viewer->assign('MODE', '');

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('MODULE', $request->getModule());

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('RECORD_ID', $recordId);

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

class Settings_BusinessHours_Edit_View extends Settings_Vtiger_Index_View

The class Settings_BusinessHours_Edit_View is not named in CamelCase.
Open

class Settings_BusinessHours_Edit_View extends Settings_Vtiger_Index_View
{
    /** {@inheritdoc} */
    public function getBreadcrumbTitle(App\Request $request)
    {

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

    /** {@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

        $this->initialize($request);

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

        $this->getViewer($request)->view('EditView.tpl', $request->getModule(false));

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

            'modules.Settings.' . $request->getModule() . '.resources.Edit',

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

            $viewer->assign('MODE', '');

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

        $viewer->assign('RECORD_MODEL', $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

        ]));

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

    }

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 ($request->has('record') && !$request->isEmpty('record', true)) {

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('DAYS_OF_THE_WEEK', \App\Fields\Date::getShortDaysOfWeek());

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

        return \App\Language::translate('LBL_BUSINESS_HOURS', $request->getModule());

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

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

            $viewer->assign('MODE', 'edit');

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

            $recordModel = Settings_BusinessHours_Record_Model::getCleanInstance();

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

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

    public function initialize(App\Request $request)

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

            $recordModel = Settings_BusinessHours_Record_Model::getInstanceById($recordId);

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

            $recordId = $request->getInteger('record');

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

        $viewer->assign('RECORD_ID', $recordId);

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

        return array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts([

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

    public function process(App\Request $request)

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

        $recordId = null;

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

        $viewer->assign('QUALIFIED_MODULE', $request->getModule(false));

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

        $viewer->assign('MODULE', $request->getModule());

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

class Settings_BusinessHours_Edit_View extends Settings_Vtiger_Index_View

There are no issues that match your filters.

Category
Status