/*
外观模式:为一个分层或一个子系统创建一个单一的入口
*/
/**
*子系统1
*@author li.yonghuan
*@version 2014.01.15
*/
class SubSystem1{
public function method1(){
echo ' SubSystem1 method1';
}
}
/**
*子系统2
*@author li.yonghuan
*@version 2014.01.15
*/
class SubSystem2{
public function method2(){
echo ' SubSystem2 method2';
}
}
/**
*子系统3
*@author li.yonghuan
*@version 2014.01.15
*/
class SubSystem3{
public function method3(){
echo ' SubSystem3 method3';
}
}
/**
*原型模式
*@author li.yonghuan
*@version 2014.01.15
*
*/
class Facade{
private $_object1 = null;
private $_object2 = null;
private $_object3 = null;
public function __construct(){
$this->_object1 = new SubSystem1();
$this->_object2 = new SubSystem2();
$this->_object3 = new SubSystem3();
}
public function methodA(){
echo 'Facade methodA ';
$this->_object1->method1();
$this->_object2->method2();
echo '<br/>';
}
public function methodB(){
echo 'Facade methodB ';
$this->_object2->method2();
$this->_object3->method3();
echo '<br/>';
}
}
//测试
$facade = new Facade();
$facade->methodA();
$facade->methodB();
php 外观模式
最新推荐文章于 2023-03-28 09:00:45 发布