Passed
Pull Request — master (#1020)
by Maxim
21:39
created

InputProxy   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Test Coverage

Coverage 64.71%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 17
eloc 17
c 1
b 1
f 0
dl 0
loc 89
ccs 22
cts 34
cp 0.6471
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOptions() 0 3 1
A setInteractive() 0 3 1
A setOption() 0 3 1
A setArgument() 0 3 1
A getParameterOption() 0 6 1
A __toString() 0 3 1
A getArgument() 0 3 1
A isInteractive() 0 3 1
A hasParameterOption() 0 3 1
A getFirstArgument() 0 3 1
A bind() 0 3 1
A hasOption() 0 3 1
A hasArgument() 0 3 1
A validate() 0 3 1
A getArguments() 0 3 1
A getOption() 0 3 1
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();
0 ignored issues
show
Bug introduced by
The method __toString() does not exist on Symfony\Component\Console\Input\InputInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Consol...treamableInputInterface or Symfony\Component\Console\Input\Input or Symfony\Component\Console\Input\Input. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        return $this->input->/** @scrutinizer ignore-call */ __toString();
Loading history...
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