Fetching latest commit…
Cannot retrieve the latest commit at this time.
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
Multiton.php added final to Multiton Mar 9, 2017
README.rst

README.rst

Multiton

THIS IS CONSIDERED TO BE AN ANTI-PATTERN! FOR BETTER TESTABILITY AND MAINTAINABILITY USE DEPENDENCY INJECTION!

Purpose

To have only a list of named instances that are used, like a singleton but with n instances.

Examples

  • 2 DB Connectors, e.g. one for MySQL, the other for SQLite
  • multiple Loggers (one for debug messages, one for errors)

UML Diagram

Alt Multiton UML Diagram

Code

You can also find this code on GitHub

Multiton.php

.. literalinclude:: Multiton.php
   :language: php
   :linenos:

Test