Method process
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$dates = [];
$moduleName = $request->getModule();
$currentDate = DateTimeField::convertToDBFormat($request->getByType('currentDate', 'DateInUserFormat'));
Function process
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function process(App\Request $request)
{
$dates = [];
$moduleName = $request->getModule();
$currentDate = DateTimeField::convertToDBFormat($request->getByType('currentDate', 'DateInUserFormat'));
- 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
Missing class import via use statement (line '31', column '27'). Open
$dateInstance->sub(new DateInterval('P1D'));
- 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 '28', column '30'). Open
$currentDateInstance = new DateTime($currentDate);
- 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 '40', column '27'). Open
$dateInstance->add(new DateInterval('P1D'));
- 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 'DateTimeField' in method 'process'. Open
$currentDate = DateTimeField::convertToDBFormat($request->getByType('currentDate', 'DateInUserFormat'));
- 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
$hideDays = App\Config::module($moduleName, 'HIDDEN_DAYS_IN_CALENDAR_VIEW');
- 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 'Calendar_Calendar_Model' in method 'process'. Open
$record = Calendar_Calendar_Model::getCleanInstance();
- 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\Fields\Date' in method 'process'. Open
$record->set('start', \App\Fields\Date::formatToDisplay(reset($dates)) . ' 00:00:00');
- 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
$viewer->assign('SHOW_COMPANIES', App\Config::module($moduleName, 'SHOW_COMPANIES_IN_QUICKCREATE'));
- 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\Fields\Date' in method 'process'. Open
$record->set('end', \App\Fields\Date::formatToDisplay(end($dates)) . ' 23:59:59');
- 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 undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('DATES', $dates);
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('SHOW_COMPANIES', App\Config::module($moduleName, 'SHOW_COMPANIES_IN_QUICKCREATE'));
- Exclude checks
Call to undeclared method \Vtiger_Viewer::assign
Open
$viewer->assign('EVENTS', $records);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Calendar_QuickCreateEvents_View extends Vtiger_IndexAjax_View
- Exclude checks
The class Calendar_QuickCreateEvents_View is not named in CamelCase. Open
class Calendar_QuickCreateEvents_View extends Vtiger_IndexAjax_View
{
/**
* Main process.
*
- 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
*
- 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
$viewer->assign('EVENTS', $records);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
--$numberDaysToDisplay;
- 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
$record->set('user', $request->getInteger('user'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$records = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer = $this->getViewer($request);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dates = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentDate = DateTimeField::convertToDBFormat($request->getByType('currentDate', 'DateInUserFormat'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hideDays = App\Config::module($moduleName, 'HIDDEN_DAYS_IN_CALENDAR_VIEW');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dates[$numberDaysToDisplay] = $currentDate;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateInstance = clone $currentDateInstance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($dateInstance->format('w'), $hideDays)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('start', \App\Fields\Date::formatToDisplay(reset($dates)) . ' 00:00:00');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$events = $record->getEntity();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record = Calendar_Calendar_Model::getCleanInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('DATES', $dates);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function process(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentDateInstance = new DateTime($currentDate);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($numberDaysToDisplay) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateInstance->sub(new DateInterval('P1D'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($dateInstance->format('w'), $hideDays)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->set('time', 'current');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while (6 !== $numberDaysToDisplay) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- 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
* Main process.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$numberDaysToDisplay = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateInstance->add(new DateInterval('P1D'));
- 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
$record->set('end', \App\Fields\Date::formatToDisplay(end($dates)) . ' 23:59:59');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->assign('SHOW_COMPANIES', App\Config::module($moduleName, 'SHOW_COMPANIES_IN_QUICKCREATE'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$viewer->view('QuickCreateEvents.tpl', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$numberDaysToDisplay;
- 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
foreach ($events as $event) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dates[$numberDaysToDisplay] = $dateInstance->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
ksort($dates);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$records[$event['start_date']][] = $event;
- 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
$numberDaysToDisplay = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateInstance = clone $currentDateInstance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dates[$numberDaysToDisplay] = $dateInstance->format('Y-m-d');
- Exclude checks
Class name "Calendar_QuickCreateEvents_View" is not in camel caps format Open
class Calendar_QuickCreateEvents_View extends Vtiger_IndexAjax_View
- Exclude checks