Recently read some information about design patterns, just can use the factory model to organize some of the previous summary of the payment class and landing class
Factory mode, which simply means using a class to instantiate other classes and eventually return objects of that class. For example, a workshop factory, specializing in the production of BMW, Mercedes-Benz, Laus Ross and other cars, then abstract into class, the workshop plant is a factory class, BMW, Mercedes-Benz, Laus Ross is an object, through this factory class to produce an object, this mode is the Factory mode.
Previously summarized payment interfaces, now sorted using Factory mode
1. Establishment of factory class
The various payment classes are instantiated by means of a parameter ($name)
2. Payment Class
(1) Epay
(2) Wpay
By passing the value of the $name (Epay,wpay), instantiating the corresponding payment class, returning the object after calling its payment method, can complete the payment, when there is a new payment class interface need to expand, no need to change any code can continue to use the factory, extensibility is very strong.
With tp3.2, this article is simply a description of the combination of Factory mode integration of various payment classes.
Application of Factory mode