YetiForceCompany/YetiForceCRM

View on GitHub
modules/Notification/dashboards/Notifications.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class 'Notification_Module_Model' in method 'process'.
Open

        $notificationModel = Notification_Module_Model::getInstance($moduleName);

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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $viewer->view('dashboards/Notifications.tpl', $moduleName);
        }

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\User' in method 'process'.
Open

        $currentUserId = \App\User::getCurrentUserId();

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_Widget_Model' in method 'process'.
Open

        $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

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 'process'.
Open

        array_unshift($typesNotification, \App\Language::translate('All'));

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('MODULE_NAME', $moduleName);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('WIDGET', $widget);

Call to method getInstance from undeclared class \Vtiger_Widget_Model
Open

        $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('NOTIFICATIONS', $notifications);

Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $currentUserId = \App\User::getCurrentUserId();

Call to undeclared method \Vtiger_Viewer::assign
Open

        $viewer->assign('TYPES_NOTIFICATION', $typesNotification);

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

class Notification_Notifications_Dashboard extends Vtiger_IndexAjax_View

The class Notification_Notifications_Dashboard is not named in CamelCase.
Open

class Notification_Notifications_Dashboard extends Vtiger_IndexAjax_View
{
    public function process(App\Request $request)
    {
        $currentUserId = \App\User::getCurrentUserId();

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

        }

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

        if ($request->has('content')) {

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

            $condition = ['u_#__notification.notification_type' => $request->getByType('type', 'Text')];

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

        $notificationModel = Notification_Module_Model::getInstance($moduleName);

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

        $typesNotification = $notificationModel->getTypes();

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

            $viewer->view('dashboards/Notifications.tpl', $moduleName);

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

        if (!$request->isEmpty('type', true)) {

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

        array_unshift($typesNotification, \App\Language::translate('All'));

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

        $viewer->assign('WIDGET', $widget);

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

        $widget = Vtiger_Widget_Model::getInstance($request->getInteger('linkid'), $currentUserId);

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

        if (empty($limit)) {

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

        $viewer->assign('MODULE_NAME', $moduleName);

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

            $limit = 10;

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

        $viewer->assign('NOTIFICATIONS', $notifications);

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

        $viewer->assign('TYPES_NOTIFICATION', $typesNotification);

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

        $notifications = $notificationModel->getEntriesInstance($limit, $condition);

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

        $limit = $widget->get('limit');

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

            $viewer->view('dashboards/NotificationsContents.tpl', $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

        $currentUserId = \App\User::getCurrentUserId();

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

        $condition = [];

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

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

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

class Notification_Notifications_Dashboard extends Vtiger_IndexAjax_View

There are no issues that match your filters.

Category
Status