2 title: s/fluent/decorated/
8 I've [read](http://www.achievo.org/blog/archives/25-The-danger-of-Fluent-interfaces.html)
9 [some](http://andigutmans.blogspot.com/2005/12/fluent-interfaces.html)
10 [posts](http://paul-m-jones.com/blog/?p=188) about "fluent interfaces" and
11 I have to agree that it's a bad idea to sacrifice a reasonable
12 API to be able to write english code.
14 It's anyway possible to accomplish that to some extent on a need-by-need basis
15 with a class of only 20 lines of code:
18 class ReturnThisDecorator
23 function __construct($object)
25 if (is_object($object)) {
26 $this->object = $object;
28 throw new InvalidArgumentException(
29 "Expected an object as argument"
34 function __call($method, $params)
36 $this->result = call_user_func_array(
37 array($this->object, $method), $params
43 $sms = new ReturnThisDecorator(new SMS);
44 echo $sms->from('...')->to('...')->message('...')->send()->result;