The method getServers has a boolean flag argument $onlyActive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getServers(bool $onlyActive = true): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '22', column '17'). Open
$query = (new \App\Db\Query())->from('w_#__servers');
- 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 '38', column '17'). Open
$query = (new \App\Db\Query())->from('w_#__servers')->andWhere(['status' => 1]);
- 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 '\App\Db' in method 'getServers'. Open
return $query->createCommand(\App\Db::getInstance('webservice'))->queryAllByGroup(1);
- 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\Db' in method 'getActiveServers'. Open
return $query->createCommand(\App\Db::getInstance('webservice'))->queryAllByGroup(1);
- 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 \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from('w_#__servers')->andWhere(['status' => 1]);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from('w_#__servers');
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_WebserviceApps_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
The class Settings_WebserviceApps_Module_Model is not named in CamelCase. Open
class Settings_WebserviceApps_Module_Model extends Settings_Vtiger_Module_Model
{
/**
* Get all servers.
*
- 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
$query->where(['status' => 1]);
- 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 static function getServers(bool $onlyActive = true): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from('w_#__servers');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->createCommand(\App\Db::getInstance('webservice'))->queryAllByGroup(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->createCommand(\App\Db::getInstance('webservice'))->queryAllByGroup(1);
- 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 $type
- 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
* @param bool $onlyActive
- 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 (!empty($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 ($onlyActive) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get active servers.
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from('w_#__servers')->andWhere(['status' => 1]);
- 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
* Get all servers.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getActiveServers(string $type = ''): 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
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['type' => $type]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Settings_WebserviceApps_Module_Model" is not in camel caps format Open
class Settings_WebserviceApps_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks