SAREhub/php_component_worker

View on GitHub
src/SAREhub/Component/Worker/Command/CommandService.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class 'SAREhub\Component\Worker\Command\CommandReply' in method 'onRequestException'.
Open

        $reply = CommandReply::error(
          $request->getCommand()->getCorrelationId(),
          'exception when send command',
          ['exceptionMessage' => $exception->getMessage()]
        );

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 assigning values to variables in if clauses and the like (line '80', column '7').
Open

    protected function doTick() {
        if ($reply = $this->getCommandReplyInput()->getNext()) {
            $this->getLogger()->info('got reply', ['reply' => $reply]);
            if ($request = $this->getCorrelatedPendingRequest($reply)) {
                $this->getLogger()->info('exists correlated command', [

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid assigning values to variables in if clauses and the like (line '82', column '8').
Open

    protected function doTick() {
        if ($reply = $this->getCommandReplyInput()->getNext()) {
            $this->getLogger()->info('got reply', ['reply' => $reply]);
            if ($request = $this->getCorrelatedPendingRequest($reply)) {
                $this->getLogger()->info('exists correlated command', [

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid using static access to class 'SAREhub\Component\Worker\Command\CommandReply' in method 'checkReplyTimeout'.
Open

                $reply = CommandReply::error(
                  $request->getCommand()->getCorrelationId(),
                  'reply timeout'
                );

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

There are no issues that match your filters.

Category
Status