mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-08 16:06:31 +02:00
execute read-the-docs.sh
This commit is contained in:
56
Behavioral/State/index.rst
Normal file
56
Behavioral/State/index.rst
Normal file
@@ -0,0 +1,56 @@
|
||||
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
|
||||
-----------
|
||||
|
||||
.. image:: uml/uml.png
|
||||
:alt: Alt State UML Diagram
|
||||
:align: center
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
OrderInterface.php
|
||||
|
||||
.. literalinclude:: OrderInterface.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
OrderFactory.php
|
||||
|
||||
.. literalinclude:: OrderFactory.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
OrderController.php
|
||||
|
||||
.. literalinclude:: OrderController.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
ShippingOrder.php
|
||||
|
||||
.. literalinclude:: ShippingOrder.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
CreateOrder.php
|
||||
|
||||
.. literalinclude:: CreateOrder.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/State
|
Reference in New Issue
Block a user