Method doRequest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doRequest(ParsedRequest $request, $attempt = 0)
{
$attempt++;
$pollingThreshhold = $this->input->getOption('polling_count') - 1;
Method process
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ParsedRequest $request)
{
if ($this->shouldExit($request)) {
return;
}
Method __construct
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
InputInterface $input,
LoggerInterface $logger,
EventDispatcherInterface $dispatcher,
ValidatorService $validatorService,
HttpClient $http,
Avoid too many return
statements within this method. Open
return $this->doRequest($request, $attempt);
The class RequestProcessor has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13. Open
class RequestProcessor
{
/**
* Amount of max seconds spas will wait until re-triggering a pollabe resource
* @type int
- 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
The method printRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->logger->info('{0} {1}', [
$request->getMethod(),
$request->getHref()
]);
- 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
The method printValidatorReport uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->report->passed();
$this->logger->info('Passed');
}
- 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 excessively long variable names like $onlyRunHappyCaseTransactions. Keep variable name length under 20. Open
$onlyRunHappyCaseTransactions = $this->input->getOption('all_transactions') == null;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}