-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugger.php
More file actions
77 lines (70 loc) · 1.48 KB
/
Debugger.php
File metadata and controls
77 lines (70 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* @author : Jakiboy
* @package : FloatPHP
* @subpackage : Helpers Framework Component
* @version : 1.5.x
* @copyright : (c) 2018 - 2025 Jihad Sinnaour <me@jihadsinnaour.com>
* @link : https://floatphp.com
* @license : MIT
*
* This file is a part of FloatPHP Framework.
*/
declare(strict_types=1);
namespace FloatPHP\Helpers\Framework;
use FloatPHP\Classes\Server\System;
use FloatPHP\Classes\Filesystem\Converter;
use FloatPHP\Helpers\Connection\Transient;
final class Debugger
{
/**
* Init debug execution time.
*
* @access public
* @return void
*/
public static function init() : void
{
if ( self::enabled() ) {
global $appStartTime;
$appStartTime = microtime(true);
}
}
/**
* Set debug execution time.
*
* @access public
* @return void
*/
public static function setExecutionTime() : void
{
if ( self::enabled() ) {
global $appStartTime;
if ( isset($appStartTime) ) {
$time = (microtime(true) - $appStartTime);
$time = Converter::toFloat($time, 3);
(new Transient())->setTemp(key: '--execution-time', value: $time, ttl: 0);
}
}
}
/**
* Get debug execution time.
*
* @access public
* @return mixed
*/
public static function getExecutionTime() : mixed
{
return (new Transient())->getTemp(key: '--execution-time');
}
/**
* Check xdebug status.
*
* @access public
* @return bool
*/
public static function enabled() : bool
{
return (bool)System::getIni(option: 'xdebug.mode');
}
}