#MOC 既存の[[🗃️クラス]]を複数組み合わせて使う手順を「窓口」となる[[🗃️クラス]]を作って、シンプルに利用できるようにする[[🗃️デザインパターン]]。読み方はファサード(=建物の表玄関を意味する)。 ```mermaid classDiagram MovieWatchingFacade o-- Television MovieWatchingFacade o-- SoundSystem MovieWatchingFacade o-- BluRayPlayer class MovieWatchingFacade{ +watchMovie() } class Television{ +turnOn() } class SoundSystem{ +turnOn() +increaseVolume() } class BluRayPlayer{ +turnOn() +play() } ``` ```php class Television { public function turnOn() { echo "Turning on the television...\n"; } } class SoundSystem { public function turnOn() { echo "Turning on the sound system...\n"; } public function increaseVolume() { echo "Increasing the volume...\n"; } } class BluRayPlayer { public function turnOn() { echo "Turning on the BluRay player...\n"; } public function play() { echo "Playing the movie...\n"; } } class MovieWatchingFacade { private $television; private $soundSystem; private $bluRayPlayer; public function __construct() { $this->television = new Television(); $this->soundSystem = new SoundSystem(); $this->bluRayPlayer = new BluRayPlayer(); } public function watchMovie() { $this->television->turnOn(); $this->soundSystem->turnOn(); $this->soundSystem->increaseVolume(); $this->bluRayPlayer->turnOn(); $this->bluRayPlayer->play(); } } // Client code $facade = new MovieWatchingFacade(); $facade->watchMovie(); ``` ## 📚ドキュメント - [15.Facadeパターン | TECHSCORE(テックスコア)](https://www.techscore.com/tech/DesignPattern/Facade) ## 📖ノウハウ ## 💁トラブルシューティング