Skip to content

Latest commit

 

History

History
 
 

SimpleFactory

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Simple Factory

Purpose

ConcreteFactory is a simple factory pattern.

It differs from the static factory because it is NOT static and as you know: static => global => evil!

Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock-up it.

UML Diagram

Alt SimpleFactory UML Diagram

Code

You can also find these code on GitHub

ConcreteFactory.php

ConcreteFactory.php

VehicleInterface.php

VehicleInterface.php

Bicycle.php

Bicycle.php

Scooter.php

Scooter.php

Test

Tests/SimpleFactoryTest.php

Tests/SimpleFactoryTest.php