Skip to content

Latest commit

 

History

History
 
 

State

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 these code on GitHub

OrderController.php

.. literalinclude:: OrderController.php
   :language: php
   :linenos:

OrderFactory.php

.. literalinclude:: OrderFactory.php
   :language: php
   :linenos:

OrderInterface.php

.. literalinclude:: OrderInterface.php
   :language: php
   :linenos:

ShippingOrder.php

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

CreateOrder.php

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

Test