@@ -3,9 +3,9 @@ |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | $result = $menu->askText() |
10 | 10 | ->setPlaceholderText('Enter something here') |
11 | 11 | ->ask(); |
@@ -3,9 +3,9 @@ |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | $result = $menu->askNumber() |
10 | 10 | ->setPlaceholderText(10) |
11 | 11 | ->ask(); |
@@ -3,9 +3,9 @@ |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | $username = $menu->askText() |
10 | 10 | ->setPromptText('Enter username') |
11 | 11 | ->setPlaceholderText('alice') |
@@ -2,8 +2,6 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace PhpSchool\CliMenu; |
4 | 4 | |
5 | -use PhpSchool\CliMenu\Dialogue\NumberInput; |
|
6 | -use PhpSchool\CliMenu\Exception\InvalidInstantiationException; |
|
7 | 5 | use PhpSchool\CliMenu\Exception\InvalidTerminalException; |
8 | 6 | use PhpSchool\CliMenu\Exception\MenuNotOpenException; |
9 | 7 | use PhpSchool\CliMenu\Input\InputIO; |
@@ -17,11 +15,9 @@ discard block |
||
17 | 15 | use PhpSchool\CliMenu\Dialogue\Flash; |
18 | 16 | use PhpSchool\CliMenu\Terminal\TerminalFactory; |
19 | 17 | use PhpSchool\CliMenu\Util\StringUtil as s; |
20 | -use PhpSchool\Terminal\Exception\NotInteractiveTerminal; |
|
21 | 18 | use PhpSchool\Terminal\InputCharacter; |
22 | 19 | use PhpSchool\Terminal\NonCanonicalReader; |
23 | 20 | use PhpSchool\Terminal\Terminal; |
24 | -use PhpSchool\Terminal\TerminalReader; |
|
25 | 21 | |
26 | 22 | /** |
27 | 23 | * @author Michael Woodward <[email protected]> |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | : $this->selectedItem++; |
205 | 205 | |
206 | 206 | if (!array_key_exists($this->selectedItem, $this->items)) { |
207 | - $this->selectedItem = $direction === 'UP' |
|
207 | + $this->selectedItem = $direction === 'UP' |
|
208 | 208 | ? end($itemKeys) |
209 | 209 | : reset($itemKeys); |
210 | 210 | } elseif ($this->getSelectedItem()->canSelect()) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
266 | 266 | } |
267 | 267 | |
268 | - array_map(function ($item, $index) use ($frame) { |
|
268 | + array_map(function($item, $index) use ($frame) { |
|
269 | 269 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
270 | 270 | }, $this->items, array_keys($this->items)); |
271 | 271 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | ? $this->style->getSelectedUnsetCode() |
296 | 296 | : $this->style->getUnselectedUnsetCode(); |
297 | 297 | |
298 | - return array_map(function ($row) use ($setColour, $unsetColour) { |
|
298 | + return array_map(function($row) use ($setColour, $unsetColour) { |
|
299 | 299 | return sprintf( |
300 | 300 | "%s%s%s%s%s%s%s\n", |
301 | 301 | str_repeat(' ', $this->style->getMargin()), |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace PhpSchool\CliMenu; |
4 | 4 | |
5 | -use PhpSchool\CliMenu\Exception\InvalidInstantiationException; |
|
6 | 5 | use PhpSchool\CliMenu\Terminal\TerminalFactory; |
7 | 6 | use PhpSchool\Terminal\Terminal; |
8 | 7 |
@@ -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 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | return max( |
98 | 98 | array_map( |
99 | - function (string $line) { |
|
99 | + function(string $line) { |
|
100 | 100 | return mb_strlen($line); |
101 | 101 | }, |
102 | 102 | $lines |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | { |
109 | 109 | $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty |
110 | 110 | |
111 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
111 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | private function calculateYPositionWithError() : int |
115 | 115 | { |
116 | 116 | $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty |
117 | 117 | |
118 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
118 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | private function calculateXPosition(Input $input, string $userInput) : int |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | ); |
130 | 130 | |
131 | 131 | $parentStyle = $this->parentMenu->getStyle(); |
132 | - $halfWidth = ($width + ($input->getStyle()->getPadding() * 2)) / 2; |
|
133 | - $parentHalfWidth = ceil($parentStyle->getWidth() / 2); |
|
132 | + $halfWidth = ($width + ($input->getStyle()->getPadding()*2))/2; |
|
133 | + $parentHalfWidth = ceil($parentStyle->getWidth()/2); |
|
134 | 134 | |
135 | 135 | return $parentHalfWidth - $halfWidth; |
136 | 136 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | ); |
163 | 163 | |
164 | 164 | $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text)); |
165 | - $leftFill = ($width / 2) - ($textLength / 2); |
|
165 | + $leftFill = ($width/2) - ($textLength/2); |
|
166 | 166 | $rightFill = ceil($width - $leftFill - $textLength); |
167 | 167 | |
168 | 168 | $this->drawLine( |
@@ -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%s%s\n", |
@@ -3,12 +3,12 @@ |
||
3 | 3 | use PhpSchool\CliMenu\CliMenu; |
4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
5 | 5 | |
6 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
6 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
7 | 7 | |
8 | -$itemCallable = function (CliMenu $menu) { |
|
8 | +$itemCallable = function(CliMenu $menu) { |
|
9 | 9 | $result = $menu->askPassword() |
10 | 10 | ->setPlaceholderText('') |
11 | - ->setValidator(function ($password) { |
|
11 | + ->setValidator(function($password) { |
|
12 | 12 | if ($password === 'password') { |
13 | 13 | $this->setValidationFailedText('Password is too weak'); |
14 | 14 | return false; |