Of all of the design patterns you could use in your code, the adapter pattern is one of my all time favourites. It allows you to abstract the implementation to an adapter that implements an interface. so you can switch implementation simply by switching the adapter.
PHP
Using AI as a deterministic translation tool in Laravel
Split a task into reasoning and execution to get deterministic behaviour out of a non-deterministic model. Read more