-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenClose.php
62 lines (48 loc) · 1.03 KB
/
OpenClose.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
<?php
// Bed desing
Class FileType{
function getDisplay($file,$fileType){
if('mp4'==$fileType){
//display Video
}elseif('mp3'==$fileType){
// display Audio
}elseif('image'==$fileType){
// display picture
}else{
}
}
}
// Open Close Principal
Class FileDisplay{
function display(fileInterFace $file){
$file->display();
}
}
interface fileInterFace{
function display();
}
Class ImageFile implements fileInterFace{
function display()
{
// take nessary steps to display image
}
}
Class VideoFile implements fileInterFace{
function display()
{
// take nessary steps to display Video
}
}
Class Audio implements fileInterFace{
function display()
{
// take nessary steps to display Audio
}
}
$audio = New Audio('abcd.mp3');
$image = New ImageFile('abcd.jpeg');
$video = New VideoFile('abcd.mp4');
$fd = New FileDisplay();
$fd->display($image);
$fd->display($video);
$fd->display($audio);