start(); // } public function __construct() { $this->start(); } public function start() { $this->start = $this->time(); } public function split() { $this->splits[] = $this->time(); return $this->getSplit(); } public function stop() { $this->stop = $this->time(); } function time() { return time(); } function diff($start, $end) { if (!isset($start) || !isset($end)) { return -1; } return $end - $start; } function getSplit() { $lastSplit = null; if (isset($this->stop)) { $lastSplit = $this->stop; } else { $count = count($this->splits); if ($count > 0) { $lastSplit = $this->splits[$count - 1]; } } return $this->diff($this->start, $lastSplit); } function getTotal(){ return $this->diff($this->start, $this->stop); } }