なんか気付いたら書いていたので、ここに供養します。
<?php
class Friends
{
private $message = null;
public function __construct()
{
$this->message = '';
}
public function wai()
{
$this->message .= "わーい\n";
return $this;
}
public function sugoi()
{
$this->message .= "すごーい\n";
return $this;
}
public function tanoshii()
{
$this->message .= "たのしー\n";
return $this;
}
public function friends($skill)
{
$this->message .= '君は' . $skill . 'がとくいな、フレンズなんだね!!' . "\n";
return $this;
}
public function __toString()
{
$message = $this->message;
$this->message = '';
return $message;
}
}
echo (new Friends())
->wai()
->sugoi()
->tanoshii()
->friends('クソリプ');