Function injectBodyParams
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function injectBodyParams(array $body, array $params, $prefix = '')
{
foreach ($params as $key => $value) {
foreach ($body as $bodyParam => $bodyValue) {
if (is_string($value) || is_numeric($value)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function injectParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function injectParams($url, array $params, $prefix = '')
{
foreach ($params as $key => $value) {
if (is_array($value)) {
$url = $this->injectParams($url, $value, $prefix . $key . '.');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid using undefined variables such as '$output' which will lead to PHP notices. Open
$output['origin%' . $key] = $value;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$output' which will lead to PHP notices. Open
return $output;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
The class RestClient has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class RestClient
{
/**
* @var Client
*/
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Expected 1 space after FUNCTION keyword; 0 found Open
$promises = $batch->reduce(function($carry, $action) use ($parametersJar) {
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Each PHP statement must be on a line by itself Open
$wrapper->setCritical($batch->filter(function($action) { return $action->isCritical(); })->count());
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$wrapper->setCritical($batch->filter(function($action) { return $action->isCritical(); })->count());
- Exclude checks
Inline control structures are not allowed Open
if (! $response) $response = new PsrResponse(502, []);
- Exclude checks
Inline control structures are not allowed Open
if ($url[0] != '/') $url = '/' . $url;
- Exclude checks
Inline control structures are not allowed Open
if (isset($parametersJar['query_string'])) $url .= '?' . $parametersJar['query_string'];
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
'X-Token-Scopes' => $request->user() && ! empty($request->user()->token()) ? implode(',', $request->user()->token()->scopes) : '',
- Exclude checks
Inline control structures are not allowed Open
if (isset($this->guzzleParams['body'])) unset($this->guzzleParams['body']);
- Exclude checks
Inline control structures are not allowed Open
if ($wrapper->hasCriticalActions()) throw new UnableToExecuteRequestException($response);
- Exclude checks
Closing brace indented incorrectly; expected 8 spaces, found 9 Open
}
- Exclude checks
Whitespace found at end of line Open
}
- Exclude checks
Closing brace must be on a line by itself Open
$wrapper->setCritical($batch->filter(function($action) { return $action->isCritical(); })->count());
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 9 Open
}
- Exclude checks
Usage of ELSE IF is discouraged; use ELSEIF instead Open
} else if (is_array($value)) {
- Exclude checks
Expected 1 newline at end of file; 0 found Open
}
- Exclude checks
Opening brace must be the last content on the line Open
$wrapper->setCritical($batch->filter(function($action) { return $action->isCritical(); })->count());
- Exclude checks