QuestionQ30

VerifiedStore Operations and Admin

An Adobe Commerce Architect runs PHP Mess Detector from the command-line interface with the coding standard supplied by Adobe Commerce. The following output is displayed:

Question Image

The Architect examines the class and observes that its constructor has 15 parameters. Five of those parameters are scalars that configure the behavior of MyService.

How should the Architect correct the code so that it complies with the coding-standard rule?

Explanation

PHPMD’s CouplingBetweenObjects rule limits the number of class dependencies. The standard rule’s default maximum is 13 acceptable dependencies, and it evaluates object dependencies such as referenced classes and interfaces—not scalar configuration values or merely the number of constructor parameters. MyService must therefore reduce the distinct classes and interfaces it references to less than 13.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!