Latest commit 4bc5a3d Dec 10, 2017
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Tests Merge branch 'master' into feature/class-instead-of-namespace Mar 9, 2017
uml PHP7 SimpleFactory Sep 22, 2016
Bicycle.php PHP7 SimpleFactory Sep 22, 2016
README.rst Fix typo (parametrized => parameterized). Didn't touch other translat… Dec 10, 2017
SimpleFactory.php PHP7 SimpleFactory Sep 22, 2016

README.rst

Simple Factory

Purpose

SimpleFactory is a simple factory pattern.

It differs from the static factory because it is not static. Therefore, you can have multiple factories, differently parameterized, you can subclass it and you can mock it. It always should be preferred over a static factory!

UML Diagram

Alt SimpleFactory UML Diagram

Code

You can also find this code on GitHub

SimpleFactory.php

.. literalinclude:: SimpleFactory.php
   :language: php
   :linenos:

Bicycle.php

.. literalinclude:: Bicycle.php
   :language: php
   :linenos:

Usage

Test

Tests/SimpleFactoryTest.php

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