phpinspectionsea icon indicating copy to clipboard operation
phpinspectionsea copied to clipboard

Efferent coupling between objects

Open gnumoksha opened this issue 4 years ago • 1 comments

Subject Details
Plugin Php Inspections (EA Extended) 4.0.2
Language level PHP 7.2

Current behaviour

The following class will throw the message "[EA] High efferent coupling (14)." But I'm not using the other classes, only its references.

declare(strict_types=1);

namespace Test;

class SomeBuilder
{
    public function build(int $number) : object
    {
        $providers = [
            1  => \Test\Test01::class,
            2  => \Test\Test02::class,
            3  => \Test\Test03::class,
            4  => \Test\Test04::class,
            5  => \Test\Test05::class,
            6  => \Test\Test06::class,
            7  => \Test\Test07::class,
            8  => \Test\Test08::class,
            9  => \Test\Test09::class,
            10 => \Test\Test10::class,
            11 => \Test\Test11::class,
        ];

        $class = $providers[$number];

        return new $class;
    }
}

Expected behaviour

Using ::class do not count as class usage for efferent coupling metrics.

Environment details

PhpStorm 2019.3.1
Build #PS-193.5662.63, built on December 19, 2019

gnumoksha avatar Dec 23 '19 17:12 gnumoksha

I need to check how the metric is calculated for PHP, perhaps that's intended behaviour.

kalessil avatar Jan 05 '20 22:01 kalessil