modules/Settings/Vtiger/models/Field.php
The method getModuleName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$moduleName = parent::getModuleName();
}
- Read upRead up
- Exclude checks
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
Reference to undeclared property \Settings_Vtiger_Field_Model->validator
Open
Open
return $this->validator ?? parent::getValidator();
- Exclude checks
Reference to undeclared property \Settings_Vtiger_Field_Model->module
Open
Open
$moduleName = $this->module->getParentName() . ':' . $this->module->getName();
- Exclude checks
Reference to undeclared property \Settings_Vtiger_Field_Model->isReadOnly
(Did you mean \Settings_Vtiger_Field_Model->isReadOnly() or expr->readonly) Open
Open
return $this->isReadOnly ?? false;
- Exclude checks
Reference to undeclared property \Settings_Vtiger_Field_Model->module
Open
Open
if (!empty($this->module) && method_exists($this->module, 'getParentName')) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_Vtiger_Field_Model extends Vtiger_Field_Model
- Exclude checks
The class Settings_Vtiger_Field_Model is not named in CamelCase. Open
Open
class Settings_Vtiger_Field_Model extends Vtiger_Field_Model
{
/**
* Function to check if the field is named field of the module.
*
- 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
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->isReadOnly ?? false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getModuleName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function isNameField(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getFieldDataType()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to check whether the current field is read-only.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$moduleName = $this->module->getParentName() . ':' . $this->module->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$moduleName = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getValidator()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$moduleName = parent::getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->fieldDataType = 'icon';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function isReadOnly(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!isset($this->fieldDataType) && 62 === $this->uitype) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return parent::getFieldDataType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to check if the field is named field of the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $this->validator ?? parent::getValidator();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!empty($this->module) && method_exists($this->module, 'getParentName')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Class name "Settings_Vtiger_Field_Model" is not in camel caps format Open
Open
class Settings_Vtiger_Field_Model extends Vtiger_Field_Model
- Exclude checks