Missing class import via use statement (line '36', column '20'). Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))
- 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 '53', column '20'). Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request($method, $url, [
- 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\Log' in method 'request'. Open
\App\Log::beginProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- 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\Log' in method 'authorize'. Open
\App\Log::beginProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- 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\RequestHttp' in method 'authorize'. Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))
- 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\Json' in method 'authorize'. Open
$this->token = \App\Json::decode((string) $response->getBody());
- 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\Log' in method 'authorize'. Open
\App\Log::endProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- 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\RequestHttp' in method 'request'. Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request($method, $url, [
- 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\Log' in method 'request'. Open
\App\Log::endProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- 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
Define a constant instead of duplicating this literal "App\Integrations\Magento" 4 times. Open
\App\Log::beginProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- 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 endProfile
from undeclared class \App\Log
Open
\App\Log::endProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- Exclude checks
Call to method endProfile
from undeclared class \App\Log
Open
\App\Log::endProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- Exclude checks
Call to method post
from undeclared class \GuzzleHttp\Client
Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))
- Exclude checks
Call to method __construct
from undeclared class \GuzzleHttp\Client
Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request($method, $url, [
- Exclude checks
Call to method __construct
from undeclared class \GuzzleHttp\Client
Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))
- Exclude checks
Call to method beginProfile
from undeclared class \App\Log
Open
\App\Log::beginProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- Exclude checks
Call to method beginProfile
from undeclared class \App\Log
Open
\App\Log::beginProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- Exclude checks
Call to method request
from undeclared class \GuzzleHttp\Client
Open
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request($method, $url, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new AppException($response->getReasonPhrase(), $response->getStatusCode());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'headers' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (string) $response->getBody();
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
* The file is part of the paid functionality. Using the file is allowed only after purchasing a subscription. File modification allowed only with the consent of the system producer.
- 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
'timeout' => 0,
- 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
if (200 !== $response->getStatusCode()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (200 !== $response->getStatusCode()) {
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = rtrim($this->config->get('url'), '/') . "/rest/$action";
- 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
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request($method, $url, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $token;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'authorization' => 'Bearer ' . $this->token,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Special token to authorization.
- 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
/** {@inheritdoc} */
- 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
'json' => $params, ]);
- 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
throw new AppException($response->getReasonPhrase(), $response->getStatusCode());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$url = rtrim($this->config->get('url'), '/') . '/rest/V1/integration/admin/token';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::beginProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
'json' => ['username' => $this->config->get('user_name'), 'password' => $this->config->get('password')], ]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::beginProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::endProfile("POST|Token::authorize|{$url}", 'App\Integrations\Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->token = \App\Json::decode((string) $response->getBody());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function request(string $method, string $action, array $params = []): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'http_errors' => false,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function authorize()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'json' => ['username' => $this->config->get('user_name'), 'password' => $this->config->get('password')], ]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::endProfile("{$method}|Token::request|{$url}", 'App\Integrations\Magento');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->post($url, [
- 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
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'http_errors' => false,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'timeout' => 0,
- Exclude checks