@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | return implode( |
| 17 | 17 | $break, |
| 18 | - array_map(function (string $line) use ($width, $break) { |
|
| 18 | + array_map(function(string $line) use ($width, $break) { |
|
| 19 | 19 | $line = rtrim($line); |
| 20 | 20 | if (mb_strlen($line) <= $width) { |
| 21 | 21 | return $line; |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | $line = ''; |
| 26 | 26 | $actual = ''; |
| 27 | 27 | foreach ($words as $word) { |
| 28 | - if (mb_strlen($actual . $word) <= $width) { |
|
| 29 | - $actual .= $word . ' '; |
|
| 28 | + if (mb_strlen($actual.$word) <= $width) { |
|
| 29 | + $actual .= $word.' '; |
|
| 30 | 30 | } else { |
| 31 | 31 | if ($actual !== '') { |
| 32 | - $line .= rtrim($actual) . $break; |
|
| 32 | + $line .= rtrim($actual).$break; |
|
| 33 | 33 | } |
| 34 | - $actual = $word . ' '; |
|
| 34 | + $actual = $word.' '; |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | - return $line . trim($actual); |
|
| 37 | + return $line.trim($actual); |
|
| 38 | 38 | }, explode("\n", $string)) |
| 39 | 39 | ); |
| 40 | 40 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function getSelectAction() : ?callable |
| 31 | 31 | { |
| 32 | - return function (CliMenu $menu) { |
|
| 32 | + return function(CliMenu $menu) { |
|
| 33 | 33 | $this->showSubMenu($menu); |
| 34 | 34 | }; |
| 35 | 35 | } |
@@ -69,12 +69,12 @@ |
||
| 69 | 69 | { |
| 70 | 70 | //y |
| 71 | 71 | $textLines = count(explode("\n", $this->text)) + 2; |
| 72 | - $this->y = (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($textLines / 2) + 1); |
|
| 72 | + $this->y = (int) (ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($textLines/2) + 1); |
|
| 73 | 73 | |
| 74 | 74 | //x |
| 75 | 75 | $parentStyle = $this->parentMenu->getStyle(); |
| 76 | - $dialogueHalfLength = (int) ((mb_strlen($this->text) + ($this->style->getPaddingLeftRight() * 2)) / 2); |
|
| 77 | - $widthHalfLength = (int) ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin()); |
|
| 76 | + $dialogueHalfLength = (int) ((mb_strlen($this->text) + ($this->style->getPaddingLeftRight()*2))/2); |
|
| 77 | + $widthHalfLength = (int) ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin()); |
|
| 78 | 78 | $this->x = $widthHalfLength - $dialogueHalfLength; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $this->emptyRow(); |
| 37 | 37 | |
| 38 | 38 | $confirmText = sprintf(' < %s > ', $confirmText); |
| 39 | - $leftFill = (int) (($promptWidth / 2) - (mb_strlen($confirmText) / 2)); |
|
| 39 | + $leftFill = (int) (($promptWidth/2) - (mb_strlen($confirmText)/2)); |
|
| 40 | 40 | |
| 41 | 41 | $this->write(sprintf( |
| 42 | 42 | "%s%s%s%s%s%s%s\n", |
@@ -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 (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1); |
|
| 113 | + return (int) (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 (int) (ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1); |
|
| 120 | + return (int) (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 (int) ($parentHalfWidth - $halfWidth); |
| 138 | 138 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text)); |
| 167 | - $leftFill = (int) (($width / 2) - ($textLength / 2)); |
|
| 167 | + $leftFill = (int) (($width/2) - ($textLength/2)); |
|
| 168 | 168 | $rightFill = (int) ceil($width - $leftFill - $textLength); |
| 169 | 169 | |
| 170 | 170 | $this->drawLine( |
@@ -79,11 +79,11 @@ |
||
| 79 | 79 | |
| 80 | 80 | public function ask() : InputResult |
| 81 | 81 | { |
| 82 | - $this->inputIO->registerControlCallback(InputCharacter::UP, function (string $input) { |
|
| 82 | + $this->inputIO->registerControlCallback(InputCharacter::UP, function(string $input) { |
|
| 83 | 83 | return $this->validate($input) ? (int) $input + 1 : $input; |
| 84 | 84 | }); |
| 85 | 85 | |
| 86 | - $this->inputIO->registerControlCallback(InputCharacter::DOWN, function (string $input) { |
|
| 86 | + $this->inputIO->registerControlCallback(InputCharacter::DOWN, function(string $input) { |
|
| 87 | 87 | return $this->validate($input) ? (int) $input - 1 : $input; |
| 88 | 88 | }); |
| 89 | 89 | |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public function getSelectAction() : ?callable |
| 47 | 47 | { |
| 48 | - return function (CliMenu $cliMenu) { |
|
| 48 | + return function(CliMenu $cliMenu) { |
|
| 49 | 49 | $this->toggle(); |
| 50 | 50 | $cliMenu->redraw(); |
| 51 | 51 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function getSelectAction() : ?callable |
| 47 | 47 | { |
| 48 | - return function (CliMenu $cliMenu) { |
|
| 48 | + return function(CliMenu $cliMenu) { |
|
| 49 | 49 | $parentItem = $cliMenu->getItemByIndex($cliMenu->getSelectedItemIndex()); |
| 50 | 50 | |
| 51 | 51 | $siblings = $parentItem instanceof SplitItem |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $filtered = array_filter( |
| 56 | 56 | $siblings, |
| 57 | - function (MenuItemInterface $item) { |
|
| 57 | + function(MenuItemInterface $item) { |
|
| 58 | 58 | return $item instanceof self; |
| 59 | 59 | } |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | 62 | array_walk( |
| 63 | 63 | $filtered, |
| 64 | - function (RadioItem $item) { |
|
| 64 | + function(RadioItem $item) { |
|
| 65 | 65 | $item->setUnchecked(); |
| 66 | 66 | } |
| 67 | 67 | ); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | protected function calculateContentWidth() : void |
| 348 | 348 | { |
| 349 | 349 | $this->contentWidth = $this->width |
| 350 | - - ($this->paddingLeftRight * 2) |
|
| 350 | + - ($this->paddingLeftRight*2) |
|
| 351 | 351 | - ($this->borderRightWidth + $this->borderLeftWidth); |
| 352 | 352 | |
| 353 | 353 | if ($this->contentWidth < 0) { |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | private function maybeShrinkWidth(int $margin, int $width) : int |
| 419 | 419 | { |
| 420 | - if ($width + ($margin * 2) >= $this->terminal->getWidth()) { |
|
| 421 | - $width = $this->terminal->getWidth() - ($margin * 2); |
|
| 420 | + if ($width + ($margin*2) >= $this->terminal->getWidth()) { |
|
| 421 | + $width = $this->terminal->getWidth() - ($margin*2); |
|
| 422 | 422 | |
| 423 | 423 | if ($width <= 0) { |
| 424 | 424 | throw CannotShrinkMenuException::fromMarginAndTerminalWidth($margin, $this->terminal->getWidth()); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | |
| 534 | 534 | private function calculateMarginAuto(int $width) : void |
| 535 | 535 | { |
| 536 | - $this->margin = (int) floor(($this->terminal->getWidth() - ($width)) / 2); |
|
| 536 | + $this->margin = (int) floor(($this->terminal->getWidth() - ($width))/2); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | public function setMargin(int $margin) : self |