Method getSummary
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
{
$updates = $usedActions = [];
$query = (new \App\Db\Query())
->select(['vtiger_modtracker_basic.module'])
Method getQueryGenerator
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
{
$queryGenerator = (new \App\QueryGenerator($moduleName))
->setFields([])
->addJoin([
Method getQueryGenerator
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
Method getUpdates
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array
Method getSummary
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
Missing class import via use statement (line '58', column '89'). Open
$queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
- 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 '50', column '40'). Open
['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]
- 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 '31', column '17'). Open
$query = (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 '134', column '23'). Open
$recordModel = new ModTracker_Record_Model();
- 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 '83', column '26'). Open
$queryGenerator = (new \App\QueryGenerator($moduleName))
- 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
Define a constant instead of duplicating this literal "vtiger_modtracker_basic.status" 4 times. Open
['vtiger_modtracker_basic.status' => $actions],
- 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.
Call to method setCustomColumn
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setCustomColumn('vtiger_modtracker_basic.*');
- Exclude checks
Call to method setCustomColumn
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$dataReader = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->createCommand()->query();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]
- Exclude checks
Return type of getQueryGenerator()
is undeclared type \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$result = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(0);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = (new \App\QueryGenerator($moduleName))
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
$queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = (new \App\QueryGenerator($moduleName))
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class ModTracker_Updates_Helper
- Exclude checks
The class ModTracker_Updates_Helper is not named in CamelCase. Open
class ModTracker_Updates_Helper
{
/**
* Gets summary.
*
- 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
$queryGenerator->addCondition('assigned_user_id', $owner, 'e', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets updates.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $updates;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Paging_Model|null $pagingModel
- 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 ($pagingModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($owner) {
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner, $pagingModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets QueryGenerator object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->addNativeCondition([
- 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 int|null $historyOwner
- Exclude checks
Line exceeds 120 characters; contains 193 characters Open
public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_crmentity.crmid = vtiger_modtracker_basic.crmid'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateRange[0] . ' 00:00:00', $dateRange[1] . ' 23:59:59'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $actions
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'between',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $row['module'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $queryGenerator->createQuery()->createCommand()->queryAllByGroup(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$updates[$moduleName] = $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getQueryGenerator(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, ?Vtiger_Paging_Model $pagingModel = null): App\QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->addJoin([
- 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 array $dateRange
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$updates = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setCustomColumn('vtiger_modtracker_basic.*');
- 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
'vtiger_modtracker_basic.changedon',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($owner) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- 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 $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $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
* Gets summary.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $modules
- 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
$queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array
- 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 ($historyOwner) {
- 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
* @param array $actions
- 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
->setFields([])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->addNativeCondition(['vtiger_modtracker_basic.status' => $actions])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'between',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($queryGenerator->getModuleField('shownerid')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addCondition('shownerid', $owner, 'e', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner, $pagingModel);
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$dataReader = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->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
* @return array
- 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
['vtiger_modtracker_basic.module' => $modules],
- 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
['vtiger_crmentity.smownerid' => $owner],
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $owner])]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->distinct(true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($result) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $owner
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_modtracker_basic',
- 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 (\count($updates) === $pagingModel->getPageLimit()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $dateRange
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateRange[0] . ' 00:00:00', $dateRange[1] . ' 23:59:59'
- 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
if ($historyOwner) {
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = new ModTracker_Record_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $actions
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$updates = $usedActions = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_modtracker_basic')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['vtiger_modtracker_basic.status' => $actions],
- 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
'vtiger_modtracker_basic.changedon',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addNativeCondition(['vtiger_modtracker_basic.whodid' => $historyOwner]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $historyOwner
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->setData($row)->setParent($row['crmid'], $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->innerJoin('vtiger_crmentity', 'vtiger_modtracker_basic.crmid=vtiger_crmentity.crmid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['or',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = self::getQueryGenerator($moduleName, $actions, $dateRange, $owner, $historyOwner);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = (new \App\QueryGenerator($moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->setStateCondition('All');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setLimit($pagingModel->getPageLimit() + 1)->setOffset($pagingModel->getStartIndex());
- 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 = $queryGenerator->createQuery()->orderBy(['vtiger_modtracker_basic.id' => SORT_DESC])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$pagingModel->set('nextPageExists', 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
$usedActions = array_unique(array_merge($usedActions, array_keys($result)));
- 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 $queryGenerator;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['vtiger_crmentity.crmid' => (new \App\Db\Query())->select(['crmid'])->from('u_#__crmentity_showners')->where(['userid' => $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
* @param int|null $owner
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $historyOwner
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['and',
- 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 App\QueryGenerator
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'INNER JOIN',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Paging_Model $pagingModel
- Exclude checks
Line exceeds 120 characters; contains 165 characters Open
public static function getUpdates(string $moduleName, array $actions, array $dateRange, ?int $owner, ?int $historyOwner, Vtiger_Paging_Model $pagingModel): array
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$updates[$recordModel->getId()] = $recordModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSummary(array $modules, array $actions, array $dateRange, ?int $owner, ?int $historyOwner): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_modtracker_basic.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
$query->andWhere(['vtiger_modtracker_basic.whodid' => $historyOwner]);
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
$queryGenerator->setCustomColumn(['vtiger_modtracker_basic.status', 'counter' => new \yii\db\Expression('COUNT(*)')])->setCustomGroup(['vtiger_modtracker_basic.status']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [$updates, $usedActions];
- 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 array $dateRange
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Class name "ModTracker_Updates_Helper" is not in camel caps format Open
class ModTracker_Updates_Helper
- Exclude checks