actually this questions is ambiguous.... for me this @Geo's answer is right one.
What you (@Anti) says could be composition
This is my example for this:
<?php
class Greeting {
private $what;
private $who;
public function say($what) {
$this->what = $what;
return $this;
}
public function to($who) {
$this->who = $who;
return $this;
}
public function __toString() {
return sprintf("%s %s
", $this->what, $this->who);
}
}
$greeting = new Greeting();
echo $greeting->say('hola')->to('gabriel'); // will print: hola gabriel
?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…