@@ -45,7 +45,7 @@ |
||
45 | 45 | ) |
46 | 46 | ); |
47 | 47 | |
48 | - return array_map(function ($row, $key) use ($style, $length) { |
|
48 | + return array_map(function($row, $key) use ($style, $length) { |
|
49 | 49 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
50 | 50 | |
51 | 51 | if ($key === 0) { |
@@ -79,11 +79,11 @@ |
||
79 | 79 | |
80 | 80 | public function ask() : InputResult |
81 | 81 | { |
82 | - $this->inputIO->registerControlCallback(InputCharacter::UP, function (string $input) { |
|
82 | + $this->inputIO->registerControlCallback(InputCharacter::UP, function(string $input) { |
|
83 | 83 | return $this->validate($input) ? $input + 1 : $input; |
84 | 84 | }); |
85 | 85 | |
86 | - $this->inputIO->registerControlCallback(InputCharacter::DOWN, function (string $input) { |
|
86 | + $this->inputIO->registerControlCallback(InputCharacter::DOWN, function(string $input) { |
|
87 | 87 | return $this->validate($input) ? $input - 1 : $input; |
88 | 88 | }); |
89 | 89 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $this->emptyRow(); |
37 | 37 | |
38 | 38 | $confirmText = sprintf(' < %s > ', $confirmText); |
39 | - $leftFill = ($promptWidth / 2) - (mb_strlen($confirmText) / 2); |
|
39 | + $leftFill = ($promptWidth/2) - (mb_strlen($confirmText)/2); |
|
40 | 40 | |
41 | 41 | $this->write(sprintf( |
42 | 42 | "%s%s%s%s%s%s%s\n", |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | return max( |
100 | 100 | array_map( |
101 | - function (string $line) { |
|
101 | + function(string $line) { |
|
102 | 102 | return mb_strlen($line); |
103 | 103 | }, |
104 | 104 | $lines |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | { |
111 | 111 | $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty |
112 | 112 | |
113 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
113 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | private function calculateYPositionWithError() : int |
117 | 117 | { |
118 | 118 | $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty |
119 | 119 | |
120 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
120 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | private function calculateXPosition(Input $input, string $userInput) : int |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | ); |
132 | 132 | |
133 | 133 | $parentStyle = $this->parentMenu->getStyle(); |
134 | - $halfWidth = ($width + ($input->getStyle()->getPaddingLeftRight() * 2)) / 2; |
|
135 | - $parentHalfWidth = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin()); |
|
134 | + $halfWidth = ($width + ($input->getStyle()->getPaddingLeftRight()*2))/2; |
|
135 | + $parentHalfWidth = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin()); |
|
136 | 136 | |
137 | 137 | return $parentHalfWidth - $halfWidth; |
138 | 138 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | ); |
165 | 165 | |
166 | 166 | $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text)); |
167 | - $leftFill = ($width / 2) - ($textLength / 2); |
|
167 | + $leftFill = ($width/2) - ($textLength/2); |
|
168 | 168 | $rightFill = ceil($width - $leftFill - $textLength); |
169 | 169 | |
170 | 170 | $this->drawLine( |
@@ -69,12 +69,12 @@ |
||
69 | 69 | { |
70 | 70 | //y |
71 | 71 | $textLines = count(explode("\n", $this->text)) + 2; |
72 | - $this->y = ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($textLines / 2) + 1; |
|
72 | + $this->y = ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($textLines/2) + 1; |
|
73 | 73 | |
74 | 74 | //x |
75 | 75 | $parentStyle = $this->parentMenu->getStyle(); |
76 | - $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight() * 2)) / 2; |
|
77 | - $widthHalfLength = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin()); |
|
76 | + $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight()*2))/2; |
|
77 | + $widthHalfLength = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin()); |
|
78 | 78 | $this->x = $widthHalfLength - $dialogueHalfLength; |
79 | 79 | } |
80 | 80 |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | protected function calculateContentWidth() : void |
314 | 314 | { |
315 | 315 | $this->contentWidth = $this->width |
316 | - - ($this->paddingLeftRight * 2) |
|
316 | + - ($this->paddingLeftRight*2) |
|
317 | 317 | - ($this->borderRightWidth + $this->borderLeftWidth); |
318 | 318 | |
319 | 319 | if ($this->contentWidth < 0) { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | public function setMarginAuto() : self |
467 | 467 | { |
468 | 468 | $this->marginAuto = true; |
469 | - $this->margin = floor(($this->terminal->getWidth() - $this->width) / 2); |
|
469 | + $this->margin = floor(($this->terminal->getWidth() - $this->width)/2); |
|
470 | 470 | |
471 | 471 | $this->generateBorderRows(); |
472 | 472 | $this->generatePaddingTopBottomRows(); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | : $this->selectedItem++; |
286 | 286 | |
287 | 287 | if (!array_key_exists($this->selectedItem, $this->items)) { |
288 | - $this->selectedItem = $direction === 'UP' |
|
288 | + $this->selectedItem = $direction === 'UP' |
|
289 | 289 | ? end($itemKeys) |
290 | 290 | : reset($itemKeys); |
291 | 291 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
388 | 388 | } |
389 | 389 | |
390 | - array_map(function ($item, $index) use ($frame) { |
|
390 | + array_map(function($item, $index) use ($frame) { |
|
391 | 391 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
392 | 392 | }, $this->items, array_keys($this->items)); |
393 | 393 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $borderColour = ''; |
439 | 439 | } |
440 | 440 | |
441 | - return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
441 | + return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
442 | 442 | return sprintf( |
443 | 443 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
444 | 444 | str_repeat(' ', $this->style->getMargin()), |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | Assertion::inArray($position, [self::POSITION_CENTER, self::POSITION_RIGHT, self::POSITION_LEFT]); |
43 | 43 | |
44 | 44 | $this->setText($text); |
45 | - $this->position = $position; |
|
45 | + $this->position = $position; |
|
46 | 46 | $this->alternateText = $alt; |
47 | 47 | } |
48 | 48 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $padding = $style->getContentWidth() - $this->artLength; |
60 | 60 | |
61 | - return array_map(function ($row) use ($padding) { |
|
61 | + return array_map(function($row) use ($padding) { |
|
62 | 62 | switch ($this->position) { |
63 | 63 | case self::POSITION_LEFT: |
64 | 64 | break; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | break; |
68 | 68 | case self::POSITION_CENTER: |
69 | 69 | default: |
70 | - $left = ceil($padding / 2); |
|
70 | + $left = ceil($padding/2); |
|
71 | 71 | $row = sprintf('%s%s', str_repeat(' ', $left), $row); |
72 | 72 | break; |
73 | 73 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function setText(string $text) : void |
107 | 107 | { |
108 | - $this->text = implode("\n", array_map(function (string $line) { |
|
108 | + $this->text = implode("\n", array_map(function(string $line) { |
|
109 | 109 | return rtrim($line, ' '); |
110 | 110 | }, explode("\n", $text))); |
111 | 111 |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | $length = $style->getDisplaysExtra() |
118 | - ? floor($style->getContentWidth() / $numberOfItems) - (mb_strlen($style->getItemExtra()) + 2) |
|
119 | - : floor($style->getContentWidth() / $numberOfItems); |
|
118 | + ? floor($style->getContentWidth()/$numberOfItems) - (mb_strlen($style->getItemExtra()) + 2) |
|
119 | + : floor($style->getContentWidth()/$numberOfItems); |
|
120 | 120 | |
121 | 121 | $length -= $this->gutter; |
122 | 122 | |
123 | - $missingLength = $style->getContentWidth() % $numberOfItems; |
|
123 | + $missingLength = $style->getContentWidth()%$numberOfItems; |
|
124 | 124 | |
125 | 125 | return $this->buildRows( |
126 | - array_map(function ($index, $item) use ($selected, $length, $style) { |
|
126 | + array_map(function($index, $item) use ($selected, $length, $style) { |
|
127 | 127 | $isSelected = $selected && $index === $this->selectedItemIndex; |
128 | 128 | $marker = $item->canSelect() |
129 | 129 | ? sprintf('%s', $style->getMarker($isSelected)) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $extraPadLength = $style->getDisplaysExtra() ? 2 + mb_strlen($style->getItemExtra()) : 0; |
156 | 156 | |
157 | 157 | return array_map( |
158 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
158 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
159 | 159 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
160 | 160 | }, |
161 | 161 | range(0, max(array_map('count', $cells)) - 1) |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | implode( |
170 | 170 | '', |
171 | 171 | array_map( |
172 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
172 | + function($cell) use ($index, $length, $extraPadLength) { |
|
173 | 173 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
174 | 174 | }, |
175 | 175 | $cells |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | bool $isSelected, |
187 | 187 | string $itemExtra |
188 | 188 | ) : array { |
189 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
189 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
190 | 190 | $invertedColoursSetCode = $isSelected |
191 | 191 | ? $style->getInvertedColoursSetCode() |
192 | 192 | : ''; |