-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacade.php
52 lines (42 loc) · 808 Bytes
/
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
<?php
interface InterfaceA
{
public function make(): string;
}
class SubsystemA implements InterfaceA
{
public function make(): string
{
return __METHOD__;
}
}
interface InterfaceB
{
public function process(): string;
}
class SubsystemB implements InterfaceB
{
public function process(): string
{
return __METHOD__;
}
}
class Facade
{
public function __construct(
private InterfaceA $interfaceA,
private InterfaceB $interfaceB
) {
}
public function execute(): string
{
return $this->interfaceA->make() . '<br>' . $this->interfaceB->process();
}
}
/**
* Client
*/
$subsystemA = new SubsystemA();
$subsystemB = new SubsystemB();
$facade = new Facade($subsystemA, $subsystemB);
echo $facade->execute();