首頁  >  文章  >  後端開發  >  adobe bridge php設計模式 Bridge 橋接模式

adobe bridge php設計模式 Bridge 橋接模式

WBOY
WBOY原創
2016-07-29 08:45:46995瀏覽

複製程式碼程式碼如下:


/**
* 橋接模式
*
* 將抽象部份與它實現部分分離,使用它們都可以有獨立的變化
*/
抽象類別Imple
/***/
抽象類Implementor
{
抽象公用函數運算();
}
class ConcreteImplementorA extends Implementor
{
公用函數運算()
{
echo "ConcreteImpleorecho >";
}
}
class ConcreteImplementorB extends Implementor
{
公用函數運算()
{
echo "ConcreteImplementorB 運算
"; }
}
類別抽象
{
protected $_implementor = null;
public function setImplementor($implementor)
{
$this->_implementor = $implementor; 🎜>}
公用函數運算()
{
$this->_implementor->operation();
}
}
class RefinedAbstraction 擴充Abstraction
{
class RefinedAbstraction 擴充Abstraction
{
class RefinedAbstraction 擴充Abstraction
{
class RefinedAbstraction >}
class ExampleAbstraction 擴充Abstraction
{
}
//
$objRAbstraction = new精煉抽象();
$objRAbstraction->setImplementor(newBetImplementor(newB); 🎜>$objRAbstraction->操作();
$objRAbstraction->setImplementor(new ConcreteImplementorA());
$objRAbstraction->操作();
$objEAbstraction = newample; $objEAbstraction->setImplementor(new ConcreteImplementorB());

$objEAbstraction->操作();

以上就介紹了adobebridge php設計模式Bridge橋接模式,包含了adobebridge方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn