-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy path8-facade.php
62 lines (52 loc) · 998 Bytes
/
8-facade.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class CheckOilPressure
{
public function check()
{
echo "Oil Pressure OK.\n";
}
}
class CheckFuel
{
public function check()
{
echo "Fuel Status OK.\n";
}
}
class CheckBreakFluid
{
public function check()
{
echo "Break Fluid OK.\n";
}
}
// === Car Facede ===
// That provide simple interface (wrapper) to complex steps
// To start a car engine, the all we need is start() method
class Car
{
public $oil;
public $fuel;
public $break;
public function __construct()
{
$this->oil = new CheckOilPressure();
$this->fuel = new CheckFuel();
$this->break = new CheckBreakFluid();
}
public function start()
{
$this->oil->check();
$this->fuel->check();
$this->break->check();
echo "Car Engine Started.\n";
}
}
// ---
$car = new Car();
$car->start();
// Output:
// Oil Pressure OK.
// Fuel Status OK.
// Break Fluid OK.
// Car Engine Started.