tomu sa hovori fluent interface a hodi sa napriklad pre immutable typy:
class StringBuilder
{
private $value;
function __construct(array $value = array()) { $this->value = $value; }
function append($str)
{
return new StringBuilder(array_merge($this->value, array($str)));
}
function __toString() { return implode('', $this->value); }
}
echo (new StringBuilder())
->append("Ja")
->append(" ")
->append("Ty");