|
|
|
@ -7,10 +7,16 @@ use Spip\Loader\Http\Request;
|
|
|
|
|
|
|
|
|
|
final class Debug {
|
|
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
|
private static $enable = false;
|
|
|
|
|
|
|
|
|
|
/** @var array<string, mixed> */
|
|
|
|
|
private static $bag = [];
|
|
|
|
|
|
|
|
|
|
/** @var Internal */
|
|
|
|
|
private $internal;
|
|
|
|
|
|
|
|
|
|
/** @var Request */
|
|
|
|
|
private $request;
|
|
|
|
|
|
|
|
|
|
public function __construct(Request $request, Internal $internal) {
|
|
|
|
@ -18,10 +24,16 @@ final class Debug {
|
|
|
|
|
$this->internal = $internal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @param mixed $value
|
|
|
|
|
* @return void;
|
|
|
|
|
*/
|
|
|
|
|
public static function add($key, $value) {
|
|
|
|
|
self::$bag[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @return void */
|
|
|
|
|
public static function enable() {
|
|
|
|
|
if (!self::$enable) {
|
|
|
|
|
self::$enable = true;
|
|
|
|
@ -35,6 +47,7 @@ final class Debug {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @return string */
|
|
|
|
|
public function debug() {
|
|
|
|
|
return "<div class='msg-alert notice' style='margin-bottom:0'>"
|
|
|
|
|
. $this->table($this->internal->toArray())
|
|
|
|
@ -43,6 +56,7 @@ final class Debug {
|
|
|
|
|
. "</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @return array<string, scalar> */
|
|
|
|
|
private function server_info() {
|
|
|
|
|
return [
|
|
|
|
|
'PATH_INFO' => $this->request->server('PATH_INFO'),
|
|
|
|
@ -55,6 +69,10 @@ final class Debug {
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array<string, mixed> $data
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function table(array $data) {
|
|
|
|
|
$box = "<table style='margin: .75em 0;'>";
|
|
|
|
|
foreach ($data as $key => $val) {
|
|
|
|
|