FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpHomeworks/designPatternFactory.php at master · randomrandom/phpHomeworks · GitHub
randomrandom
/
phpHomeworks
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
phpHomeworks
/
designPatternFactory.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (50 loc) · 1.16 KB
Breadcrumbs
phpHomeworks
/
designPatternFactory.php
Copy path
File metadata and controls
67 lines (50 loc) · 1.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
63
64
65
66
67
<?php
abstract
class
IceCream {
public
function
getType
(){
echo
$
this
->
type
;
}
}
class
Raffi
extends
IceCream{
private
$
type
=
"
Raffi
"
;
public
function
getType
(){
echo
$
this
->
type
;
}
}
class
Delta
extends
IceCream{
private
$
type
=
"
Delta
"
;
public
function
getType
(){
echo
$
this
->
type
;
}
}
class
Darko
extends
IceCream{
private
$
type
=
"
Darko
"
;
public
function
getType
(){
echo
$
this
->
type
;
}
}
class
IceCreamFactory {
const
RAFFI
=
"
Raffi
"
;
const
DELTA
=
"
Delta
"
;
const
DARKO
=
"
Darko
"
;
public
static
function
createIceCream
(
$
iceCreamType
){
switch
(
$
iceCreamType
){
case
self
::
RAFFI
:
return
new
Raffi
();
break
;
case
self
::
DELTA
:
return
new
Delta
();
break
;
case
self
::
DARKO
:
return
new
Darko
();
}
die
(
"
IceCream isn't recognized.
"
);
}
}
$
iceCreamFactory
=
new
IceCreamFactory
();
$
Raffi
=
$
iceCreamFactory
->
createIceCream
(IceCreamFactory::
RAFFI
);
$
Raffi
->
getType
();
$
Delta
=
$
iceCreamFactory
->
createIceCream
(IceCreamFactory::
DELTA
);
$
Delta
->
getType
();
$
Darko
=
$
iceCreamFactory
->
createIceCream
(IceCreamFactory::
DARKO
);
$
Darko
->
getType
();
?>
Back
|
FazBrowse Home
|
New Git URL