This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php declare(strict_types=1); |
||
2 | |||
3 | namespace Limoncello\Commands\Wrappers; |
||
4 | |||
5 | /** |
||
6 | * Copyright 2015-2019 [email protected] |
||
7 | * |
||
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
9 | * you may not use this file except in compliance with the License. |
||
10 | * You may obtain a copy of the License at |
||
11 | * |
||
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
13 | * |
||
14 | * Unless required by applicable law or agreed to in writing, software |
||
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
17 | * See the License for the specific language governing permissions and |
||
18 | * limitations under the License. |
||
19 | */ |
||
20 | |||
21 | use Limoncello\Contracts\Commands\IoInterface; |
||
22 | use Symfony\Component\Console\Input\InputInterface; |
||
23 | use Symfony\Component\Console\Output\OutputInterface; |
||
24 | |||
25 | /** |
||
26 | * @package Limoncello\Commands |
||
27 | */ |
||
28 | class ConsoleIoWrapper implements IoInterface |
||
29 | { |
||
30 | /** |
||
31 | * @var InputInterface |
||
32 | */ |
||
33 | private $input; |
||
34 | |||
35 | /** |
||
36 | * @var OutputInterface |
||
37 | */ |
||
38 | private $output; |
||
39 | |||
40 | /** |
||
41 | * @param InputInterface $input |
||
42 | 12 | * @param OutputInterface $output |
|
43 | */ |
||
44 | 12 | public function __construct(InputInterface $input, OutputInterface $output) |
|
45 | 12 | { |
|
46 | $this->input = $input; |
||
47 | $this->output = $output; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | 4 | * @inheritdoc |
|
52 | */ |
||
53 | 4 | public function hasArgument(string $name): bool |
|
54 | { |
||
55 | return $this->getInput()->hasArgument($name); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | 8 | * @inheritdoc |
|
60 | */ |
||
61 | 8 | public function getArgument(string $name) |
|
62 | { |
||
63 | return $this->getInput()->getArgument($name); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | 1 | * @inheritdoc |
|
68 | */ |
||
69 | 1 | public function getArguments(): array |
|
70 | { |
||
71 | return $this->getInput()->getArguments(); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | 1 | * @inheritdoc |
|
76 | */ |
||
77 | 1 | public function hasOption(string $name): bool |
|
78 | { |
||
79 | return $this->getInput()->hasOption($name); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | 1 | * @inheritdoc |
|
84 | */ |
||
85 | 1 | public function getOption(string $name) |
|
86 | { |
||
87 | return $this->getInput()->getOption($name); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | 1 | * @inheritdoc |
|
92 | */ |
||
93 | 1 | public function getOptions(): array |
|
94 | { |
||
95 | return $this->getInput()->getOptions(); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | 3 | * @inheritdoc |
|
100 | */ |
||
101 | 3 | View Code Duplication | public function writeInfo(string $message, int $verbosity = self::VERBOSITY_NORMAL): IoInterface |
0 ignored issues
–
show
|
|||
102 | 3 | { |
|
103 | 3 | $isNewLine = false; |
|
104 | $options = $this->convertVerbosityLevel($verbosity); |
||
105 | 3 | $this->getOutput()->write("<info>$message</info>", $isNewLine, $options); |
|
106 | |||
107 | return $this; |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | 1 | * @inheritdoc |
|
112 | */ |
||
113 | 1 | View Code Duplication | public function writeWarning(string $message, int $verbosity = self::VERBOSITY_NORMAL): IoInterface |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
114 | 1 | { |
|
115 | 1 | $isNewLine = false; |
|
116 | $options = $this->convertVerbosityLevel($verbosity); |
||
117 | 1 | $this->getOutput()->write("<comment>$message</comment>", $isNewLine, $options); |
|
118 | |||
119 | return $this; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | 5 | * @inheritdoc |
|
124 | */ |
||
125 | 5 | View Code Duplication | public function writeError(string $message, int $verbosity = self::VERBOSITY_NORMAL): IoInterface |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
126 | 5 | { |
|
127 | 5 | $isNewLine = false; |
|
128 | $options = $this->convertVerbosityLevel($verbosity); |
||
129 | 5 | $this->getOutput()->write("<error>$message</error>", $isNewLine, $options); |
|
130 | |||
131 | return $this; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | 8 | * @return OutputInterface |
|
136 | */ |
||
137 | 8 | protected function getOutput(): OutputInterface |
|
138 | { |
||
139 | return $this->output; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | 9 | * @return InputInterface |
|
144 | */ |
||
145 | 9 | protected function getInput(): InputInterface |
|
146 | { |
||
147 | return $this->input; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @param int $verbosity |
||
152 | * |
||
153 | 9 | * @return int |
|
154 | */ |
||
155 | protected function convertVerbosityLevel(int $verbosity): int |
||
156 | 9 | { |
|
157 | 1 | switch ($verbosity) { |
|
158 | 1 | case static::VERBOSITY_QUIET: |
|
159 | 9 | $result = OutputInterface::VERBOSITY_QUIET; |
|
160 | 9 | break; |
|
161 | 9 | case static::VERBOSITY_NORMAL: |
|
162 | 3 | $result = OutputInterface::VERBOSITY_NORMAL; |
|
163 | 3 | break; |
|
164 | 3 | case static::VERBOSITY_VERBOSE: |
|
165 | 1 | $result = OutputInterface::VERBOSITY_VERBOSE; |
|
166 | 1 | break; |
|
167 | 1 | case static::VERBOSITY_VERY_VERBOSE: |
|
168 | $result = OutputInterface::VERBOSITY_VERY_VERBOSE; |
||
169 | 1 | break; |
|
170 | 1 | default: |
|
171 | $result = OutputInterface::VERBOSITY_NORMAL; |
||
172 | break; |
||
173 | 9 | } |
|
174 | |||
175 | return $result; |
||
176 | } |
||
177 | } |
||
178 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.