modules/Settings/Leads/models/Field.php
Function getFieldDataType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public function getFieldDataType()
{
$fieldDataType = '';
$uitype = $this->get('uitype');
if ('9' == $uitype) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method getInstance has a boolean flag argument $module, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public static function getInstance($value, $module = false)
- 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
Saw unextractable annotation for comment '* @param <string> $value'</string>
Open
Open
* @param <String/Integer> $value
- Exclude checks
Saw unextractable annotation for comment '* @return <settings_leads_field_model> field model'</settings_leads_field_model>
Open
Open
* @return <Settings_Leads_Field_Model> field model
- Exclude checks
Saw unextractable annotation for comment '* @return <settings_leads_field_model>'</settings_leads_field_model>
Open
Open
* @return <Settings_Leads_Field_Model>
- Exclude checks
Default value for string
$module
can't be false
Open
Open
public static function getInstance($value, $module = false)
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_Leads_Field_Model extends Vtiger_Field_Model
- Exclude checks
The class Settings_Leads_Field_Model is not named in CamelCase. Open
Open
class Settings_Leads_Field_Model extends Vtiger_Field_Model
{
/**
* Function to get field data type.
*
- 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
case 'multipicklist':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param string $module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function getInstance($value, $module = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$objectProperties = get_object_vars($fieldModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
switch ($fieldDataType) {
- 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
$fieldModel->{$properName} = $propertyValue;
- 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 ('9' == $uitype) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function getCleanInstance()
- 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
$uitype = $this->get('uitype');
- 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
* @return <Settings_Leads_Field_Model> field model
- 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 (!$fieldDataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldDataType = parent::getFieldDataType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
case 'text':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- 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 $fieldModel;
- 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
$fieldModel = parent::getInstance($value, $module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldDataType = 'textArea';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get clean instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldModel = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string data type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldDataType = 'percent';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($objectProperties as $properName => $propertyValue) {
- 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
$fieldDataType = 'multiSelectCombo';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return <Settings_Leads_Field_Model>
- 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
case 'boolean':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $fieldDataType;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get instance.
- 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 get field data type.
- 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
* @param <String/Integer> $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldDataType = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldDataType = 'checkBox';
- Exclude checks
Class name "Settings_Leads_Field_Model" is not in camel caps format Open
Open
class Settings_Leads_Field_Model extends Vtiger_Field_Model
- Exclude checks