Coupling Between Objects

This pass computes the coupling between a class and other classes.

Generally, loose coupled classes and components are preferable as the higher your coupling, the higher are the chances that a class breaks or requires adaption because of changes in classes that it depends on.

When computing coupling, we ignore dependencies to classes which have been marked as stable. This pass considers anything defined by the PHP runtime as stable, and also user-land code which has been marked with the @api doc comment. These dependencies should rarely - if at all - change during the lifetime of a project.

Ignoring Additional Stable Code

If you would like to consider more code as stable and thus remove it from the coupling analysis, you can list it in the configuration of your project:

# .scrutinizer.yml
tools:
    php_analyzer:
        config:
            metrics_coupling:
                stable_code:
                    namespace_prefixes:
                        - Your\Namespace\Prefix

                    classes:
                        - Some\ClassName

In this case, we ignore all classes from a namespace starting with Your\Namespace\Prefix, and also the class named Some\ClassName. Prefixes and class names are case-insensitive.