@@ -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 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - return array_map(function ($row, $key) use ($style, $marker, $length) { |
|
| 55 | + return array_map(function($row, $key) use ($style, $marker, $length) { |
|
| 56 | 56 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
| 57 | 57 | |
| 58 | 58 | if ($key === 0) { |
@@ -3,20 +3,20 @@ |
||
| 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('Second Item', function (CliMenu $menu) { |
|
| 15 | + ->addItem('Second Item', function(CliMenu $menu) { |
|
| 16 | 16 | $menu->getStyle()->setBg('red'); |
| 17 | 17 | $menu->redraw(); |
| 18 | 18 | }) |
| 19 | - ->addItem('Third Item', function (CliMenu $menu) { |
|
| 19 | + ->addItem('Third Item', function(CliMenu $menu) { |
|
| 20 | 20 | $menu->getStyle()->setBg('default'); |
| 21 | 21 | $menu->redraw(); |
| 22 | 22 | }) |
@@ -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->askPassword() |
| 10 | 10 | ->setPlaceholderText('') |
| 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->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') |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | return max( |
| 107 | 107 | array_map( |
| 108 | - function (string $line) { |
|
| 108 | + function(string $line) { |
|
| 109 | 109 | return mb_strlen($line); |
| 110 | 110 | }, |
| 111 | 111 | $lines |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty |
| 119 | 119 | |
| 120 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
| 120 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | private function calculateYPositionWithError() : int |
| 124 | 124 | { |
| 125 | 125 | $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty |
| 126 | 126 | |
| 127 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
| 127 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | private function calculateXPosition(Input $input, string $userInput) : int |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | ); |
| 139 | 139 | |
| 140 | 140 | $parentStyle = $this->parentMenu->getStyle(); |
| 141 | - $halfWidth = ($width + ($this->style->getPadding() * 2)) / 2; |
|
| 142 | - $parentHalfWidth = ceil($parentStyle->getWidth() / 2); |
|
| 141 | + $halfWidth = ($width + ($this->style->getPadding()*2))/2; |
|
| 142 | + $parentHalfWidth = ceil($parentStyle->getWidth()/2); |
|
| 143 | 143 | |
| 144 | 144 | return $parentHalfWidth - $halfWidth; |
| 145 | 145 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | 171 | $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text)); |
| 172 | - $leftFill = ($width / 2) - ($textLength / 2); |
|
| 172 | + $leftFill = ($width/2) - ($textLength/2); |
|
| 173 | 173 | $rightFill = ceil($width - $leftFill - $textLength); |
| 174 | 174 | |
| 175 | 175 | $this->drawLine( |