-
Notifications
You must be signed in to change notification settings - Fork 4.6k
State pattern is maintainable #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
state pattern change readme.rst
|
||
class ContextOrder extends StateOrder | ||
{ | ||
public function getState():StateOrder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 7 sintax should go to php7
branch #169 (comment). Master branch still PHP 5.6 compatible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you say about https://github.com/domnikl/DesignPatternsPHP/blob/master/Structural/Adapter/Book.php#L22? It's master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, didn't know that php7 branch was merged on master #235
Behavioral/State/CreateOrder.php
Outdated
return $this->details['status']; | ||
$order = new ShippingOrder(); | ||
static::$state = $order; | ||
//$this->setStatus('shipping'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also $order
is superfluous here: static::$state = new ShippingOrder()
$contextOrder = new ContextOrder(); | ||
$contextOrder->setState($order); | ||
$contextOrder->done(); | ||
$contextOrder->done(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why done()
is fired twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's show, that's order from create go to shipping and after to completed. Our states is connected. It's normal behaviour, one order transform from one state to another.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the little change, it's ready to get merged.
Behavioral/State/CreateOrder.php
Outdated
return $this->details['status']; | ||
$order = new ShippingOrder(); | ||
static::$state = $order; | ||
//$this->setStatus('shipping'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also $order
is superfluous here: static::$state = new ShippingOrder()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey! Merge it.
I did, thanks! |
Clear. |
I will refactoring this pattern.