Refactoring classes into src/ folder, so they will be auto-loaded by composer

This commit is contained in:
slawkens
2024-01-27 00:36:49 +01:00
parent 410d75c882
commit 1a6fb8bee2
78 changed files with 439 additions and 341 deletions

56
system/src/Timer.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
/**
* Timer class
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2019 MyAAC
* @link https://my-aac.org
*/
namespace MyAAC;
class Timer
{
private $start = 0;
private $stop = 0;
private $elapsed = 0;
function __construct($start = true) {
if($start) $this->start();
}
function start() {
$this->start = $this->_gettime();
}
function stop()
{
$this->stop = $this->_gettime();
$this->elapsed = $this->_compute();
}
function elapsed()
{
if(!$this->elapsed)
$this->stop();
return $this->elapsed;
}
function reset()
{
$this->start = 0;
$this->stop = 0;
$this->elapsed = 0;
}
private function _gettime() {
return microtime(true);
}
private function _compute() {
return $this->stop - $this->start;
}
}
?>