modules/Occurrences/models/Field.php
The method getValidator uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$validator = parent::getValidator();
}
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Occurrences_Field_Model extends Vtiger_Field_Model
- Exclude checks
The class Occurrences_Field_Model is not named in CamelCase. Open
Open
class Occurrences_Field_Model extends Vtiger_Field_Model
{
/** {@inheritdoc} */
public function getValidator()
{
- 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
if ('date_end' === $this->getName()) {
- 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 $validator;
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$funcName = ['name' => 'greaterThanDependentField',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$validator = parent::getValidator();
- 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
$validator = [];
- 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
'params' => ['date_start'], ];
- 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
array_push($validator, $funcName);
- Exclude checks
Class name "Occurrences_Field_Model" is not in camel caps format Open
Open
class Occurrences_Field_Model extends Vtiger_Field_Model
- Exclude checks