forked from cbergau/PHPDesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fluent_interface.php
53 lines (45 loc) · 922 Bytes
/
fluent_interface.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
<?php
/**
* Fluent interface example
*
* @author Christian Bergau <[email protected]>
* @copyright Free for all
* @link http://en.wikipedia.org/wiki/Fluent_interface
*/
class Product
{
protected $valueA;
protected $valueB;
protected $valueC;
public function setValueA($valueA)
{
$this->valueA = $valueA;
return $this;
}
public function getValueA()
{
return $this->valueA;
}
public function setValueB($valueB)
{
$this->valueB = $valueB;
return $this;
}
public function getValueB()
{
return $this->valueB;
}
public function setValueC($valueC)
{
$this->valueC = $valueC;
return $this;
}
public function getValueC()
{
return $this->valueC;
}
}
$product = new Product();
$product->setValueA('A')
->setValueB('B')
->setValueC('C');