Method process
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process()
{
$html = '';
$scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
if (!$scheduleData) {
Function process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function process()
{
$html = '';
$scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
if (!$scheduleData) {
- 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 '\Notification_Module_Model' in method 'process'. Open
$entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));
- 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 '\Notification_Module_Model' in method 'process'. Open
$notificationInstance = \Notification_Module_Model::getInstance('Notification');
- 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_Watchdog_Model' in method 'process'. Open
$scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
- 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\Config' in method 'process'. Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- 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\Config' in method 'process'. Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- 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\Language' in method 'process'. Open
$html = \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');
- 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\Language' in method 'process'. Open
return \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');
- 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
syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Notification_Notifications_TextParser extends \App\TextParser\Base
- Exclude checks
The class Notification_Notifications_TextParser is not named in CamelCase. Open
class Notification_Notifications_TextParser extends \App\TextParser\Base
{
/** @var string Class name */
public $name = 'LBL_NOTIFICATIONS';
- 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
Only one argument is allowed per line in a multi-line function call Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- 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
$entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));
- Exclude checks
Line exceeds 120 characters; contains 198 characters Open
$entries = \Notification_Module_Model::getEmailSendEntries($this->textParser->getParam('userId'), $modules, $this->textParser->getParam('startDate'), $this->textParser->getParam('endDate'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = $scheduleData['modules'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$title = preg_replace_callback(
- 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
$scheduleData = \Vtiger_Watchdog_Model::getWatchingModulesSchedule($this->textParser->getParam('userId'), true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<hr><strong>$type</strong><ul>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$massage = preg_replace_callback(
- 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
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- 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
$pattern = "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $name = 'LBL_NOTIFICATIONS';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= "<li>$title<br />$massage</li>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html .= '</ul><br />';
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$notificationInstance = \Notification_Module_Model::getInstance('Notification');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($notificationInstance->getTypes() as $typeId => $type) {
- 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 (!$scheduleData) {
- 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 mixed Parser type */
- 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 $type = 'mail';
- 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
public function process()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');
- 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 $html;
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html = \App\Language::translate('LBL_NO_NOTIFICATIONS', 'Notification');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$html = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($entries[$typeId])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($html)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Class 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
foreach ($entries[$typeId] as $notification) {
- Exclude checks
Multi-line function call not indented correctly; expected 20 spaces but found 24 Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Multi-line function call not indented correctly; expected 20 spaces but found 24 Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getTitle());
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$pattern, fn ($matches) => \App\Config::main('site_URL') . $matches[0], $notification->getMessage());
- Exclude checks
Class name "Notification_Notifications_TextParser" is not in camel caps format Open
class Notification_Notifications_TextParser extends \App\TextParser\Base
- Exclude checks