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 = [])
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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);
- Exclude checks
Reference to undeclared property \Vtiger_Basic_Widget->Data
Open
$this->Data = $widget['data'] ?? [];
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Basic_Widget
- Exclude checks
The class Vtiger_Basic_Widget is not named in CamelCase. Open
class Vtiger_Basic_Widget
{
public $Module = false;
public $Record = false;
public $Config = [];
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Data = $widget['data'] ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $row
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $Module = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $moduleModel = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Config['tpl'] = 'Basic.tpl';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return !$this->allowedModules || \in_array($this->Module, $this->allowedModules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $widget;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getApiData(array $row): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Record = $Record;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'BasicConfig';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isPermitted(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Return data for api.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->moduleModel = $moduleModel ?: \Vtiger_Module_Model::getInstance($this->Module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $Record = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget = $this->Config;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $Config = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowedModules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct($Module = false, $moduleModel = null, $Record = null, $widget = [])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $row;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $dbParams = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Module = $Module;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$widget['instance'] = $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getConfigTplName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to check permission.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getWidget()
- Exclude checks
Class name "Vtiger_Basic_Widget" is not in camel caps format Open
class Vtiger_Basic_Widget
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
}
}