Missing class import via use statement (line '44', column '20'). Open
return new \rho_api\modules\v1\models\UserRateLimiter();
- 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
The method findModelByClientIdAndAccessToken uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new NotFoundHttpException("Object not found.");
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\rho_api\models\VUserExternalInfo' in method 'findModelByClientIdAndAccessToken'. Open
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- 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 '\rho_api\modules\v1\helpers\Client' in method 'checkAccessByClientIdAndAccessToken'. Open
Client::checkClientId($client_id);
- 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 '\rho_api\modules\v1\helpers\AccessToken' in method 'checkAccessByClientIdAndAccessToken'. Open
AccessToken::checkAccessToken($access_token);
- 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
The parameter $client_id is not named in camelCase. Open
public static function checkAccessByClientIdAndAccessToken($client_id, $access_token)
{
Client::checkClientId($client_id);
AccessToken::checkAccessToken($access_token);
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $access_token is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $access_token is not named in camelCase. Open
public static function checkAccessByClientIdAndAccessToken($client_id, $access_token)
{
Client::checkClientId($client_id);
AccessToken::checkAccessToken($access_token);
}
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $client_id is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Whitespace found at end of line Open
*
- Exclude checks
Whitespace found at end of line Open
*
- Exclude checks
The variable $access_token is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $client_id is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $access_token is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $client_id is not named in camelCase. Open
public static function findModelByClientIdAndAccessToken($client_id, $access_token)
{
self::checkAccessByClientIdAndAccessToken($client_id, $access_token);
$model = VUserExternalInfo::findOne(['access_token' => $access_token, 'client_id' => $client_id]);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $client_id is not named in camelCase. Open
public static function checkAccessByClientIdAndAccessToken($client_id, $access_token)
{
Client::checkClientId($client_id);
AccessToken::checkAccessToken($access_token);
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $access_token is not named in camelCase. Open
public static function checkAccessByClientIdAndAccessToken($client_id, $access_token)
{
Client::checkClientId($client_id);
AccessToken::checkAccessToken($access_token);
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}