@@ -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 | |
@@ -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; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function addSubMenu(string $id, CliMenuBuilder $subMenuBuilder = null) : CliMenuBuilder |
| 154 | 154 | { |
| 155 | - $this->menuItems[] = $id; |
|
| 155 | + $this->menuItems[] = $id; |
|
| 156 | 156 | |
| 157 | 157 | if (null === $subMenuBuilder) { |
| 158 | 158 | $this->subMenuBuilders[$id] = new static($this); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | private function itemsHaveExtra(array $items) : bool |
| 296 | 296 | { |
| 297 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
| 297 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
| 298 | 298 | return $item->showsItemExtra(); |
| 299 | 299 | })); |
| 300 | 300 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | private function buildSubMenus(array $items) : array |
| 361 | 361 | { |
| 362 | - return array_map(function ($item) { |
|
| 362 | + return array_map(function($item) { |
|
| 363 | 363 | if (!is_string($item)) { |
| 364 | 364 | return $item; |
| 365 | 365 | } |
@@ -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 | -$exit = function (CliMenu $menu) { |
|
| 8 | +$exit = function(CliMenu $menu) { |
|
| 9 | 9 | $menu->close(); |
| 10 | 10 | }; |
| 11 | 11 | |
@@ -3,9 +3,9 @@ discard block |
||
| 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 | echo $menu->getSelectedItem()->getText(); |
| 10 | 10 | }; |
| 11 | 11 | |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | ->addLineBreak('-') |
| 17 | 17 | ->addSubMenu('Options') |
| 18 | 18 | ->setTitle('CLI Menu > Options') |
| 19 | - ->addItem('First option', function (CliMenu $menu) { |
|
| 19 | + ->addItem('First option', function(CliMenu $menu) { |
|
| 20 | 20 | echo sprintf('Executing option: %s', $menu->getSelectedItem()->getText()); |
| 21 | 21 | }) |
| 22 | 22 | ->addSubMenu('Secret Options') |
| 23 | 23 | ->setTitle('CLI Menu > Options > Secret Options') |
| 24 | - ->addItem('First secret option', function (CliMenu $menu) { |
|
| 24 | + ->addItem('First secret option', function(CliMenu $menu) { |
|
| 25 | 25 | echo sprintf('Executing secret option: %s', $menu->getSelectedItem()->getText()); |
| 26 | 26 | }) |
| 27 | 27 | ->addLineBreak('-') |
@@ -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", |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | Assertion::inArray($position, [self::POSITION_CENTER, self::POSITION_RIGHT, self::POSITION_LEFT]); |
| 43 | 43 | |
| 44 | - $this->text = implode("\n", array_map(function (string $line) { |
|
| 44 | + $this->text = implode("\n", array_map(function(string $line) { |
|
| 45 | 45 | return rtrim($line, ' '); |
| 46 | 46 | }, explode("\n", $text))); |
| 47 | 47 | $this->position = $position; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $padding = $style->getContentWidth() - $this->artLength; |
| 63 | 63 | |
| 64 | - return array_map(function ($row) use ($padding) { |
|
| 64 | + return array_map(function($row) use ($padding) { |
|
| 65 | 65 | switch ($this->position) { |
| 66 | 66 | case self::POSITION_LEFT: |
| 67 | 67 | break; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | break; |
| 71 | 71 | case self::POSITION_CENTER: |
| 72 | 72 | default: |
| 73 | - $left = ceil($padding / 2); |
|
| 73 | + $left = ceil($padding/2); |
|
| 74 | 74 | $row = sprintf('%s%s', str_repeat(' ', $left), $row); |
| 75 | 75 | break; |
| 76 | 76 | } |
@@ -3,16 +3,16 @@ |
||
| 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 | echo $menu->getSelectedItem()->getText(); |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | $menu = (new CliMenuBuilder) |
| 13 | 13 | ->setTitle('Basic CLI Menu') |
| 14 | 14 | ->addItem('First Item', $itemCallable) |
| 15 | - ->addItem('Make menu wider', function (CliMenu $menu) { |
|
| 15 | + ->addItem('Make menu wider', function(CliMenu $menu) { |
|
| 16 | 16 | $menu->getStyle()->setWidth($menu->getStyle()->getWidth() + 10); |
| 17 | 17 | $menu->redraw(); |
| 18 | 18 | }) |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | : $this->selectedItem++; |
| 280 | 280 | |
| 281 | 281 | if (!array_key_exists($this->selectedItem, $this->items)) { |
| 282 | - $this->selectedItem = $direction === 'UP' |
|
| 282 | + $this->selectedItem = $direction === 'UP' |
|
| 283 | 283 | ? end($itemKeys) |
| 284 | 284 | : reset($itemKeys); |
| 285 | 285 | } elseif ($this->getSelectedItem()->canSelect()) { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - array_map(function ($item, $index) use ($frame) { |
|
| 352 | + array_map(function($item, $index) use ($frame) { |
|
| 353 | 353 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
| 354 | 354 | }, $this->items, array_keys($this->items)); |
| 355 | 355 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | $borderColour = ''; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
| 396 | + return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
| 397 | 397 | return sprintf( |
| 398 | 398 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 399 | 399 | str_repeat(' ', $this->style->getMargin()), |