WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Drupal using static functions or a service

Submitted by barnettech on Thu, 06/03/2021 - 14:51

https://stovepipe.systems/post/avoiding-static-in-your-code

If there are not dependencies and it's not a pain to mock in a unit test, or for re-use then static is fine. A service lets you encapsulate everything and all the dependencies using dependency injection, to make sure all the dependencies are easy to setup.