-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapapter.php
More file actions
executable file
·46 lines (42 loc) · 784 Bytes
/
apapter.php
File metadata and controls
executable file
·46 lines (42 loc) · 784 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
45
46
<?php
interface target{
function action_one();
function action_two();
}
class adaptee{
function action_one(){
echo 1231;
}
function action_two(){
echo 'two1';
}
}
class adapter extends adaptee implements target{
function action_one(){
$obj = new adaptee();
$obj->action_one();
}
function action_two(){
$obj = new adaptee();
$obj->action_two();
}
}
class apapter_two implements target{
public $list;
public function __construct($obj){
$this->list = $obj;
}
function action_one(){
$this->list->action_one();
}
function action_two(){
$this->list->action_two();
}
}
$ad = new adapter();
$ad->action_one();
$ad->action_two();
$adaptee = new adaptee();
$adapter_two = new apapter_two($adaptee);
$adapter_two->action_one();
$adapter_two->action_two();