Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 1.13 KB

README.rst

File metadata and controls

68 lines (46 loc) · 1.13 KB

Purpose

To dynamically add new functionality to class instances.

Examples

  • Zend Framework: decorators for Zend_Form_Element instances
  • Web Service Layer: Decorators JSON and XML for a REST service (in this case, only one of these should be allowed of course)

UML Diagram

Alt Decorator UML Diagram

Code

You can also find this code on GitHub

Booking.php

.. literalinclude:: Booking.php
   :language: php
   :linenos:

BookingDecorator.php

.. literalinclude:: BookingDecorator.php
   :language: php
   :linenos:

DoubleRoomBooking.php

.. literalinclude:: DoubleRoomBooking.php
   :language: php
   :linenos:

ExtraBed.php

.. literalinclude:: ExtraBed.php
   :language: php
   :linenos:

WiFi.php

.. literalinclude:: WiFi.php
   :language: php
   :linenos:

Test

Tests/DecoratorTest.php

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