hendrikmaus/spas

View on GitHub
src/Request/RequestProcessor.php

Summary

Maintainability
B
4 hrs
Test Coverage

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;
Severity: Minor
Found in src/Request/RequestProcessor.php - About 1 hr to fix

    Method process has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(ParsedRequest $request)
        {
            if ($this->shouldExit($request)) {
                return;
            }
    Severity: Minor
    Found in src/Request/RequestProcessor.php - About 1 hr to fix

      Method __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              InputInterface $input,
              LoggerInterface $logger,
              EventDispatcherInterface $dispatcher,
              ValidatorService $validatorService,
              HttpClient $http,
      Severity: Major
      Found in src/Request/RequestProcessor.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                return $this->doRequest($request, $attempt);
        Severity: Major
        Found in src/Request/RequestProcessor.php - About 30 mins to fix

          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
          Severity: Minor
          Found in src/Request/RequestProcessor.php by phpmd

          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()
                      ]);
          Severity: Minor
          Found in src/Request/RequestProcessor.php by phpmd

          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');
                  }
          Severity: Minor
          Found in src/Request/RequestProcessor.php by phpmd

          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;
          Severity: Minor
          Found in src/Request/RequestProcessor.php by phpmd

          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++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          There are no issues that match your filters.

          Category
          Status