Function searchAccountsToConvert
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function searchAccountsToConvert(Vtiger_Record_Model $recordModel)
{
\App\Log::trace('Start ' . __METHOD__);
if ($recordModel) {
$mappingFields = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'mapping');
- 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 searchAccountsToConvert
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchAccountsToConvert(Vtiger_Record_Model $recordModel)
{
\App\Log::trace('Start ' . __METHOD__);
if ($recordModel) {
$mappingFields = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'mapping');
Method getQueryByModuleField
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
{
if (!empty($record) && \in_array($sourceModule, ['Campaigns', 'Products', 'Services'])) {
switch ($sourceModule) {
case 'Campaigns':
Function getQueryByModuleField
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
{
if (!empty($record) && \in_array($sourceModule, ['Campaigns', 'Products', 'Services'])) {
switch ($sourceModule) {
case 'Campaigns':
- 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
Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed. Open
public function searchAccountsToConvert(Vtiger_Record_Model $recordModel)
- 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 '108', column '18'). Open
$query = (new App\Db\Query())->select(['vtiger_account.accountid'])
- 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 '119', column '17'). Open
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- 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 '77', column '22'). Open
$subQuery = (new App\Db\Query())
- 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 '192', column '50'). Open
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
- 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 '81', column '28'). Open
$secondSubQuery = (new App\Db\Query())
- 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 '87', column '63'). Open
$condition = ['not in', 'vtiger_leaddetails.leadid', (new App\Db\Query())->select([$fieldName])->from($tableName)->where([$relatedFieldName => $record])];
- 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 '25', column '17'). Open
$query = (new App\Db\Query())->select(['count' => 'COUNT(*)', 'time' => 'date(createdtime)'])
- 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 'Settings_MarketingProcesses_Module_Model' in method 'checkIfAllowedToConvert'. Open
$leadConfig = Settings_MarketingProcesses_Module_Model::getConfig('lead');
- 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\Log' in method 'searchAccountsToConvert'. Open
\App\Log::trace('End ' . __METHOD__);
- 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 searchRecordCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
}
- 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
The method getQueryByModuleField uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$condition = ['not in', 'vtiger_leaddetails.leadid', (new App\Db\Query())->select([$fieldName])->from($tableName)->where([$relatedFieldName => $record])];
}
- 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\Json' in method 'searchAccountsToConvert'. Open
$mappingFields = \App\Json::decode($mappingFields);
- 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 'Settings_MarketingProcesses_Module_Model' in method 'getConversionAvaibleStatuses'. Open
$leadConfig = Settings_MarketingProcesses_Module_Model::getConfig('lead');
- 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_Processes_Model' in method 'searchAccountsToConvert'. Open
$mappingFields = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'mapping');
- 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\Log' in method 'searchAccountsToConvert'. Open
\App\Log::trace('End ' . __METHOD__);
- 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 'searchAccountsToConvert'. Open
$moduleModel = 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\PrivilegeQuery' in method 'getLeadsCreated'. Open
\App\PrivilegeQuery::getConditions($query, $this->getName());
- 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\Log' in method 'searchAccountsToConvert'. Open
\App\Log::trace('Start ' . __METHOD__);
- 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\Log' in method 'searchAccountsToConvert'. Open
\App\Log::trace('End ' . __METHOD__);
- 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 "vtiger_crmentity" 3 times. Open
->innerJoin('vtiger_crmentity', 'vtiger_leaddetails.leadid = vtiger_crmentity.crmid')
- 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 "vtiger_leaddetails" 3 times. Open
->from('vtiger_leaddetails')
- 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 "crmid" 4 times. Open
$fieldName = 'crmid';
- 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 "convert_status" 3 times. Open
return $leadConfig['convert_status'];
- 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 "not in" 4 times. Open
$condition = ['and', ['not in', 'vtiger_leaddetails.leadid', $subQuery], ['not in', 'vtiger_leaddetails.leadid', $secondSubQuery]];
- 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 "vtiger_leaddetails.leadid" 3 times. Open
$condition = ['and', ['not in', 'vtiger_leaddetails.leadid', $subQuery], ['not in', 'vtiger_leaddetails.leadid', $secondSubQuery]];
- 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.
Avoid unused parameters such as '$field'. Open
public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
- Exclude checks
Saw unextractable annotation for comment '* @return <array>'</array>
Open
* @return <Array>
- Exclude checks
Call to method addNativeCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addNativeCondition($condition);
- Exclude checks
Call to undeclared method \App\Db\Query::andWhere
Open
$query->andWhere(['vtiger_leaddetails.converted' => 0]);
- Exclude checks
Argument 1 (encodedValue)
is array
but \App\Json::decode()
takes string
defined at /code/app/Json.php:37
Open
$mappingFields = \App\Json::decode($mappingFields);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$subQuery = (new App\Db\Query())
- Exclude checks
Doc-block of $recordSearch
in searchRecordCondition
is phpdoc param type \App\RecordSearch
which is not a permitted replacement of the nullable param type ?\App\RecordSearch
declared in the signature ('?T' should be documented as 'T|null' or '?T') Open
* @param App\RecordSearch $recordSearch
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new App\Db\Query())->select(['count' => 'COUNT(*)', 'time' => 'date(createdtime)'])
- Exclude checks
Returning type int
but searchAccountsToConvert()
is declared to return bool
Open
return (int) $dataReader->readColumn(0);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$secondSubQuery = (new App\Db\Query())
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Start ' . __METHOD__);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Parameter $queryGenerator
has undeclared type \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new App\Db\Query())->select(['vtiger_account.accountid'])
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Call to undeclared method \App\Db\Query::innerJoin
Open
$query->innerJoin('vtiger_leaddetails', 'csl.crmid = vtiger_leaddetails.leadid');
- Exclude checks
Call to undeclared method \App\Db\Query::andWhere
Open
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$condition = ['not in', 'vtiger_leaddetails.leadid', (new App\Db\Query())->select([$fieldName])->from($tableName)->where([$relatedFieldName => $record])];
- Exclude checks
Saw unextractable annotation for comment '* @return <array> array of statuses'</array>
Open
* @return <Array> array of statuses
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ('Services' === $sourceModule) {
$subQuery = (new App\Db\Query())
->select(['relcrmid'])
->from('vtiger_crmentityrel')
->where(['crmid' => $record]);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 116.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Leads_Module_Model extends Vtiger_Module_Model
- Exclude checks
The class Leads_Module_Model is not named in CamelCase. Open
class Leads_Module_Model extends Vtiger_Module_Model
{
/**
* Function returns the Number of Leads created per week.
*
- 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
Line exceeds 120 characters; contains 127 characters Open
$query->andWhere(['between', 'createdtime', $dateFilter['start'] . ' 00:00:00', $dateFilter['end'] . ' 23:59:59']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Line exceeds 120 characters; contains 170 characters Open
$condition = ['not in', 'vtiger_leaddetails.leadid', (new App\Db\Query())->select([$fieldName])->from($tableName)->where([$relatedFieldName => $record])];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\NoPermitted
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($mappingFields as $mappingField) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(["{$tableName}.{$fieldModel->getColumnName()}" => $recordModel->get($leadFieldName)]);
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$query->andWhere(["{$tableName}.{$fieldModel->getColumnName()}" => $recordModel->get($leadFieldName)]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$numberRows = $dataReader->count();
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $numberRows) {
- 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
$relatedFieldName = 'productid';
- 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
->from('vtiger_crmentityrel')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$secondSubQuery = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['crmid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mappingFields = \App\Json::decode($mappingFields);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($numberRows > 1) {
- 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
->where(['deleted' => 0, 'converted' => 0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->query();
- 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 $sourceModule Parent 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
break;
- 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
->from('vtiger_account')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_crmentity.deleted' => 0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$joinTable = ['vtiger_account', 'vtiger_crmentity'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($mappingField as $leadFieldName => $accountFieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $moduleModel->getFieldByName($accountFieldName);
- 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 that returns status that allow to convert Lead.
- 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
\App\PrivilegeQuery::getConditions($query, $this->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_crmentityrel')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$condition = ['and', ['not in', 'vtiger_leaddetails.leadid', $subQuery], ['not in', 'vtiger_leaddetails.leadid', $secondSubQuery]];
- 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
\App\Log::trace('Start ' . __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new App\Db\Query())->select(['vtiger_account.accountid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->limit(2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $dateFilter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = vtiger_account.accountid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new App\Db\Query())->select(['count' => 'COUNT(*)', 'time' => 'date(createdtime)'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_crmentity', 'vtiger_leaddetails.leadid = vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $response;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($record) && \in_array($sourceModule, ['Campaigns', 'Products', 'Services'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($sourceModule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = 'vtiger_campaign_records';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Products':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = 'crmid';
- 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 <Array>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['between', 'createdtime', $dateFilter['start'] . ' 00:00:00', $dateFilter['end'] . ' 23:59:59']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\QueryGenerator $queryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addNativeCondition($condition);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to search accounts.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = $fieldModel->get('table');
- 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 string $record parent id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['crmid' => $record]);
- 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 = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'mapping');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Vtiger_Module_Model::getInstance('Accounts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fieldModel) {
- 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 <Array> array of statuses
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getLeadsCreated($owner, $dateFilter)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->groupBy('date(createdtime)')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['time'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'Campaigns':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = 'vtiger_seproductsrel';
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$condition = ['and', ['not in', 'vtiger_leaddetails.leadid', $subQuery], ['not in', 'vtiger_leaddetails.leadid', $secondSubQuery]];
- 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
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$joinTable[] = $tableName;
- 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
$relatedFieldName = 'campaignid';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- 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
public function searchAccountsToConvert(Vtiger_Record_Model $recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$focus = $moduleModel->getEntityInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($tableName, $joinTable)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
* Function that checks if lead record can be converted.
- 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($dateFilter)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (int) $dataReader->readColumn(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns the Number of Leads created per week.
- 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
$response = [];
- 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 getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = 'crmid';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Services' === $sourceModule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$condition = ['not in', 'vtiger_leaddetails.leadid', (new App\Db\Query())->select([$fieldName])->from($tableName)->where([$relatedFieldName => $record])];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
$query->innerJoin($tableName, "{$tableName}.{$focus->tab_name_index[$tableName]} = vtiger_account.accountid");
- 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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
- 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
$query->innerJoin('vtiger_leaddetails', 'csl.crmid = vtiger_leaddetails.leadid');
- 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 App\RecordSearch $recordSearch
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordSearch->moduleName === $this->getName()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['smownerid' => $owner]);
- 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
$subQuery = (new App\Db\Query())
- 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
$query->innerJoin($tableName, "{$tableName}.{$focus->tab_name_index[$tableName]} = vtiger_account.accountid");
- 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
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getConversionAvaibleStatuses()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function checkIfAllowedToConvert($status)
- 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
$query->andWhere(['vtiger_leaddetails.converted' => 0]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($owner)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_leaddetails')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['count'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['relcrmid'])
- 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
\App\Log::trace('End ' . __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $status - lead status
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $owner
- 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 to get list view query for popup window.
- 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 $field parent fieldname
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['relcrmid' => $record]);
- 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
$dataReader = $query->createCommand()->query();
- 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 App\Db\Query $query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function searchRecordCondition(App\Db\Query $query, App\RecordSearch $recordSearch = null): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($leadConfig['convert_status'])) {
- 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
* The function adds restrictions to the functionality of searching for records.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool if or not allowed to convert
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$leadConfig = Settings_MarketingProcesses_Module_Model::getConfig('lead');
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
$query->andWhere(['not in', 'csl.crmid', (new \App\Db\Query())->select(['leadid'])->from('vtiger_leaddetails')->where(['converted' => 1])]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \in_array($status, $leadConfig['convert_status']);
- 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
$leadConfig = Settings_MarketingProcesses_Module_Model::getConfig('lead');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $leadConfig['convert_status'];
- 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
} else {
- Exclude checks
Class name "Leads_Module_Model" is not in camel caps format Open
class Leads_Module_Model extends Vtiger_Module_Model
- Exclude checks