FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DesignPatternsPHP/AbstractFactory/AbstractFactory.php at master · NandoKstroNet/DesignPatternsPHP · GitHub
NandoKstroNet
/
DesignPatternsPHP
Public
forked from
DesignPatternsPHP/DesignPatternsPHP
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
DesignPatternsPHP
/
AbstractFactory
/
AbstractFactory.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (42 loc) · 1.32 KB
Breadcrumbs
DesignPatternsPHP
/
AbstractFactory
/
AbstractFactory.php
Copy path
File metadata and controls
45 lines (42 loc) · 1.32 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
<?php
namespace
DesignPatterns
\
AbstractFactory
;
/**
* Abstract Factory pattern
*
* Purpose:
* to create series of related or dependant objects without specifying their concrete classes,
* usually the created classes all implement the same interface. The client of the abstract
* factory does not care about how these objects are created, he just knows they go together.
*
* Sometimes also known as "Kit" in a GUI libraries.
*
* This design pattern implements the Dependency Inversion Principle since
* it is the concrete subclass which creates concrete components.
*
* In this case, the abstract factory is a contract for creating some components
* for the web. There are two components : Text and Picture. There is two ways
* of rendering : HTML or JSON.
*
* Therefore 4 concretes classes, but the client just need to know this contract
* to build a correct http response (for a html page or for an ajax request)
*/
abstract
class
AbstractFactory
{
/**
* Creates a text component
*
* @param string $content
*
* @return Text
*/
abstract
public
function
createText
(
$
content
);
/**
* Creates a picture component
*
* @param string $path
* @param string $name
*
* @return Picture
*/
abstract
public
function
createPicture
(
$
path
,
$
name
=
''
);
}
Back
|
FazBrowse Home
|
New Git URL