@@ -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; |
@@ -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, |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | : $this->selectedItem++; |
193 | 193 | |
194 | 194 | if (!array_key_exists($this->selectedItem, $this->items)) { |
195 | - $this->selectedItem = $direction === 'up' |
|
195 | + $this->selectedItem = $direction === 'up' |
|
196 | 196 | ? end($itemKeys) |
197 | 197 | : reset($itemKeys); |
198 | 198 | } elseif ($this->getSelectedItem()->canSelect()) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
248 | 248 | } |
249 | 249 | |
250 | - array_map(function ($item, $index) use ($frame) { |
|
250 | + array_map(function($item, $index) use ($frame) { |
|
251 | 251 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
252 | 252 | }, $this->items, array_keys($this->items)); |
253 | 253 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ? $this->style->getSelectedUnsetCode() |
293 | 293 | : $this->style->getUnselectedUnsetCode(); |
294 | 294 | |
295 | - $rows = array_map(function ($row) use ($setColour, $unsetColour) { |
|
295 | + $rows = array_map(function($row) use ($setColour, $unsetColour) { |
|
296 | 296 | return sprintf( |
297 | 297 | "%s%s%s%s%s%s%s\n\r", |
298 | 298 | 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\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 |