Skip to content

Latest commit

 

History

History
 
 

AbstractFactory

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Purpose

To create series of related or dependent objects without specifying their concrete classes. Usually the created classes all implement the same interface. The client of the abstract factory does not care about how these objects are created, it just knows how they go together.

UML Diagram

Alt AbstractFactory UML Diagram

Code

You can also find this code on GitHub

Product.php

.. literalinclude:: Product.php
   :language: php
   :linenos:

ShippableProduct.php

.. literalinclude:: ShippableProduct.php
   :language: php
   :linenos:

DigitalProduct.php

.. literalinclude:: DigitalProduct.php
   :language: php
   :linenos:

ProductFactory.php

.. literalinclude:: ProductFactory.php
   :language: php
   :linenos:

Test

Tests/AbstractFactoryTest.php

.. literalinclude:: Tests/AbstractFactoryTest.php
   :language: php
   :linenos: