Возможно ли узнать, вызван ли вызов метода из цепочки методов?
Для меня, например, сильфон class
:Проверьте, является ли вызов методом цепочки
class Test{
protected $string = '123';
public function a($string){
$this->string .= $string;
if(method chain){
return $this;
}else{
return $this->string;
}
}
public function b($string){
$this->string .= $string;
if(method chain){
return $this;
}else{
return $this->string;
}
}
}
Результат:
$test = new Test();
echo $test->a('000'); // 123000
echo $test->a('000')->b('www'); // 123000www
UPDATE
Я кончался создание exec()
метод, чтобы сказать нет больше методов не собирались назвать.
public function exec(){
return $this->string;
}