Function process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process(OSSMail_Mail_Model $mail)
{
$this->mail = $mail;
$campaignIds = $this->findAndBind();
if (0 == $mail->get('type') && false !== $campaignIds && 0 != $campaignIds) {
- 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
Avoid using static access to class 'OSSMailScanner_Record_Model' in method 'process'. Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);
- 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 'OSSMailScanner_Record_Model' in method 'process'. Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);
- 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
Call to method mergeArray
from undeclared class \OSSMailScanner_Record_Model
Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);
- Exclude checks
Call to method mergeArray
from undeclared class \OSSMailScanner_Record_Model
Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);
- Exclude checks
Call to method mergeArray
from undeclared class \OSSMailScanner_Record_Model
Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Avoid excessively long class names like OSSMailScanner_BindCampaigns_ScannerAction. Keep class name length under 40. Open
class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
{
/**
* Module name.
*
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
- Exclude checks
The class OSSMailScanner_BindCampaigns_ScannerAction is not named in CamelCase. Open
class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
{
/**
* Module name.
*
- 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
public $tableColumn = 'campaign_no';
- 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
* Table 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
* @var string
- 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
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsToaddress);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $moduleName = 'Campaigns';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$campaignIds = $this->findAndBind();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmIds = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- 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 (0 == $mail->get('type') && false !== $campaignIds && 0 != $campaignIds) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsBccaddress);
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$dbCommand->update('vtiger_campaign_records', ['campaignrelstatusid' => 1], ['campaignid' => $campaignId, 'crmid' => $recordId])->execute();
- 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 OSSMail_Mail_Model $mail
- 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
foreach ($crmIds as $recordId) {
- 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 process(OSSMail_Mail_Model $mail)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- 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
$this->mail = $mail;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmidsToaddress = $mail->findEmailAddress('to_email', false, true);
- 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
* Module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Table name.
- 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
$dbCommand->update('vtiger_campaign_records', ['campaignrelstatusid' => 1], ['campaignid' => $campaignId, 'crmid' => $recordId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $campaignIds;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmidsCcaddress = $mail->findEmailAddress('cc_email', false, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmIds = OSSMailScanner_Record_Model::mergeArray($crmIds, $crmidsCcaddress);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tableName = 'vtiger_campaign';
- 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
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$crmidsBccaddress = $mail->findEmailAddress('bcc_email', false, true);
- 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
* Process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($campaignIds as $campaignId) {
- Exclude checks
Class name "OSSMailScanner_BindCampaigns_ScannerAction" is not in camel caps format Open
class OSSMailScanner_BindCampaigns_ScannerAction extends OSSMailScanner_PrefixScannerAction_Model
- Exclude checks