arkitect icon indicating copy to clipboard operation
arkitect copied to clipboard

No classes should DSL

Open pfazzi opened this issue 3 years ago • 0 comments

Feature Request

I would enforce a rule on a deprecated namespace.

Q A
New Feature yes
RFC yes
BC Break no

Summary

I would like to have a DSL like this:

Rule::noClass()
  ->should(new ResideInOneOfTheseNamespaces(
      "Prima\Service",
      "Prima\Entity"
  ))->because("Those namespaces have been deprecated in favor of the new modular architecture");

This rule is already implementable in the following way:

Rule::allClasses()
  ->that(new ResideInOneOfTheseNamespaces(
      "Prima\Service",
      "Prima\Entity"
  ))->should(
      new NotResideInTheseNamespaces(
          "Prima\Service",
          "Prima\Entity"
      )
  )->because("Those namespaces have been deprecated in favor of the new modular architecture");

But it looks awkward to me to read.

Furthermore, it would be easier to express rules like the following:

Rule::noClass()
  ->should(new HaveNameMatching("*Manager"))
  ->because("of our naming convention services should be named with a more self-explanatory name");

What do you think?

pfazzi avatar Nov 22 '22 19:11 pfazzi