@@ -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 | $flash = $menu->flash("PHP School FTW!!"); |
| 10 | 10 | $flash->getStyle()->setBg('green'); |
| 11 | 11 | $flash->display(); |
@@ -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 | echo $menu->getSelectedItem()->getText(); |
| 10 | 10 | }; |
| 11 | 11 | |
@@ -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 | echo $menu->getSelectedItem()->getText(); |
| 10 | 10 | }; |
| 11 | 11 | |
@@ -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 | $menu->confirm('PHP School FTW!') |
| 10 | 10 | ->display('OK'); |
| 11 | 11 | }; |
@@ -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 | echo $menu->getSelectedItem()->getText(); |
| 10 | 10 | }; |
| 11 | 11 | |
@@ -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 | $username = $menu->askText() |
| 10 | 10 | ->setPromptText('Enter username') |
| 11 | 11 | ->setPlaceholderText('alice') |
@@ -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) { |
@@ -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]> |
@@ -87,6 +87,9 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | private $currentFrame; |
| 89 | 89 | |
| 90 | + /** |
|
| 91 | + * @param string $title |
|
| 92 | + */ |
|
| 90 | 93 | public function __construct( |
| 91 | 94 | ?string $title, |
| 92 | 95 | array $items, |
@@ -541,6 +544,9 @@ discard block |
||
| 541 | 544 | return new Password(new InputIO($this, $this->terminal), $style); |
| 542 | 545 | } |
| 543 | 546 | |
| 547 | + /** |
|
| 548 | + * @param string $text |
|
| 549 | + */ |
|
| 544 | 550 | private function guardSingleLine($text) : void |
| 545 | 551 | { |
| 546 | 552 | if (strpos($text, "\n") !== false) { |
@@ -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()), |