YetiForceCompany/YetiForceCRM

View on GitHub
modules/IStorages/textparsers/TableHierarchy.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            ['label' => \App\Language::translate('SINGLE_IStorages', $this->textParser->moduleName), 'width' => '50%', 'align' => 'left'],

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

            ['label' => \App\Language::translate('LBL_STORAGE_OWNER', $this->textParser->moduleName), 'width' => '40%', 'align' => 'center'],

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

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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 "width" 4 times.
Open

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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 "align" 7 times.
Open

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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 "label" 4 times.
Open

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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 record from undeclared class \App\TextParser
Open

        $hierarchy = $this->textParser->recordModel->getEntity()->getHierarchy($this->textParser->record, false, false);

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

        $hierarchy = $this->textParser->recordModel->getEntity()->getHierarchy($this->textParser->record, false, false);

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

            ['label' => \App\Language::translate('LBL_STORAGE_OWNER', $this->textParser->moduleName), 'width' => '40%', 'align' => 'center'],

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

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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

            ['label' => \App\Language::translate('SINGLE_IStorages', $this->textParser->moduleName), 'width' => '50%', 'align' => 'left'],

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

class IStorages_TableHierarchy_Textparser extends \App\TextParser\Base

The class IStorages_TableHierarchy_Textparser is not named in CamelCase.
Open

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

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

    public $name = 'LBL_TABLE_HIERARCHY';

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

            ['label' => \App\Language::translate('SINGLE_IStorages', $this->textParser->moduleName), 'width' => '50%', 'align' => 'left'],

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

            $html .= '<th style="width:' . $thData['width'] . ';text-align:' . $thData['align'] . ';">' . $thData['label'] . '</th>';

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

            ++$rowNum;

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

    }

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

        $rowNum = 1;

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

            ['label' => \App\Language::translate('LBL_STORAGE_OWNER', $this->textParser->moduleName), 'width' => '40%', 'align' => 'center'],

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

    {

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

        $html .= '.storagesTable td,.storagesTable th{padding:5px}';

Line exceeds 120 characters; contains 133 characters
Open

            $html .= '<th style="width:' . $thData['width'] . ';text-align:' . $thData['align'] . ';">' . $thData['label'] . '</th>';

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

        $html = '<style>';

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

        $html .= '.storagesTable tbody tr:nth-child(odd){background:#eee}';

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

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

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

        $hierarchy = $this->textParser->recordModel->getEntity()->getHierarchy($this->textParser->record, false, false);

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

        $html .= '<table class="storagesTable"><thead><tr>';

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

        $thDataArray = [

Line exceeds 120 characters; contains 141 characters
Open

            ['label' => \App\Language::translate('LBL_STORAGE_OWNER', $this->textParser->moduleName), 'width' => '40%', 'align' => 'center'],

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

        $html .= '.storagesTable{width:100%;font-size:10px;border:1px solid #ddd;border-collapse:collapse}';

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

        }

Line exceeds 120 characters; contains 135 characters
Open

            ['label' => \App\Language::translate('LBL_ROW_NUM', $this->textParser->moduleName), 'width' => '10%', 'align' => 'center'],

Line exceeds 120 characters; contains 138 characters
Open

            ['label' => \App\Language::translate('SINGLE_IStorages', $this->textParser->moduleName), 'width' => '50%', 'align' => 'left'],

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

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

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

            $html .= '<td style="text-align:' . $thDataArray[1]['align'] . ';">' . $entry[0] . '</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

        foreach ($thDataArray as $thData) {

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

        foreach ($hierarchy['entries'] as $entry) {

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

            $html .= '<td style="text-align:' . $thDataArray[2]['align'] . ';">' . $entry[1] . '</td></tr>';

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

     * Process.

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

        $html .= '</style>';

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 .= '<tr><td style="text-align:' . $thDataArray[0]['align'] . ';">' . $rowNum . '.</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

        ];

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

class IStorages_TableHierarchy_Textparser extends \App\TextParser\Base

There are no issues that match your filters.

Category
Status