-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate_method.php
59 lines (50 loc) · 1.46 KB
/
template_method.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
<?php
/**
* Template method pattern example
*
* @author Christian Bergau <cbergau86@gmail.com>
* @copyright Free for all
* @link http://en.wikipedia.org/wiki/Template_method
*/
abstract class Product
{
abstract public function actionOne();
abstract public function actionTwo();
abstract public function actionThree();
public function doTheActions()
{
$this->actionOne();
$this->actionTwo();
$this->actionThree();
}
}
class ConcreteProductA extends Product
{
public function actionOne()
{
// Implement actionOne for ProductA which can be a little different to other products implementation
}
public function actionTwo()
{
// Implement actionTwo for ProductA which can be a little different to other products implementation
}
public function actionThree()
{
// Implement actionThree for ProductA which can be a little different to other products implementation
}
}
class ConcreteProductB extends Product
{
public function actionOne()
{
// Implement actionOne for ProductB which can be a little different to other products implementation
}
public function actionTwo()
{
// Implement actionTwo for ProductB which can be a little different to other products implementation
}
public function actionThree()
{
// Implement actionThree for ProductB which can be a little different to other products implementation
}
}