-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/ShippingOrder.php#L22
https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/CreateOrder.php#L28
Refactoring code to create interfaces which is seperate completeOrder and shipOrder.
Maybe will be useful https://softwareengineering.stackexchange.com/questions/181922/does-the-state-pattern-violate-liskov-substitution-principle
And also you have bad style and you code is not maintainable: https://github.com/domnikl/DesignPatternsPHP/blob/master/Behavioral/State/OrderRepository.php#L24
You can create class which is implement the same interface and pass your created objects(CreateOrder and ShippingOrder) - DI. Override interface class in your new class and call your parent method there. (you can apply decorator there too)