Function doTask
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function doTask($recordModel)
{
if (\App\Integrations\SMSProvider::isActiveProvider()) {
$moduleName = 'SMSNotifier';
$recordModelTemp = \Vtiger_Record_Model::getCleanInstance($moduleName)->set('message', $this->content);
- 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 '\App\Integrations\SMSProvider' in method 'doTask'. Open
if (\App\Integrations\SMSProvider::isActiveProvider()) {
- 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\TextParser' in method 'doTask'. Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- 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
Argument 2 (callback)
is Closure():''
but \preg_replace_callback()
takes callable(array):string
Open
$phoneNumber = preg_replace_callback('/[^\d\+]/s', function () {
- Exclude checks
Reference to undeclared property \VTSMSTask->sms_recepient
Open
$recepient = $textParser->setContent($this->sms_recepient)->parse()->getContent();
- Exclude checks
Call to method getInstanceByModel
from undeclared class \App\TextParser
(Did you mean class \Tests\App\TextParser) Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- Exclude checks
Saw unextractable annotation for comment '/** @var array Fields */'
Open
/** @var array Fields */
- Exclude checks
Reference to undeclared property \VTSMSTask->content
(Did you mean expr->contents) Open
$recordModelTemp = \Vtiger_Record_Model::getCleanInstance($moduleName)->set('message', $this->content);
- Exclude checks
Call to undeclared method \App\Base::save
Open
$recordModel->set('phone', $phoneNumber)->save();
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class VTSMSTask extends VTTask
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$phoneNumber = preg_replace_callback('/[^\d\+]/s', function () {
- 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 bool Execute Immediately */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Fields */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFieldNames()
- 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
$recepient = $textParser->setContent($this->sms_recepient)->parse()->getContent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}, strip_tags($phoneNumber));
- 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 doTask($recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModelTemp->set('related_to', $recordModel->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$textParser = \App\TextParser::getInstanceByModel($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set('phone', $phoneNumber)->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
$moduleName = 'SMSNotifier';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recepients = array_unique(explode(',', $recepient));
- 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 Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModelTemp = \Vtiger_Record_Model::getCleanInstance($moduleName)->set('message', $this->content);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($recepients as $phoneNumber) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($recordModel->getModuleName(), $recordModelTemp->getField('related_to')->getReferenceList())) {
- 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
if ($phoneNumber) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ['content', 'sms_recepient'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = clone $recordModelTemp;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $executeImmediately = 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
{
- 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 (\App\Integrations\SMSProvider::isActiveProvider()) {
- 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
* Execute task.
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
if (\in_array($recordModel->getModuleName(), $recordModelTemp->getField('related_to')->getReferenceList())) {
- Exclude checks