Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 8b74ab9

Browse files
committed
enhance dumper
1 parent 9c09d16 commit 8b74ab9

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

src/Helpers/Dump.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Helpers/Dumper.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace SwooleTW\Http\Helpers;
4+
5+
use Symfony\Component\VarDumper\Cloner\VarCloner;
6+
use Symfony\Component\VarDumper\Dumper\CliDumper;
7+
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
8+
9+
class VarDumper
10+
{
11+
protected static $cloner;
12+
13+
public static function dump(...$args)
14+
{
15+
if (! static::$cloner instanceOf VarCloner) {
16+
static::$cloner = new VarCloner;
17+
}
18+
19+
$dumper = static::getDumper();
20+
21+
foreach ($args as $arg) {
22+
$dumper->dump(
23+
static::$cloner->cloneVar($arg)
24+
);
25+
}
26+
27+
return true;
28+
}
29+
30+
public static function getDumper()
31+
{
32+
$dumper = defined('IN_PHPUNIT') || ! config('swoole_http.ob_output')
33+
? CliDumper::class
34+
: HtmlDumper::class;
35+
36+
return new $dumper;
37+
}
38+
}

0 commit comments

Comments
 (0)