PHP: chaining methods with variable methods -


here code:

return pdf::loadfile($url)     ->setpaper('a4')     ->setoption('margin-top', 10)     ->stream('somefile.pdf'); 

as calling method on multiple locations, there kind of option call in way this?

return pdf::loadfile($url)     ->callsettings()     ->stream('somefile.pdf'); 

where settings ->setpaper('a4')->setoption('margin-top', 10).

it's easy. implement new callsettings() method in pdf class, calls methods , returns $this:

public function callsettings() {     $this->setpaper('a4')          ->setoption('margin-top', 10);      return $this; } 

Comments