Skip to content
Snippets Groups Projects

docs: add order state example

Merged Jan Kuchař requested to merge add-order-state-example into master
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
@@ -2,7 +2,7 @@
In order state example I would like to demonstrate that there are more then one solution of domain problem of order state which can transition into another states.
## 1. Class constants
## 1. Class constants
[source code](refactoring-1.phpt)
@@ -28,7 +28,7 @@ Nice thing is that we do not need anymore external service for asking `OrderStat
Remaining problem is that there are still lot of ifs and we still need to handle case where someone adds new value into enum which we do not count with.
## 4. Separate instance for each value
## 4. Separate instance for each value
[source code](refactoring-4.phpt)
@@ -45,4 +45,4 @@ Now, new domain requirement:
1. I have rewritten each value as separate class (as behaviour is different for different values)
2. I have implemented doTransition() on enum parent class as it is only proper way of changing enum value
3. I have added `onActivation(Order $order)` method, which is called whenever state transition occurs.
3. I have overridden `onActivation()` on enum values with desired behaviour.
\ No newline at end of file
3. I have overridden `onActivation()` on enum values with desired behaviour.
Loading