Php design mode Bridge (Bridge mode ). Copy the code as follows :? Php *** bridging mode ** separates the abstract part from its implementation part, and each of them can have independent changes. * abstractclassImplementor {abstractpubl
The code is as follows:
/**
* Bridging mode
*
* Separate the abstract part from its implementation part, and use them to have independent changes
*/
Abstract class Implementor
{
Abstract public function operation ();
}
Class ConcreteImplementorA extends Implementor
{
Public function operation ()
{
Echo "ConcreteImplementorA Operation
";
}
}
Class ConcreteImplementorB extends Implementor
{
Public function operation ()
{
Echo "ConcreteImplementorB Operation
";
}
}
Class Program action
{
Protected $ _ implementor = null;
Public function setImplementor ($ implementor)
{
$ This-> _ implementor = $ implementor;
}
Public function operation ()
{
$ This-> _ implementor-> operation ();
}
}
Class RefinedAbstraction extends action
{
}
Class ExampleAbstraction extends action
{
}
//
$ Objr1_action = new refined1_action ();
$ Objr1_action-> setImplementor (new ConcreteImplementorB ());
$ Objr1_action-> operation ();
$ Objr1_action-> setImplementor (new ConcreteImplementorA ());
$ Objr1_action-> operation ();
$ Objedomainaction = new exampledomainaction ();
$ Objesponaction-> setImplementor (new ConcreteImplementorB ());
$ Objesponaction-> operation ();
The http://www.bkjia.com/PHPjc/323618.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323618.htmlTechArticle code is as follows :? Php/*** bridge mode ** separates the abstract part from its implementation part, and each of them can have independent changes */abstract class Implementor {abstract publ...