Skip to content

Conversation

ko22009
Copy link
Contributor

@ko22009 ko22009 commented Apr 27, 2017

I will refactoring this pattern.

state pattern change readme.rst

class ContextOrder extends StateOrder
{
public function getState():StateOrder
Copy link
Contributor

@gmsantos gmsantos May 1, 2017

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

Copy link
Contributor Author

@ko22009 ko22009 May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@gmsantos gmsantos May 1, 2017

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

return $this->details['status'];
$order = new ShippingOrder();
static::$state = $order;
//$this->setStatus('shipping');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@domnikl domnikl left a 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.

return $this->details['status'];
$order = new ShippingOrder();
static::$state = $order;
//$this->setStatus('shipping');
Copy link
Contributor

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()

@ko22009 ko22009 closed this May 10, 2017
@ko22009 ko22009 reopened this May 10, 2017
Copy link
Contributor Author

@ko22009 ko22009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey! Merge it.

@domnikl domnikl merged commit c1f0fac into DesignPatternsPHP:master May 10, 2017
@domnikl
Copy link
Contributor

domnikl commented May 10, 2017

I did, thanks!

@ko22009
Copy link
Contributor Author

ko22009 commented May 10, 2017

Clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants