1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Spiral\Console; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Provides the ability to inject desired command name into Symfony\Console\Application->doRun(); |
12
|
|
|
*/ |
13
|
|
|
final class InputProxy implements InputInterface |
14
|
|
|
{ |
15
|
100 |
|
public function __construct( |
16
|
|
|
private readonly InputInterface $input, |
17
|
|
|
private readonly array $overwrite |
18
|
|
|
) { |
19
|
100 |
|
} |
20
|
|
|
|
21
|
|
|
public function __toString(): string |
22
|
|
|
{ |
23
|
|
|
return $this->input->__toString(); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
100 |
|
public function getFirstArgument(): ?string |
27
|
|
|
{ |
28
|
100 |
|
return $this->overwrite['firstArgument'] ?? $this->input->getFirstArgument(); |
29
|
|
|
} |
30
|
|
|
|
31
|
100 |
|
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool |
32
|
|
|
{ |
33
|
100 |
|
return $this->input->hasParameterOption($values, $onlyParams); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getParameterOption( |
37
|
|
|
string|array $values, |
38
|
|
|
string|bool|int|float|array|null $default = false, |
39
|
|
|
bool $onlyParams = false |
40
|
|
|
): mixed { |
41
|
|
|
return $this->input->getParameterOption($values, $default, $onlyParams); |
42
|
|
|
} |
43
|
|
|
|
44
|
100 |
|
public function bind(InputDefinition $definition): void |
45
|
|
|
{ |
46
|
100 |
|
$this->input->bind($definition); |
47
|
|
|
} |
48
|
|
|
|
49
|
100 |
|
public function validate(): void |
50
|
|
|
{ |
51
|
100 |
|
$this->input->validate(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getArguments(): array |
55
|
|
|
{ |
56
|
|
|
return $this->input->getArguments(); |
57
|
|
|
} |
58
|
|
|
|
59
|
100 |
|
public function getArgument(string $name): mixed |
60
|
|
|
{ |
61
|
100 |
|
return $this->input->getArgument($name); |
62
|
|
|
} |
63
|
|
|
|
64
|
97 |
|
public function setArgument(string $name, mixed $value): void |
65
|
|
|
{ |
66
|
97 |
|
$this->input->setArgument($name, $value); |
67
|
|
|
} |
68
|
|
|
|
69
|
100 |
|
public function hasArgument(string $name): bool |
70
|
|
|
{ |
71
|
100 |
|
return $this->input->hasArgument($name); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getOptions(): array |
75
|
|
|
{ |
76
|
|
|
return $this->input->getOptions(); |
77
|
|
|
} |
78
|
|
|
|
79
|
64 |
|
public function getOption(string $name): mixed |
80
|
|
|
{ |
81
|
64 |
|
return $this->input->getOption($name); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function setOption(string $name, mixed $value): void |
85
|
|
|
{ |
86
|
|
|
$this->input->setOption($name, $value); |
87
|
|
|
} |
88
|
|
|
|
89
|
36 |
|
public function hasOption(string $name): bool |
90
|
|
|
{ |
91
|
36 |
|
return $this->input->hasOption($name); |
92
|
|
|
} |
93
|
|
|
|
94
|
100 |
|
public function isInteractive(): bool |
95
|
|
|
{ |
96
|
100 |
|
return $this->input->isInteractive(); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setInteractive(bool $interactive): void |
100
|
|
|
{ |
101
|
|
|
$this->input->setInteractive($interactive); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|