Mario Simão 56970cc221 style: Adopt PSR12
Dev dependency flyeralarm/php-code-validator has been removed.

Closes #444
2021-10-01 10:26:04 -03:00
..
2021-10-01 10:26:04 -03:00
2021-10-01 10:26:04 -03:00
2021-10-01 10:26:04 -03:00
2021-10-01 10:26:04 -03:00
2020-06-20 11:27:02 -03:00

`Proxy`__
=========

Purpose
-------

To interface to anything that is expensive or impossible to duplicate.

Examples
--------

-  Doctrine2 uses proxies to implement framework magic (e.g. lazy
   initialization) in them, while the user still works with his own
   entity classes and will never use nor touch the proxies

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

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

Code
----

You can also find this code on `GitHub`_

BankAccount.php

.. literalinclude:: BankAccount.php
   :language: php
   :linenos:

HeavyBankAccount.php

.. literalinclude:: HeavyBankAccount.php
   :language: php
   :linenos:

BankAccountProxy.php

.. literalinclude:: BankAccountProxy.php
   :language: php
   :linenos:

Test
----

ProxyTest.php

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

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