YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSTimeControl/textparsers/UserGroup.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '67', column '15').
Open

        return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('Role', 'Users') . '</th>';

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';

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

            $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->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

Avoid using static access to class '\App\Fields\RangeTime' in method 'process'.
Open

            $html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';

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

                'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->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

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

            $html .= "<td style=\"{$bodyStyle}\">" . $user . '</td>';

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.

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';

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.

Reference to instance property moduleName from undeclared class \App\TextParser
Open

                'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),

Call to undeclared method \App\Db\Query::select
Open

        return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();

Reference to instance property moduleName from undeclared class \App\TextParser
Open

            $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->moduleName);

Call to method getParam from undeclared class \App\TextParser (Did you mean class \Tests\App\TextParser)
Open

        $ids = $this->textParser->getParam('pdf')->getVariable('recordsId');

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

class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base

The class OSSTimeControl_UserGroup_Textparser is not named in CamelCase.
Open

class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base
{
    /** @var string Class name */
    public $name = 'LBL_TIME_CONTROL_USER_GROUP';

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

    /** @var mixed Parser type */

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

        return $html . '</tbody></table>';

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

     * @return string

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

    {

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

        $bodyStyle = 'font-size:8px;border:1px solid #ddd;padding:0px4px;';

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

            $html .= "<td style=\"{$bodyStyle}\">" . $user . '</td>';

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

            $html .= "<td style=\"{$bodyStyle} text-align:center;\">" . $data['role'] . '</td>';

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

        $users = [];

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

        if (!\is_array($ids)) {

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 getUserList()

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

            $html .= '<tr>';

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

            $html .= '</tr>';

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

     * Process.

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

     *

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('User Name', 'Users') . '</th>';

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

    }

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

        $ids = $this->textParser->getParam('pdf')->getVariable('recordsId');

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

            }

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

            $user = $recordModel->getDisplayValue('assigned_user_id', $recordId, true);

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

            $users[$user] = [

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

        $html .= '<table class="table" style="border-collapse:collapse;width:100%;"><thead><tr>';

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('Role', 'Users') . '</th>';

Line exceeds 120 characters; contains 138 characters
Open

            $html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';

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

            $html .= "<td style=\"{$bodyStyle} text-align:center;\">" . \App\Fields\RangeTime::displayElapseTime($data['time']) . '</td>';

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

            if (!$recordModel->isViewable()) {

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

            ];

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

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';

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

    {

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

            $ids = [$ids];

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

    public function getRoleName($userId)

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

    {

Line exceeds 120 characters; contains 216 characters
Open

        return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();

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

        $html = '';

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

        $html .= '</tr></thead><tbody>';

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

    public $name = 'LBL_TIME_CONTROL_USER_GROUP';

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

        $headerStyle = 'font-size:9px;padding:0px 4px;text-align:center;';

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

    public $type = 'pdf';

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

                'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),

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

    public function process()

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

        foreach ($ids as $recordId) {

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

                continue;

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

    /** @var string Class name */

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

                'time' => $time,

Line exceeds 120 characters; contains 141 characters
Open

                'role' => \App\Language::translate($this->getRoleName($recordModel->get('assigned_user_id')), $this->textParser->moduleName),

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

    /**

Line exceeds 120 characters; contains 122 characters
Open

        $html .= "<th style=\"{$headerStyle}\">" . \App\Language::translate('OSSTimeControl', 'OSSTimeControl') . '</th>';

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

            $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $this->textParser->moduleName);

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

            $time = ($users[$user]['time'] ?? 0) + $recordModel->get('sum_time');

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 ($this->getUserList() as $user => $data) {

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 $users;

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

        return (new \App\Db\Query())->select(['rolename'])->from('vtiger_role')->innerJoin('vtiger_user2role', 'vtiger_role.roleid = vtiger_user2role.roleid')->where(['vtiger_user2role.userid' => $userId])->scalar();

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

class OSSTimeControl_UserGroup_Textparser extends \App\TextParser\Base

There are no issues that match your filters.

Category
Status