YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/widgets/Basic.php

Summary

Maintainability
A
0 mins
Test Coverage
F
52%

The method __construct has a boolean flag argument $Module, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Avoid using static access to class '\Vtiger_Module_Model' in method '__construct'.
Open

        $this->moduleModel = $moduleModel ?: \Vtiger_Module_Model::getInstance($this->Module);
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

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

Argument 1 (mixed) is false but \Vtiger_Module_Model::getInstance() takes int|string defined at /code/modules/Vtiger/models/Module.php:197
Open

        $this->moduleModel = $moduleModel ?: \Vtiger_Module_Model::getInstance($this->Module);
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phan

Reference to undeclared property \Vtiger_Basic_Widget->Data
Open

        $this->Data = $widget['data'] ?? [];
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phan

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

class Vtiger_Basic_Widget

The class Vtiger_Basic_Widget is not named in CamelCase.
Open

class Vtiger_Basic_Widget
{
    public $Module = false;
    public $Record = false;
    public $Config = [];
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

The parameter $Module is not named in camelCase.
Open

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
    {
        $this->Module = $Module;
        $this->Record = $Record;
        $this->Config = $widget;
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $Record is not named in camelCase.
Open

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
    {
        $this->Module = $Module;
        $this->Record = $Record;
        $this->Config = $widget;
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

        $this->Config = $widget;

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

        $this->Data = $widget['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

    {

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

     * @param array $row

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

    public $Module = false;

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 $moduleModel = false;

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

        $this->Config['tpl'] = 'Basic.tpl';

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

        return !$this->allowedModules || \in_array($this->Module, $this->allowedModules);

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

        return $widget;

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

     * @return array

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

    public function getApiData(array $row): array

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

        $this->Record = $Record;

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

        return 'BasicConfig';

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 isPermitted(): bool

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

     * Return data for api.

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

     *

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

        $this->moduleModel = $moduleModel ?: \Vtiger_Module_Model::getInstance($this->Module);

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 $Record = false;

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

    /**

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

        $widget = $this->Config;

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

    public $Config = [];

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

    public $allowedModules = [];

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

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])

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

        return $row;

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

    public $dbParams = [];

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

        $this->Module = $Module;

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

    {

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

        $widget['instance'] = $this;

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

    public function getConfigTplName()

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

     * Function to check permission.

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

     * @return bool

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

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

class Vtiger_Basic_Widget

The variable $Module is not named in camelCase.
Open

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
    {
        $this->Module = $Module;
        $this->Record = $Record;
        $this->Config = $widget;
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $Record is not named in camelCase.
Open

    public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
    {
        $this->Module = $Module;
        $this->Record = $Record;
        $this->Config = $widget;
Severity: Minor
Found in modules/Vtiger/widgets/Basic.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status