Method getAllUser
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getAllUser($type = 0)
{
$db = new App\Db\Query();
if (0 === $type) {
$db->select([
Missing class import via use statement (line '15', column '13'). Open
$db = 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
Define a constant instead of duplicating this literal "vtiger_users.id = dav_users.userid" 3 times. Open
->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
- 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.
Define a constant instead of duplicating this literal "vtiger_users.status" 3 times. Open
'vtiger_users.status',
- 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.
Define a constant instead of duplicating this literal "dav_users" 3 times. Open
])->from('dav_users')
- 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.
Define a constant instead of duplicating this literal "dav_principals.userid = dav_users.userid" 3 times. Open
->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
- 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.
Define a constant instead of duplicating this literal "dav_principals" 3 times. Open
->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
- 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.
Define a constant instead of duplicating this literal "userid" 4 times. Open
'userid' => 'vtiger_users.id',
- 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.
Define a constant instead of duplicating this literal "vtiger_users" 3 times. Open
->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
- 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 close
from undeclared class \yii\db\DataReader
Open
$dataReader->close();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$db->select([
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$db->select([
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$db->select([
- Exclude checks
Call to method read
from undeclared class \yii\db\DataReader
Open
while ($row = $dataReader->read()) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class API_DAV_Model
- Exclude checks
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = new App\Db\Query();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The class API_DAV_Model is not named in CamelCase. Open
class API_DAV_Model
{
public $davUsers = [];
public static function getAllUser($type = 0)
- 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
])->from('dav_users')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAllUser($type = 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dav_principals.displayname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'calendarsid' => 'dav_calendarinstances.calendarid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_users.status' => 'Active']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userid' => 'dav_users.userid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->from('dav_users')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_users.status',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (1 === $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'david' => 'dav_users.id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userid' => 'vtiger_users.id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dav_principals.email',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_users.user_name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->from('dav_users')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->select([
- 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 $davUsers = [];
- 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
'calendarsid' => 'dav_calendarinstances.calendarid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_users.status' => 'Active']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userid' => 'dav_users.userid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addressbooksid' => 'dav_addressbooks.id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->select([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dav_users.*',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addressbooksid' => 'dav_addressbooks.id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'david' => 'dav_users.id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('dav_addressbooks', 'dav_addressbooks.principaluri = dav_principals.uri')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$users[$row['userid']] = $row;
- 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
return $users;
- 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
->leftJoin('dav_addressbooks', 'dav_addressbooks.principaluri = dav_principals.uri')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (2 === $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
->innerJoin('dav_principals', 'dav_principals.userid = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->select([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('dav_calendarinstances', 'dav_calendarinstances.principaluri = dav_principals.uri');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_users', 'vtiger_users.id = dav_users.userid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('dav_calendarinstances', 'dav_calendarinstances.principaluri = dav_principals.uri')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $db->createCommand()->query();
- 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
$users = [];
- Exclude checks
Class name "API_DAV_Model" is not in camel caps format Open
class API_DAV_Model
- Exclude checks