@@ -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 | }) |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | return max( |
| 100 | 100 | array_map( |
| 101 | - function (string $line) { |
|
| 101 | + function(string $line) { |
|
| 102 | 102 | return mb_strlen($line); |
| 103 | 103 | }, |
| 104 | 104 | $lines |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty |
| 112 | 112 | |
| 113 | - return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1; |
|
| 113 | + return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | private function calculateYPositionWithError() : int |
| 117 | 117 | { |
| 118 | 118 | $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. 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 calculateXPosition(Input $input, string $userInput) : int |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | $parentStyle = $this->parentMenu->getStyle(); |
| 134 | - $halfWidth = ($width + ($input->getStyle()->getPaddingLeftRight() * 2)) / 2; |
|
| 135 | - $parentHalfWidth = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin()); |
|
| 134 | + $halfWidth = ($width + ($input->getStyle()->getPaddingLeftRight()*2))/2; |
|
| 135 | + $parentHalfWidth = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin()); |
|
| 136 | 136 | |
| 137 | 137 | return $parentHalfWidth - $halfWidth; |
| 138 | 138 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text)); |
| 167 | - $leftFill = ($width / 2) - ($textLength / 2); |
|
| 167 | + $leftFill = ($width/2) - ($textLength/2); |
|
| 168 | 168 | $rightFill = ceil($width - $leftFill - $textLength); |
| 169 | 169 | |
| 170 | 170 | $this->drawLine( |
@@ -69,12 +69,12 @@ |
||
| 69 | 69 | { |
| 70 | 70 | //y |
| 71 | 71 | $textLines = count(explode("\n", $this->text)) + 2; |
| 72 | - $this->y = ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($textLines / 2) + 1; |
|
| 72 | + $this->y = ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($textLines/2) + 1; |
|
| 73 | 73 | |
| 74 | 74 | //x |
| 75 | 75 | $parentStyle = $this->parentMenu->getStyle(); |
| 76 | - $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight() * 2)) / 2; |
|
| 77 | - $widthHalfLength = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin()); |
|
| 76 | + $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight()*2))/2; |
|
| 77 | + $widthHalfLength = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin()); |
|
| 78 | 78 | $this->x = $widthHalfLength - $dialogueHalfLength; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | protected function calculateContentWidth() : void |
| 314 | 314 | { |
| 315 | 315 | $this->contentWidth = $this->width |
| 316 | - - ($this->paddingLeftRight * 2) |
|
| 316 | + - ($this->paddingLeftRight*2) |
|
| 317 | 317 | - ($this->borderRightWidth + $this->borderLeftWidth); |
| 318 | 318 | |
| 319 | 319 | if ($this->contentWidth < 0) { |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | public function setMarginAuto() : self |
| 467 | 467 | { |
| 468 | 468 | $this->marginAuto = true; |
| 469 | - $this->margin = floor(($this->terminal->getWidth() - $this->width) / 2); |
|
| 469 | + $this->margin = floor(($this->terminal->getWidth() - $this->width)/2); |
|
| 470 | 470 | |
| 471 | 471 | $this->generateBorderRows(); |
| 472 | 472 | $this->generatePaddingTopBottomRows(); |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | use PhpSchool\CliMenu\Input\InputIO; |
| 7 | 7 | use PhpSchool\CliMenu\MenuStyle; |
| 8 | 8 | |
| 9 | -require_once(__DIR__ . '/../vendor/autoload.php'); |
|
| 9 | +require_once(__DIR__.'/../vendor/autoload.php'); |
|
| 10 | 10 | |
| 11 | -$itemCallable = function (CliMenu $menu) { |
|
| 11 | +$itemCallable = function(CliMenu $menu) { |
|
| 12 | 12 | $style = (new MenuStyle()) |
| 13 | 13 | ->setBg('yellow') |
| 14 | 14 | ->setFg('black'); |