<?php /** * 外觀模式 * 爲其餘子系統或者其餘類. * 提供一個更高層的通用接口(或類). */ class TypeA { public function getMy () { echo 'TypeA'.PHP_EOL; } } class TypeB { public function getMy () { echo 'TypeB'.PHP_EOL; } } class TypeC { public function getMy () { echo 'TypeC'.PHP_EOL; } } /** * Class Exterior * 統一調用高級接口 */ class Exterior { protected $typeA; protected $typeB; protected $typeC; public function __construct() { $this->typeA = new TypeA(); $this->typeB = new TypeB(); $this->typeC = new TypeC(); } public function get () { $this->typeA->getMy(); $this->typeB->getMy(); $this->typeC->getMy(); } } $ext = new Exterior(); $ext->get(); //TypeA //TypeB //TypeC