Skip to content

Commit 2e99160

Browse files
author
Lucas Michot
committed
No need to construct both descriptors.
1 parent d24b641 commit 2e99160

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/DumpServerCommand.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,33 @@ class DumpServerCommand extends Command
2929
*/
3030
protected $description = 'Start the dump server to collect dump information';
3131

32-
/** @var DumpServer */
33-
private $server;
34-
3532
/**
36-
* @var \Symfony\Component\VarDumper\Command\Descriptor\DumpDescriptorInterface[]
33+
* @var \Symfony\Component\VarDumper\Server\DumpServer
3734
*/
38-
private $descriptors;
35+
private $server;
3936

4037
public function __construct(DumpServer $server)
4138
{
4239
$this->server = $server;
4340

44-
$this->descriptors = [
45-
'cli' => new CliDescriptor(new CliDumper()),
46-
'html' => new HtmlDescriptor(new HtmlDumper()),
47-
];
48-
4941
parent::__construct();
5042
}
5143

5244
public function handle()
5345
{
54-
$io = new SymfonyStyle($this->input, $this->output);
55-
$format = $this->option('format');
56-
57-
if (! $descriptor = $this->descriptors[$format] ?? null) {
58-
throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format));
46+
switch ($format = $this->option('format')) {
47+
case 'cli':
48+
$descriptor = new CliDescriptor(new CliDumper);
49+
break;
50+
case 'html':
51+
$descriptor = new HtmlDescriptor(new HtmlDumper);
52+
break;
53+
default:
54+
throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format));
5955
}
6056

57+
$io = new SymfonyStyle($this->input, $this->output);
58+
6159
$errorIo = $io->getErrorStyle();
6260
$errorIo->title('Laravel Var Dump Server');
6361

0 commit comments

Comments
 (0)