Factory Method Pattern

This is an example of a Factory Method Pattern.

This pattern is used to separate object construction code from the code that will use the object. It makes it easier to extend object construction code independently of the rest of the code. Though they might seem similar, and in occasion is used interchangeably by some, there is a big difference between a Factory Method Pattern and an Abstract Factory Pattern. -> Where the Factory Method Pattern is implemented by inheritance, the Abstract Factory Pattern is implemented by composition.

This means that in a Factory Method Pattern, the Factory object can have subclasses that can override the creational method, while in an Abstract Factory Pattern the factory classes must all implement a set of creational methods to be able to create a family of objects related in some way.

A Factory Method is used to create one product while Abstract Factory is about creating families of dependent products. Here is a good article.

Factory A

Not actually going to sort but rather showing that I am agnostic of what subject I will be creating: App\PatternFactory\SubjectA.
Made in factory App\PatternFactory\ConcreteFactoryA.

Factory B

Not actually going to sort but rather showing that I am agnostic of what subject I will be creating: App\PatternFactory\SubjectB.
Made in factory App\PatternFactory\ConcreteFactoryB.