PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / var-dumper / Command / ServerDumpCommand.php
matomo / app / vendor / prefixed / symfony / var-dumper / Command Last commit date
Descriptor 1 year ago ServerDumpCommand.php 2 years ago
ServerDumpCommand.php
92 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\VarDumper\Command;
12
13 use Matomo\Dependencies\Symfony\Component\Console\Command\Command;
14 use Matomo\Dependencies\Symfony\Component\Console\Completion\CompletionInput;
15 use Matomo\Dependencies\Symfony\Component\Console\Completion\CompletionSuggestions;
16 use Matomo\Dependencies\Symfony\Component\Console\Exception\InvalidArgumentException;
17 use Matomo\Dependencies\Symfony\Component\Console\Input\InputInterface;
18 use Matomo\Dependencies\Symfony\Component\Console\Input\InputOption;
19 use Matomo\Dependencies\Symfony\Component\Console\Output\OutputInterface;
20 use Matomo\Dependencies\Symfony\Component\Console\Style\SymfonyStyle;
21 use Matomo\Dependencies\Symfony\Component\VarDumper\Cloner\Data;
22 use Matomo\Dependencies\Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
23 use Matomo\Dependencies\Symfony\Component\VarDumper\Command\Descriptor\DumpDescriptorInterface;
24 use Matomo\Dependencies\Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
25 use Matomo\Dependencies\Symfony\Component\VarDumper\Dumper\CliDumper;
26 use Matomo\Dependencies\Symfony\Component\VarDumper\Dumper\HtmlDumper;
27 use Matomo\Dependencies\Symfony\Component\VarDumper\Server\DumpServer;
28 /**
29 * Starts a dump server to collect and output dumps on a single place with multiple formats support.
30 *
31 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
32 *
33 * @final
34 */
35 class ServerDumpCommand extends Command
36 {
37 protected static $defaultName = 'server:dump';
38 protected static $defaultDescription = 'Start a dump server that collects and displays dumps in a single place';
39 private $server;
40 /** @var DumpDescriptorInterface[] */
41 private $descriptors;
42 public function __construct(DumpServer $server, array $descriptors = [])
43 {
44 $this->server = $server;
45 $this->descriptors = $descriptors + ['cli' => new CliDescriptor(new CliDumper()), 'html' => new HtmlDescriptor(new HtmlDumper())];
46 parent::__construct();
47 }
48 protected function configure()
49 {
50 $this->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format (%s)', implode(', ', $this->getAvailableFormats())), 'cli')->setDescription(self::$defaultDescription)->setHelp(<<<'EOF'
51 <info>%command.name%</info> starts a dump server that collects and displays
52 dumps in a single place for debugging you application:
53
54 <info>php %command.full_name%</info>
55
56 You can consult dumped data in HTML format in your browser by providing the <comment>--format=html</comment> option
57 and redirecting the output to a file:
58
59 <info>php %command.full_name% --format="html" > dump.html</info>
60
61 EOF
62 );
63 }
64 protected function execute(InputInterface $input, OutputInterface $output) : int
65 {
66 $io = new SymfonyStyle($input, $output);
67 $format = $input->getOption('format');
68 if (!($descriptor = $this->descriptors[$format] ?? null)) {
69 throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format));
70 }
71 $errorIo = $io->getErrorStyle();
72 $errorIo->title('Symfony Var Dumper Server');
73 $this->server->start();
74 $errorIo->success(sprintf('Server listening on %s', $this->server->getHost()));
75 $errorIo->comment('Quit the server with CONTROL-C.');
76 $this->server->listen(function (Data $data, array $context, int $clientId) use($descriptor, $io) {
77 $descriptor->describe($io, $data, $context, $clientId);
78 });
79 return 0;
80 }
81 public function complete(CompletionInput $input, CompletionSuggestions $suggestions) : void
82 {
83 if ($input->mustSuggestOptionValuesFor('format')) {
84 $suggestions->suggestValues($this->getAvailableFormats());
85 }
86 }
87 private function getAvailableFormats() : array
88 {
89 return array_keys($this->descriptors);
90 }
91 }
92