PHP Timer

php

I made a small PHP Timer because I always ended up googling the code instead of writing it.

The API is easy, just two static function; start() and stop().

<?php
 
class Timer {
 
    protected static $start_time = 0.00;
    protected static $total_time = 0.00;
 
    public static function start() {
        self::$start_time = microtime(true);
    }
 
    public static function stop() {
        $time_end = microtime(true);
        $end_time = $time_end - self::$start_time;
        self::$total_time = $end_time + self::$total_time;
        return sprintf("%.3fs (%.3fs total)" ,$end_time, self::$total_time );
    }
}