<?php
interface Counter
{
/** @return self */
public function count();
/** @return int */
public function getCount();
}
class FluentCounter implements Counter
{
private $count = 0;
public function count()
{
$this->count += 1;
return $this;
}
public function getCount()
{
return $this->count;
}
}
$counter = new FluentCounter();
echo $counter->count()->count()->count()->getCount();