I’m not sure if you’ll understand the way I interpreted it. Forgive my spider web brain. I should have used software modelling tool instead of MS Paint :D :D :D ... But nah! :D hehe

There are still lots of patterns to learn but below are the most common. You can check it at: https://github.com/DesignPatternsPHP

Decorator Pattern

The purpose of decorator pattern is it dynamically adds new functionality to class instances.

Interfaces allow to specify what methods a class should implement. 

To implement an interface, the implements operator is used. All methods in the interface must be  implemented within a class.

https://photos.app.goo.gl/T9vRfaGdsg73Rxrr6

Output:

54 Basic inspection and oil change.

Adapter Pattern

The purpose of an adapter pattern is it  allows you to translate one interface to use with another.

Think of it as the same  usage of a real world adapter. An adapter is a device that converts attributes of one electrical device or system to those of an otherwise incompatible device or system.

https://photos.app.goo.gl/NNrgwDoiQXTGd1R56

Template Pattern

The purpose of template pattern is to remove duplication implementation. Template pattern is an abstract class exposes defined ways/templates to execute its methods. Abstract classes and methods are when the parent class has a named method, but need its child classes to fill out the tasks. An abstract method is a method that is declared, but not implemented in the code.

https://photos.app.goo.gl/EKepFwXdiJL4xJC46

(new TurkeySub)->make();

output:

laying down a bread

add some lettuce

add Turkey

add some sauces

(new VeggieSub)->make();

output:

laying down a bread

add some lettuce

add Veggie

add some sauces

Strategy Pattern

The purpose of strategy pattern is to define a family of algorithms, encapsulates each one and make them interchangeable.

https://photos.app.goo.gl/vi5ktFU1Hs5TBB3F7

Output:

Log the data to a Saas site. Log the data to the database.

Chain of Responsibility Pattern

The purpose of this pattern is it literally allows us to chain any number of objects, where each has the option of either handling a particular request, or deferring to the next object in the cycle.

https://photos.app.goo.gl/u6JuSG51byhJGQnZA

Output:

Order of chain should all be true. Otherwise it will throw an exception error. For example, I'll set $alarmOn to false. The error result is:

Fatal error: Uncaught Exception: Alarm not set! 

Observer Pattern

The purpose of this pattern is it basically  triggers a code to run when certain events happened. 

https://photos.app.goo.gl/SppMCjWcoZHnc6nRA

Output:

string(13) "Log something" string(13) "Fire an email" string(14) "Reporter Login"