-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacade.php
More file actions
44 lines (40 loc) · 945 Bytes
/
facade.php
File metadata and controls
44 lines (40 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
//Facade Design Pattern
class SpaceShuttle {
function powerOn(){
echo "Power on\n";
}
function checkTemperature(){
echo "Temperature Ok\n";
}
function checkFuel(){
echo "We have enough fuel\n";
}
function startEngine(){
echo "Start Engine\n";
}
function startThrusters(){
echo "Done!\n";
}
}
class SpaceShuttleDecade {
private $shuttle;
function __construct(SpaceShuttle $shuttle){
$this->shuttle = $shuttle;
}
function takeOff(){
$this->shuttle->powerOn();
$this->shuttle->checkTemperature();
$this->shuttle->checkFuel();
$this->shuttle->startEngine();
$this->shuttle->startThrusters();
}
}
$ss = new SpaceShuttle();
$ssd = new SpaceShuttleDecade($ss);
$ssd->takeOff();
// $ss->powerOn();
// $ss->checkTemperature();
// $ss->checkFuel();
// $ss->startEngine();
// $ss->startThrusters();