Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 990 Bytes

README.rst

File metadata and controls

58 lines (39 loc) · 990 Bytes

Purpose

Encapsulate varying behavior for the same routine based on an object's state. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements.

UML Diagram

Alt State UML Diagram

Code

You can also find this code on GitHub

ContextOrder.php

.. literalinclude:: ContextOrder.php
   :language: php
   :linenos:

StateOrder.php

.. literalinclude:: StateOrder.php
   :language: php
   :linenos:

ShippingOrder.php

.. literalinclude:: ShippingOrder.php
   :language: php
   :linenos:

CreateOrder.php

.. literalinclude:: CreateOrder.php
   :language: php
   :linenos:

Test

Tests/StateTest.php

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