SAREhub/PHP_Client

View on GitHub
src/SAREhub/Client/Amqp/AmqpChannelWrapper.php

Summary

Maintainability
A
2 hrs
Test Coverage

AmqpChannelWrapper has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class AmqpChannelWrapper extends ServiceSupport
{
    /**
     * @var AmqpChannelWrapperState
     */
Severity: Minor
Found in src/SAREhub/Client/Amqp/AmqpChannelWrapper.php - About 2 hrs to fix

    The class AmqpChannelWrapper has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
    Open

    class AmqpChannelWrapper extends ServiceSupport
    {
        /**
         * @var AmqpChannelWrapperState
         */

    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 registerConsumer has a boolean flag argument $lazy, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function registerConsumer(AmqpConsumer $consumer, bool $lazy = true): void

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method reject has a boolean flag argument $requeue, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function reject(Message $message, bool $requeue = true)

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid using static access to class '\SAREhub\Client\Message\BasicExchange' in method 'onMessage'.
    Open

            $exchange = BasicExchange::withIn($inConverted->copy());

    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

    Line exceeds 120 characters; contains 123 characters
    Open

            $this->getLogger()->notice("Unregistered consumer with tag: $consumerTag", ["options" => $consumer->getOptions()]);

    There are no issues that match your filters.

    Category
    Status