DateTime::modify() mutates the object and returns it. Because it returns something, it reads like a pure function, so it gets assigned to a new variable — and then…
The application already has a Mailer interface and eleven classes depend on it. The transactional-email service being brought in ships a client with a different method name, a…
A codebase split into Billing, Catalogue and Shipping namespaces, each with its own repositories and services, looks modular in the directory listing. Then one report joins four tables…
An optional collaborator — a logger only configured in production, a cache that may be switched off, a discount that may not apply — produces the same three…
“Send the confirmation in the background” arrives as a requirement long after the code that sends it has settled into a controller method, wired to a request and…
Setter injection and a service locator both let a class acquire a collaborator at the moment it happens to need one, so nothing about the class announces how…
A payment provider’s SDK ends up referenced in a controller, in two models, in a console command and in nine tests. Changing provider then means changing all of…
Two classes that need the same six lines and share no useful ancestor leave three bad options: copy the lines, invent a base class whose only purpose is…