Files
DesignPatternsPHP/Structural/Registry
MathiasReker 6ec696d00b Final public method for abstract class
All public methods of abstract classes should be final. Enforce API encapsulation in an inheritance architecture. If you want to override a method, use the Template method pattern.
2022-06-16 21:09:49 +02:00
..
2021-10-01 10:26:04 -03:00
2019-08-26 06:18:51 +02:00
2020-06-20 11:27:02 -03:00

`Registry`__
============

Purpose
-------

To implement a central storage for objects often used throughout the
application, is typically implemented using an abstract class with only
static methods (or using the Singleton pattern). Remember that this introduces
global state, which should be avoided at all times! Instead implement it using Dependency Injection!

UML Diagram
-----------

.. image:: uml/uml.png
   :alt: Alt Registry UML Diagram
   :align: center

Code
----

You can also find this code on `GitHub`_

Registry.php

.. literalinclude:: Registry.php
   :language: php
   :linenos:

Service.php

.. literalinclude:: Service.php
   :language: php
   :linenos:

Test
----

Tests/RegistryTest.php

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

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/main/Structural/Registry
.. __: http://en.wikipedia.org/wiki/Service_locator_pattern