From 49148e87d43fd9408a2777c4654dbd51d02e5c6e Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 17 Sep 2025 18:44:52 +0000 Subject: [PATCH] - Added details tag in HTML output for better visual and accessibility --- src/Dump.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Dump.php b/src/Dump.php index c5e2c49..7b8d20a 100644 --- a/src/Dump.php +++ b/src/Dump.php @@ -33,15 +33,17 @@ class Dump { } public function renderHtml() { - $data = $this->getDumpContent(); + $data = implode('', array_map(fn($e) => "

$e

", $this->getDumpContent(true))); $this->trace['file'] ??= "?"; $this->trace['line'] ??= "?"; return << -
[ file: {$this->trace['file']}:{$this->trace['line']} ] timestamp: {$this->trace['time']}
-$data +
+    
+ [ file: {$this->trace['file']}:{$this->trace['line']} ] timestamp: {$this->trace['time']} +

$data

+
HTML; } @@ -57,9 +59,18 @@ HTML; return str_repeat('-', strlen($header)) . PHP_EOL . $header . PHP_EOL . str_repeat('-', strlen($header)) . PHP_EOL . $data . PHP_EOL; } - protected function getDumpContent() { + protected function getDumpContent(bool $split = false) : string|array { + if ($split) { + return array_map(fn($e) => $this->renderDump([ $e ]), $this->content ?: [ null ]); + } + + return $this->renderDump($this->content !== [] ? $this->content : [null]); + } + + protected function renderDump(mixed $any) : string + { ob_start(); - var_dump(...($this->content !== [] ? $this->content : [null])); + var_dump(...$any); return ob_get_clean(); }