summaryrefslogtreecommitdiff
path: root/vendor/symfony/console/Debug/CliRequest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/console/Debug/CliRequest.php')
-rw-r--r--vendor/symfony/console/Debug/CliRequest.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/vendor/symfony/console/Debug/CliRequest.php b/vendor/symfony/console/Debug/CliRequest.php
new file mode 100644
index 0000000..b023db0
--- /dev/null
+++ b/vendor/symfony/console/Debug/CliRequest.php
@@ -0,0 +1,70 @@
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
12namespace Symfony\Component\Console\Debug;
13
14use Symfony\Component\Console\Command\TraceableCommand;
15use Symfony\Component\HttpFoundation\Request;
16use Symfony\Component\HttpFoundation\Response;
17
18/**
19 * @internal
20 */
21final class CliRequest extends Request
22{
23 public function __construct(
24 public readonly TraceableCommand $command,
25 ) {
26 parent::__construct(
27 attributes: ['_controller' => \get_class($command->command), '_virtual_type' => 'command'],
28 server: $_SERVER,
29 );
30 }
31
32 // Methods below allow to populate a profile, thus enable search and filtering
33 public function getUri(): string
34 {
35 if ($this->server->has('SYMFONY_CLI_BINARY_NAME')) {
36 $binary = $this->server->get('SYMFONY_CLI_BINARY_NAME').' console';
37 } else {
38 $binary = $this->server->get('argv')[0];
39 }
40
41 return $binary.' '.$this->command->input;
42 }
43
44 public function getMethod(): string
45 {
46 return $this->command->isInteractive ? 'INTERACTIVE' : 'BATCH';
47 }
48
49 public function getResponse(): Response
50 {
51 return new class($this->command->exitCode) extends Response {
52 public function __construct(private readonly int $exitCode)
53 {
54 parent::__construct();
55 }
56
57 public function getStatusCode(): int
58 {
59 return $this->exitCode;
60 }
61 };
62 }
63
64 public function getClientIp(): string
65 {
66 $application = $this->command->getApplication();
67
68 return $application->getName().' '.$application->getVersion();
69 }
70}