Files
DesignPatternsPHP/Creational/Singleton
Roman Martinuk 74c96851d1 singleton fix visible __wakeup()
1) DesignPatterns\Creational\Singleton\Tests\SingletonTest::testUniqueness
The magic method DesignPatterns\Creational\Singleton\Singleton::__wakeup() must have public visibility

/app/Creational/Singleton/Singleton.php:39
/app/Creational/Singleton/Tests/SingletonTest.php:12

ERRORS!
2021-03-14 20:58:23 +03:00
..
2020-06-20 11:27:02 -03:00
2021-03-14 20:58:23 +03:00

`Singleton`__
=============

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

Purpose
-------

To have only one instance of this object in the application that will
handle all calls.

Examples
--------

-  DB Connector
-  Logger
-  Lock file for the application (there is only one in the filesystem
   ...)

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

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

Code
----

You can also find this code on `GitHub`_

Singleton.php

.. literalinclude:: Singleton.php
   :language: php
   :linenos:

Test
----

Tests/SingletonTest.php

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

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/main/Creational/Singleton
.. __: http://en.wikipedia.org/wiki/Singleton_pattern