Function getAccountFieldsForLeadConvert
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function getAccountFieldsForLeadConvert()
{
$accountsFields = [];
$moduleName = 'Accounts';
- 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
Function getConvertLeadMappedField
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function getConvertLeadMappedField($fieldName, $moduleName)
{
$mappingFields = $this->get('mappingFields');
if (!$mappingFields) {
- 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
Method getAccountFieldsForLeadConvert
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAccountFieldsForLeadConvert()
{
$accountsFields = [];
$moduleName = 'Accounts';
Method getConvertLeadMappedField
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConvertLeadMappedField($fieldName, $moduleName)
{
$mappingFields = $this->get('mappingFields');
if (!$mappingFields) {
The method getAccountFieldsForLeadConvert() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function getAccountFieldsForLeadConvert()
{
$accountsFields = [];
$moduleName = 'Accounts';
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed. Open
public function getAccountFieldsForLeadConvert()
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '145', column '18'). Open
$query = (new \App\Db\Query())->from('vtiger_convertleadmapping');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '29', column '29'). Open
$returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\Cache' in method 'getConverted'. Open
} elseif (\App\Cache::has('Leads.converted', $this->getId())) {
- 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
Avoid using static access to class '\App\Privilege' in method 'getAccountFieldsForLeadConvert'. Open
if (!\App\Privilege::isPermitted($moduleName, 'EditView')) {
- 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
Avoid using static access to class 'Vtiger_Module_Model' in method 'getAccountFieldsForLeadConvert'. Open
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
- 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
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete('Leads.converted', $this->getId());
- 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
Avoid using static access to class 'Vtiger_Field_Model' in method 'getAccountFieldsForLeadConvert'. Open
$fieldModel = Vtiger_Field_Model::getInstance($complusoryField, $moduleModel);
- 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
Avoid using static access to class 'Vtiger_Module_Model' in method 'getConvertLeadMappedField'. Open
$accountInstance = Vtiger_Module_Model::getInstance('Accounts');
- 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
Avoid using static access to class '\App\Cache' in method 'delete'. Open
\App\Cache::delete('Leads.converted', $this->getId());
- 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
Avoid using static access to class 'Vtiger_Module_Model' in method 'getConvertLeadMappedField'. Open
$leadInstance = Vtiger_Module_Model::getInstance('Leads');
- 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
The method getConverted uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
\App\Cache::save('Leads.converted', $this->getId(), $returnVal);
}
- 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
Avoid using static access to class '\App\Cache' in method 'getConverted'. Open
\App\Cache::save('Leads.converted', $this->getId(), $returnVal);
- 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
The method getAccountFieldsForLeadConvert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$industryFieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());
}
- 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
Avoid using static access to class '\App\Cache' in method 'getConverted'. Open
$returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());
- 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
Define a constant instead of duplicating this literal "accountfid" 3 times. Open
if ($row['accountfid'] && isset($accountFieldInstances[$row['accountfid']])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "fieldvalue" 5 times. Open
$fieldModel->set('fieldvalue', $this->get($leadMappedField));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Leads.converted" 5 times. Open
} elseif (\App\Cache::has('Leads.converted', $this->getId())) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Accounts" 4 times. Open
$moduleName = 'Accounts';
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \App\Db\Query::select
Open
$returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::delete()
takes string
defined at /code/app/Cache.php:105
Open
\App\Cache::delete('Leads.converted', $this->getId());
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::delete()
takes string
defined at /code/app/Cache.php:105
Open
\App\Cache::delete('Leads.converted', $this->getId());
- Exclude checks
Returning type void
but getAccountFieldsForLeadConvert()
is declared to return array
Open
return;
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
} elseif (\App\Cache::has('Leads.converted', $this->getId())) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
\App\Cache::save('Leads.converted', $this->getId(), $returnVal);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from('vtiger_convertleadmapping');
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
$returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());
- Exclude checks
Avoid excessively long variable names like $accountFieldInstances. Keep variable name length under 20. Open
$accountFieldInstances = $accountInstance->getFieldsById();
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $industryLeadMappedField. Keep variable name length under 20. Open
$industryLeadMappedField = $this->getConvertLeadMappedField($complusoryField, $moduleName);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Leads_Record_Model extends Vtiger_Record_Model
- Exclude checks
The class Leads_Record_Model is not named in CamelCase. Open
class Leads_Record_Model extends Vtiger_Record_Model
{
/**
* Get converted column.
*
- 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 'getConverted()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getConverted(): bool
{
if ($this->isNew()) {
$returnVal = false;
} elseif (\App\Cache::has('Leads.converted', $this->getId())) {
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
Spaces must be used to indent lines; tabs are not allowed Open
public function getConverted(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $returnVal;
- 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
return parent::isEditable() && !$this->getConverted();
- 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
$complusoryFields = []; //Field List in the conversion lead
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldModels as $fieldName => $fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $keyIndex) {
- 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
return $accountsFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAccountFieldsForLeadConvert()
- 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
} else {
- 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
if (!\App\Privilege::isPermitted($moduleName, 'EditView')) {
- 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
parent::save();
- 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(string $action)
- 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 string $fieldName
- 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
* Function returns Account fields for Lead Convert.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountsFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leadFieldName = $leadFieldInstance->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($row['accountfid'] && isset($accountFieldInstances[$row['accountfid']])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns the fields required for Lead Convert.
- 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
$convertFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('Leads.converted', $this->getId(), $returnVal);
- 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
return parent::isViewable() && !$this->getConverted();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::isPermitted($action) && !$this->getConverted();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Fields that need to be shown
- 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
* @return bool
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
$returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnVal = 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- 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
if (!$mappingFields) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountsFields[] = $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$leadFieldInstance) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = Vtiger_Field_Model::getInstance($complusoryField, $moduleModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountInstance = Vtiger_Module_Model::getInstance('Accounts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- 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
* Get converted column.
- 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
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$industryFieldModel = $moduleModel->getField($complusoryField);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from('vtiger_convertleadmapping');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('mappingFields', $mappingFields);
- 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
$accountFieldInstances = $accountInstance->getFieldsById();
- 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 function delete()
- 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
$moduleName = 'Accounts';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleModel->isActive()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($leadMappedField) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($industryLeadMappedField) {
- 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 function getConvertLeadMappedField($fieldName, $moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leadInstance = Vtiger_Module_Model::getInstance('Leads');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountFields = $this->getAccountFieldsForLeadConvert();
- 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
$mappingFields['Accounts'][$accountFieldInstances[$row['accountfid']]->getName()] = $leadFieldName;
- 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
if ($this->isNew()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function save()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isViewable()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isEditable(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=' . $this->getModuleName() . '&view=ConvertLead&record=' . $this->getId();
- 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
unset($complusoryFields[$keyIndex]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('fieldvalue', $this->get($leadMappedField));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$industryLeadMappedField = $this->getConvertLeadMappedField($complusoryField, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$industryFieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());
- 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
* Function returns field mapped to Leads field, used in Lead Convert for settings the field values.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $convertFields;
- 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
if (!$this->isNew()) {
- 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
* Function returns the url for converting lead.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' == $fieldModel->get('fieldvalue')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$industryFieldModel->set('fieldvalue', $this->get($industryLeadMappedField));
- 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
continue;
- 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
$leadFieldInstances = $leadInstance->getFieldsById();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getConvertLeadFields()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mappingFields = [];
- 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
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$keyIndex = array_search($fieldName, $complusoryFields);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($complusoryFields as $complusoryField) {
- 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
$mappingFields = $this->get('mappingFields');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leadFieldInstance = $leadFieldInstances[$row['leadfid']];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $mappingFields[$moduleName][$fieldName] ?? '';
- 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
} elseif (\App\Cache::has('Leads.converted', $this->getId())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('Leads.converted', $this->getId());
- 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
if ($fieldModel->isMandatory() && 'assigned_user_id' != $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leadMappedField = $this->getConvertLeadMappedField($fieldName, $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel->getPermissions(false)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- 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
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Vtiger_Field_Model[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($accountFields)) {
- 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
$returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('Leads.converted', $this->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getConvertLeadUrl()
- 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
$fieldModels = $moduleModel->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$accountsFields[] = $industryFieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- 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
if (empty($row['leadfid'])) {
- 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
$convertFields['Accounts'] = $accountFields;
- Exclude checks
Class name "Leads_Record_Model" is not in camel caps format Open
class Leads_Record_Model extends Vtiger_Record_Model
- Exclude checks