Your question is a bit vague, but I think what you are talking about is a Fluent Interface. The idea behind them is to enable you to call multiple methods on a single instance, by having each method return the instance. It's commonly used for setters on classes, and enables you to write code like:
$foo = new Foo();
$foo
->setThisThing()
->setAnotherThing()
->setThingToParameter($parameter)
...;
rather than
$foo->setThisThing();
$foo->setAnotherThing();
...
Whether you find this better or worse is a matter of taste, but Fluent interfaces do come some drawbacks
In your case, the shop class might look like:
<?php
class shop
{
private $couponText;
public function cart($function) {
// Do something with $function here
return $this;
}
public function coupon($couponText) {
$this->couponText = $couponText;
return $this;
}
public function getCoupon() {
return $this->couponText;
}
}
The key parts are the return $this;
lines - they allow you to chain subsequent method calls onto each other, as in your example.
See https://eval.in/851708 for an example.