Conditions | 1 |
Paths | 1 |
Total Lines | 3 |
Code Lines | 1 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 1 |
Changes | 0 |
Metric | Value |
---|---|
dl | 0 |
loc | 3 |
ccs | 2 |
cts | 2 |
cp | 1 |
rs | 10 |
c | 0 |
b | 0 |
f | 0 |
cc | 1 |
eloc | 1 |
nc | 1 |
nop | 0 |
crap | 1 |
1 | <?php |
||||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||||
2 | namespace EddIriarte\Console\Handlers; |
||||||
0 ignored issues
–
show
|
|||||||
3 | |||||||
4 | use Symfony\Component\Console\Output\OutputInterface; |
||||||
5 | use Symfony\Component\Console\Terminal; |
||||||
6 | use EddIriarte\Console\Inputs\Interfaces\SelectInput; |
||||||
7 | |||||||
8 | /** |
||||||
9 | * Class SelectHandler |
||||||
10 | * @package Lazzier\Helpers |
||||||
0 ignored issues
–
show
|
|||||||
11 | * @author Eduardo Iriarte <eddiriarte[at]gmail[dot]com> |
||||||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||||||
12 | */ |
||||||
0 ignored issues
–
show
|
|||||||
13 | class SelectHandler |
||||||
14 | { |
||||||
0 ignored issues
–
show
|
|||||||
15 | /** |
||||||
0 ignored issues
–
show
|
|||||||
16 | * @var resource |
||||||
17 | */ |
||||||
18 | protected $stream; |
||||||
0 ignored issues
–
show
|
|||||||
19 | |||||||
20 | /** |
||||||
0 ignored issues
–
show
|
|||||||
21 | * @var OutputInterface |
||||||
22 | */ |
||||||
23 | protected $output; |
||||||
0 ignored issues
–
show
|
|||||||
24 | |||||||
25 | /** |
||||||
0 ignored issues
–
show
|
|||||||
26 | * @var SelectInput |
||||||
27 | */ |
||||||
28 | protected $question; |
||||||
0 ignored issues
–
show
|
|||||||
29 | |||||||
30 | /** |
||||||
0 ignored issues
–
show
|
|||||||
31 | * @var int |
||||||
0 ignored issues
–
show
|
|||||||
32 | */ |
||||||
33 | protected $row; |
||||||
0 ignored issues
–
show
|
|||||||
34 | |||||||
35 | /** |
||||||
0 ignored issues
–
show
|
|||||||
36 | * @var int |
||||||
0 ignored issues
–
show
|
|||||||
37 | */ |
||||||
38 | protected $column; |
||||||
0 ignored issues
–
show
|
|||||||
39 | |||||||
40 | /** |
||||||
0 ignored issues
–
show
|
|||||||
41 | * @var bool |
||||||
0 ignored issues
–
show
|
|||||||
42 | */ |
||||||
43 | protected $firstRun; |
||||||
0 ignored issues
–
show
|
|||||||
44 | |||||||
45 | /** |
||||||
0 ignored issues
–
show
|
|||||||
46 | * @var int |
||||||
0 ignored issues
–
show
|
|||||||
47 | */ |
||||||
48 | protected $terminalWidth; |
||||||
0 ignored issues
–
show
|
|||||||
49 | |||||||
50 | /** |
||||||
0 ignored issues
–
show
|
|||||||
51 | * SelectStreamHandler constructor. |
||||||
52 | * @param SelectInput $question |
||||||
0 ignored issues
–
show
|
|||||||
53 | * @param OutputInterface $output |
||||||
0 ignored issues
–
show
|
|||||||
54 | * @param $stream |
||||||
0 ignored issues
–
show
|
|||||||
55 | */ |
||||||
56 | 7 | public function __construct(SelectInput $question, OutputInterface $output, $stream) |
|||||
0 ignored issues
–
show
|
|||||||
57 | { |
||||||
0 ignored issues
–
show
|
|||||||
58 | 7 | $this->row = 0; |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
59 | 7 | $this->column = 0; |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
60 | 7 | $this->question = $question; |
|||||
61 | 7 | $this->output = $output; |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
62 | 7 | $this->stream = $stream; |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
63 | 7 | } |
|||||
0 ignored issues
–
show
|
|||||||
64 | |||||||
65 | /** |
||||||
66 | * Navigates through option items. |
||||||
67 | * |
||||||
68 | * @return array |
||||||
69 | */ |
||||||
70 | 6 | public function handle(): array |
|||||
71 | { |
||||||
0 ignored issues
–
show
|
|||||||
72 | 6 | $this->firstRun = true; |
|||||
0 ignored issues
–
show
|
|||||||
73 | 6 | $this->output->writeln( |
|||||
74 | 6 | '<info>' . $this->question->getMessage() . '</info> [<comment>SPACE=select</>, <comment>ENTER=submit</>]' |
|||||
0 ignored issues
–
show
|
|||||||
75 | ); |
||||||
76 | 6 | $this->repaint(); |
|||||
77 | |||||||
78 | 6 | $sttyMode = shell_exec('stty -g'); |
|||||
79 | |||||||
80 | // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) |
||||||
0 ignored issues
–
show
|
|||||||
81 | 6 | shell_exec('stty -icanon -echo'); |
|||||
82 | |||||||
83 | // Read a keypress |
||||||
0 ignored issues
–
show
|
|||||||
84 | 6 | while (!feof($this->stream)) { |
|||||
0 ignored issues
–
show
|
|||||||
85 | 6 | $char = fread($this->stream, 1); |
|||||
86 | 6 | if (" " === $char) { |
|||||
0 ignored issues
–
show
The string literal
does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||||||
87 | 6 | $this->tryCellSelection(); |
|||||
88 | 6 | } elseif ("\033" === $char) { |
|||||
0 ignored issues
–
show
|
|||||||
89 | 6 | $this->tryCellNavigation($char); |
|||||
90 | 6 | } elseif (10 === ord($char)) { |
|||||
0 ignored issues
–
show
|
|||||||
91 | //TODO handle valid state... |
||||||
0 ignored issues
–
show
|
|||||||
92 | 3 | $this->clear(); |
|||||
93 | 3 | $this->output->write('> ' . join(', ', $this->question->getSelections())); |
|||||
0 ignored issues
–
show
|
|||||||
94 | 3 | $this->output->write($char); |
|||||
95 | 3 | break; |
|||||
96 | } |
||||||
97 | 6 | $this->repaint(); |
|||||
98 | } |
||||||
99 | |||||||
100 | // Reset stty so it behaves normally again |
||||||
0 ignored issues
–
show
|
|||||||
101 | 6 | shell_exec(sprintf('stty %s', $sttyMode)); |
|||||
102 | |||||||
103 | 6 | $this->output->writeln(' '); |
|||||
104 | |||||||
105 | 6 | return $this->question->getSelections(); |
|||||
106 | } |
||||||
0 ignored issues
–
show
|
|||||||
107 | |||||||
108 | /** |
||||||
0 ignored issues
–
show
|
|||||||
109 | * @param $row |
||||||
0 ignored issues
–
show
|
|||||||
110 | * @param $column |
||||||
0 ignored issues
–
show
|
|||||||
111 | * @return bool |
||||||
0 ignored issues
–
show
|
|||||||
112 | */ |
||||||
113 | 11 | public function exists($row, $column): bool |
|||||
0 ignored issues
–
show
|
|||||||
114 | { |
||||||
0 ignored issues
–
show
|
|||||||
115 | 11 | return $this->question->hasEntryAt($row, $column); |
|||||
0 ignored issues
–
show
The method
hasEntryAt() does not exist on EddIriarte\Console\Inputs\Interfaces\SelectInput . Since it exists in all sub-types, consider adding an abstract or default implementation to EddIriarte\Console\Inputs\Interfaces\SelectInput .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
116 | } |
||||||
0 ignored issues
–
show
|
|||||||
117 | |||||||
118 | /** |
||||||
0 ignored issues
–
show
|
|||||||
119 | * |
||||||
120 | */ |
||||||
0 ignored issues
–
show
|
|||||||
121 | 1 | protected function up(): void |
|||||
122 | { |
||||||
0 ignored issues
–
show
|
|||||||
123 | 1 | if ($this->exists($this->row - 1, $this->column)) { |
|||||
0 ignored issues
–
show
|
|||||||
124 | 1 | $this->row -= 1; |
|||||
125 | } |
||||||
126 | 1 | } |
|||||
0 ignored issues
–
show
|
|||||||
127 | |||||||
128 | /** |
||||||
0 ignored issues
–
show
|
|||||||
129 | * |
||||||
130 | */ |
||||||
0 ignored issues
–
show
|
|||||||
131 | 2 | protected function down(): void |
|||||
132 | { |
||||||
0 ignored issues
–
show
|
|||||||
133 | 2 | if ($this->exists($this->row + 1, $this->column)) { |
|||||
0 ignored issues
–
show
|
|||||||
134 | 2 | $this->row += 1; |
|||||
135 | } |
||||||
136 | 2 | } |
|||||
0 ignored issues
–
show
|
|||||||
137 | |||||||
138 | /** |
||||||
0 ignored issues
–
show
|
|||||||
139 | * |
||||||
140 | */ |
||||||
0 ignored issues
–
show
|
|||||||
141 | 3 | protected function left(): void |
|||||
142 | { |
||||||
0 ignored issues
–
show
|
|||||||
143 | 3 | if ($this->exists($this->row, $this->column - 1)) { |
|||||
0 ignored issues
–
show
|
|||||||
144 | 3 | $this->column -= 1; |
|||||
145 | } |
||||||
146 | 3 | } |
|||||
0 ignored issues
–
show
|
|||||||
147 | |||||||
148 | /** |
||||||
0 ignored issues
–
show
|
|||||||
149 | * |
||||||
150 | */ |
||||||
0 ignored issues
–
show
|
|||||||
151 | 5 | protected function right(): void |
|||||
152 | { |
||||||
0 ignored issues
–
show
|
|||||||
153 | 5 | if ($this->exists($this->row, $this->column + 1)) { |
|||||
0 ignored issues
–
show
|
|||||||
154 | 5 | $this->column += 1; |
|||||
155 | } |
||||||
156 | 5 | } |
|||||
0 ignored issues
–
show
|
|||||||
157 | |||||||
158 | /** |
||||||
0 ignored issues
–
show
|
|||||||
159 | * |
||||||
160 | */ |
||||||
0 ignored issues
–
show
|
|||||||
161 | 6 | protected function tryCellSelection(): void |
|||||
162 | { |
||||||
0 ignored issues
–
show
|
|||||||
163 | // Try to select cell. |
||||||
164 | 6 | if ($this->exists($this->row, $this->column)) { |
|||||
165 | 6 | $option = $this->question->getEntryAt($this->row, $this->column); |
|||||
0 ignored issues
–
show
The method
getEntryAt() does not exist on EddIriarte\Console\Inputs\Interfaces\SelectInput . Since it exists in all sub-types, consider adding an abstract or default implementation to EddIriarte\Console\Inputs\Interfaces\SelectInput .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
166 | 6 | $this->question->select($option); |
|||||
167 | } |
||||||
168 | 6 | } |
|||||
0 ignored issues
–
show
|
|||||||
169 | |||||||
170 | /** |
||||||
0 ignored issues
–
show
|
|||||||
171 | * @param $char |
||||||
0 ignored issues
–
show
|
|||||||
172 | */ |
||||||
0 ignored issues
–
show
|
|||||||
173 | 6 | protected function tryCellNavigation($char): void |
|||||
0 ignored issues
–
show
|
|||||||
174 | { |
||||||
0 ignored issues
–
show
|
|||||||
175 | // Did we read an escape sequence? |
||||||
176 | 6 | $char .= fread($this->stream, 2); |
|||||
177 | 6 | if (empty($char[2]) || !in_array($char[2], ['A', 'B', 'C', 'D'])) { |
|||||
0 ignored issues
–
show
|
|||||||
178 | // Input stream was not an arrow key. |
||||||
179 | return; |
||||||
180 | } |
||||||
181 | |||||||
182 | 6 | switch ($char[2]) { |
|||||
0 ignored issues
–
show
|
|||||||
183 | 6 | case 'A': // go up! |
|||||
0 ignored issues
–
show
|
|||||||
184 | 1 | $this->up(); |
|||||
185 | 1 | break; |
|||||
0 ignored issues
–
show
|
|||||||
186 | 6 | case 'B': // go down! |
|||||
0 ignored issues
–
show
|
|||||||
187 | 2 | $this->down(); |
|||||
188 | 2 | break; |
|||||
0 ignored issues
–
show
|
|||||||
189 | 5 | case 'C': // go right! |
|||||
0 ignored issues
–
show
|
|||||||
190 | 5 | $this->right(); |
|||||
191 | 5 | break; |
|||||
0 ignored issues
–
show
|
|||||||
192 | 3 | case 'D': // go left! |
|||||
0 ignored issues
–
show
|
|||||||
193 | 3 | $this->left(); |
|||||
194 | 3 | break; |
|||||
0 ignored issues
–
show
|
|||||||
195 | } |
||||||
196 | 6 | } |
|||||
0 ignored issues
–
show
|
|||||||
197 | |||||||
198 | /** |
||||||
0 ignored issues
–
show
|
|||||||
199 | * |
||||||
200 | */ |
||||||
0 ignored issues
–
show
|
|||||||
201 | 7 | public function repaint(): void |
|||||
202 | { |
||||||
0 ignored issues
–
show
|
|||||||
203 | 7 | $message = $this->message(); |
|||||
204 | 7 | if (!$this->firstRun) { |
|||||
0 ignored issues
–
show
|
|||||||
205 | 7 | $this->clear(); |
|||||
206 | } |
||||||
207 | |||||||
208 | 7 | $this->firstRun = false; |
|||||
0 ignored issues
–
show
|
|||||||
209 | 7 | $this->output->write($message); |
|||||
210 | 7 | } |
|||||
0 ignored issues
–
show
|
|||||||
211 | |||||||
212 | /** |
||||||
0 ignored issues
–
show
|
|||||||
213 | * |
||||||
214 | */ |
||||||
0 ignored issues
–
show
|
|||||||
215 | 7 | public function clear(): void |
|||||
216 | { |
||||||
0 ignored issues
–
show
|
|||||||
217 | // Move the cursor to the beginning of the line |
||||||
0 ignored issues
–
show
|
|||||||
218 | 7 | $this->output->write("\x0D"); |
|||||
219 | // Erase the line |
||||||
0 ignored issues
–
show
|
|||||||
220 | 7 | $this->output->write("\x1B[2K"); |
|||||
221 | // Erase previous lines |
||||||
0 ignored issues
–
show
|
|||||||
222 | 7 | $lines = $this->question->getChunksCount() - 1; |
|||||
0 ignored issues
–
show
The method
getChunksCount() does not exist on EddIriarte\Console\Inputs\Interfaces\SelectInput . Since it exists in all sub-types, consider adding an abstract or default implementation to EddIriarte\Console\Inputs\Interfaces\SelectInput .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
223 | 7 | if ($lines > 0) { |
|||||
224 | 2 | $this->output->write(str_repeat("\x1B[1A\x1B[2K", $lines)); |
|||||
225 | } |
||||||
226 | 7 | } |
|||||
0 ignored issues
–
show
|
|||||||
227 | |||||||
228 | /** |
||||||
0 ignored issues
–
show
|
|||||||
229 | * @return string |
||||||
230 | */ |
||||||
231 | 7 | protected function message(): string |
|||||
232 | { |
||||||
0 ignored issues
–
show
|
|||||||
233 | 7 | $chunkSize = $this->chunkSize(); |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
234 | 7 | $chunks = $this->question->getChunks($chunkSize); |
|||||
0 ignored issues
–
show
The method
getChunks() does not exist on EddIriarte\Console\Inputs\Interfaces\SelectInput . Since it exists in all sub-types, consider adding an abstract or default implementation to EddIriarte\Console\Inputs\Interfaces\SelectInput .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
235 | 7 | $columnSpace = floor(($this->terminalWidth() - ($chunkSize * 5)) / $chunkSize); |
|||||
236 | 7 | return join(PHP_EOL, array_map(function ($entries) use ($chunks, $columnSpace) { |
|||||
0 ignored issues
–
show
|
|||||||
237 | 7 | $hasCursor = (bool) ($this->row === array_search($entries, $chunks)); |
|||||
0 ignored issues
–
show
|
|||||||
238 | 7 | return $this->makeRow($entries, ($hasCursor ? $this->column : -10), $columnSpace); |
|||||
0 ignored issues
–
show
$columnSpace of type double is incompatible with the type integer expected by parameter $columnSpace of EddIriarte\Console\Handl...electHandler::makeRow() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
239 | 7 | }, $chunks)); |
|||||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||||||
240 | } |
||||||
0 ignored issues
–
show
|
|||||||
241 | |||||||
242 | /** |
||||||
0 ignored issues
–
show
|
|||||||
243 | * @param array $entries |
||||||
0 ignored issues
–
show
|
|||||||
244 | * @param int $activeColumn |
||||||
0 ignored issues
–
show
|
|||||||
245 | * @return mixed |
||||||
246 | */ |
||||||
247 | protected function makeRow(array $entries, int $activeColumn, int $columnSpace) |
||||||
248 | { |
||||||
0 ignored issues
–
show
|
|||||||
249 | 7 | return array_reduce($entries, function ($carry, $item) use ($entries, $activeColumn, $columnSpace) { |
|||||
0 ignored issues
–
show
|
|||||||
250 | 7 | $isActive = ($activeColumn === array_search($item, $entries)); |
|||||
0 ignored issues
–
show
|
|||||||
251 | 7 | return $carry . $this->makeCell($item, $isActive, $columnSpace); |
|||||
0 ignored issues
–
show
|
|||||||
252 | 7 | }, ''); |
|||||
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
![]() |
|||||||
253 | } |
||||||
0 ignored issues
–
show
|
|||||||
254 | |||||||
255 | /** |
||||||
0 ignored issues
–
show
|
|||||||
256 | * @param string $option |
||||||
0 ignored issues
–
show
|
|||||||
257 | * @param bool $hasCursor |
||||||
0 ignored issues
–
show
|
|||||||
258 | * @param int $maxWidth |
||||||
0 ignored issues
–
show
|
|||||||
259 | * @return string |
||||||
260 | */ |
||||||
261 | 7 | protected function makeCell(string $option, bool $hasCursor = false, int $maxWidth = 20): string |
|||||
0 ignored issues
–
show
|
|||||||
262 | { |
||||||
0 ignored issues
–
show
|
|||||||
263 | 7 | $selected = $this->question->isSelected($option); |
|||||
264 | 7 | $name = substr($option, 0, ($maxWidth - 1)); |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
265 | |||||||
266 | 7 | return sprintf( |
|||||
267 | 7 | $hasCursor ? ' <hl> %1$s %2$s </hl>' : ' <%3$s> %1$s %2$s </%3$s>', |
|||||
0 ignored issues
–
show
|
|||||||
268 | 7 | ($selected ? '●' : '○'), |
|||||
0 ignored issues
–
show
|
|||||||
269 | 7 | $name . str_repeat(' ', $maxWidth - mb_strlen($name)), |
|||||
0 ignored issues
–
show
|
|||||||
270 | 7 | ($selected ? 'info' : 'comment') |
|||||
0 ignored issues
–
show
|
|||||||
271 | ); |
||||||
272 | } |
||||||
0 ignored issues
–
show
|
|||||||
273 | |||||||
274 | 7 | public function terminalWidth() |
|||||
0 ignored issues
–
show
|
|||||||
275 | { |
||||||
0 ignored issues
–
show
|
|||||||
276 | 7 | return (new Terminal)->getWidth(); |
|||||
277 | } |
||||||
0 ignored issues
–
show
|
|||||||
278 | |||||||
279 | 7 | public function chunkSize() |
|||||
0 ignored issues
–
show
|
|||||||
280 | { |
||||||
0 ignored issues
–
show
|
|||||||
281 | 7 | $max = $this->terminalWidth(); |
|||||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||||||
282 | 7 | $largest = array_reduce($this->question->getOptions(), 'max', 0); |
|||||
283 | |||||||
284 | 7 | if ($largest > ($max / 2)) { |
|||||
285 | return 1; |
||||||
286 | 7 | } elseif ($largest > ($max / 3)) { |
|||||
0 ignored issues
–
show
|
|||||||
287 | return 2; |
||||||
288 | } else { |
||||||
289 | 7 | return 3; |
|||||
290 | } |
||||||
291 | } |
||||||
0 ignored issues
–
show
|
|||||||
292 | } |
||||||
0 ignored issues
–
show
|
|||||||
293 |