@@ -3,7 +3,7 @@ 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 | 8 | $art = <<<ART |
| 9 | 9 | _ __ _ |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | LEARNING FOR ELEPHPANTS |
| 16 | 16 | ART; |
| 17 | 17 | |
| 18 | -$itemCallable = function (CliMenu $menu) { |
|
| 18 | +$itemCallable = function(CliMenu $menu) { |
|
| 19 | 19 | echo $menu->getSelectedItem()->getText(); |
| 20 | 20 | }; |
| 21 | 21 | |
@@ -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 @@ 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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | ->addItem('Second Item', $itemCallable) |
| 16 | 16 | ->addItem('Third Item', $itemCallable) |
| 17 | 17 | ->disableDefaultItems() |
| 18 | - ->addItem('CUSTOM CLOSE', function (CliMenu $menu) { |
|
| 18 | + ->addItem('CUSTOM CLOSE', function(CliMenu $menu) { |
|
| 19 | 19 | $menu->close(); |
| 20 | 20 | }) |
| 21 | 21 | ->build(); |
@@ -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,7 +16,7 @@ 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 | ->addLineBreak('-') |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
| 5 | 5 | use PhpSchool\CliMenu\MenuItem\MenuItem; |
| 6 | 6 | |
| 7 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 7 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 8 | 8 | |
| 9 | -$itemCallable = function (CliMenu $menu) { |
|
| 9 | +$itemCallable = function(CliMenu $menu) { |
|
| 10 | 10 | echo $menu->getSelectedItem()->getText(); |
| 11 | 11 | }; |
| 12 | 12 | |
@@ -106,7 +106,7 @@ |
||
| 106 | 106 | exec('stty -icanon'); |
| 107 | 107 | $this->isCanonical = true; |
| 108 | 108 | } else { |
| 109 | - exec('stty ' . $this->getOriginalConfiguration()); |
|
| 109 | + exec('stty '.$this->getOriginalConfiguration()); |
|
| 110 | 110 | $this->isCanonical = false; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace PhpSchool\CliMenu; |
| 4 | 4 | |
| 5 | -use PhpSchool\CliMenu\Exception\InvalidInstantiationException; |
|
| 6 | 5 | use PhpSchool\CliMenu\Exception\InvalidTerminalException; |
| 7 | 6 | use PhpSchool\CliMenu\Exception\MenuNotOpenException; |
| 8 | 7 | use PhpSchool\CliMenu\MenuItem\LineBreakItem; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | : $this->selectedItem++; |
| 216 | 216 | |
| 217 | 217 | if (!array_key_exists($this->selectedItem, $this->items)) { |
| 218 | - $this->selectedItem = $direction === 'up' |
|
| 218 | + $this->selectedItem = $direction === 'up' |
|
| 219 | 219 | ? end($itemKeys) |
| 220 | 220 | : reset($itemKeys); |
| 221 | 221 | } elseif ($this->getSelectedItem()->canSelect()) { |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - array_map(function ($item, $index) use ($frame) { |
|
| 278 | + array_map(function($item, $index) use ($frame) { |
|
| 279 | 279 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
| 280 | 280 | }, $this->items, array_keys($this->items)); |
| 281 | 281 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | ? $this->style->getSelectedUnsetCode() |
| 310 | 310 | : $this->style->getUnselectedUnsetCode(); |
| 311 | 311 | |
| 312 | - return array_map(function ($row) use ($setColour, $unsetColour) { |
|
| 312 | + return array_map(function($row) use ($setColour, $unsetColour) { |
|
| 313 | 313 | return sprintf( |
| 314 | 314 | "%s%s%s%s%s%s%s\n\r", |
| 315 | 315 | str_repeat(' ', $this->style->getMargin()), |
@@ -59,6 +59,9 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | private $currentFrame; |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $title |
|
| 64 | + */ |
|
| 62 | 65 | public function __construct( |
| 63 | 66 | ?string $title, |
| 64 | 67 | array $items, |
@@ -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\CliMenu\Terminal\TerminalInterface; |
| 8 | 7 | |
@@ -267,7 +267,7 @@ |
||
| 267 | 267 | |
| 268 | 268 | public function setWidth(int $width) : self |
| 269 | 269 | { |
| 270 | - $availableWidth = $this->terminal->getWidth() - ($this->margin * 2) - ($this->padding * 2); |
|
| 270 | + $availableWidth = $this->terminal->getWidth() - ($this->margin*2) - ($this->padding*2); |
|
| 271 | 271 | |
| 272 | 272 | if ($width >= $availableWidth) { |
| 273 | 273 | $width = $availableWidth; |
@@ -4,13 +4,13 @@ |
||
| 4 | 4 | use PhpSchool\CliMenu\CliMenuBuilder; |
| 5 | 5 | use PhpSchool\CliMenu\MenuItem\MenuItemInterface; |
| 6 | 6 | |
| 7 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 7 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 8 | 8 | |
| 9 | -$itemCallable = function (CliMenu $menu) { |
|
| 9 | +$itemCallable = function(CliMenu $menu) { |
|
| 10 | 10 | static $i = 1; |
| 11 | 11 | |
| 12 | 12 | foreach ($menu->getItems() as $item) { |
| 13 | - $i % 2 === 0 |
|
| 13 | + $i%2 === 0 |
|
| 14 | 14 | ? $item->showItemExtra() |
| 15 | 15 | : $item->hideItemExtra(); |
| 16 | 16 | |