@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | $this->menu = $menu; |
| 60 | 60 | $this->splitItem = new SplitItem(); |
| 61 | 61 | |
| 62 | - $this->checkboxStyle = new CheckboxStyle(); |
|
| 63 | - $this->radioStyle = new RadioStyle(); |
|
| 62 | + $this->checkboxStyle = new CheckboxStyle(); |
|
| 63 | + $this->radioStyle = new RadioStyle(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function addItem( |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | $menu = $builder->build(); |
| 130 | 130 | $menu->setParent($this->menu); |
| 131 | 131 | |
| 132 | - $menu->checkboxStyle(function (CheckboxStyle $style) { |
|
| 132 | + $menu->checkboxStyle(function(CheckboxStyle $style) { |
|
| 133 | 133 | $style->fromArray($this->menu->getCheckboxStyle()->toArray()); |
| 134 | 134 | }); |
| 135 | 135 | |
| 136 | - $menu->radioStyle(function (RadioStyle $style) { |
|
| 136 | + $menu->radioStyle(function(RadioStyle $style) { |
|
| 137 | 137 | $style->fromArray($this->menu->getRadioStyle()->toArray()); |
| 138 | 138 | }); |
| 139 | 139 | |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | if (!$menu->getCheckboxStyle()->getIsCustom()) { |
| 206 | - $menu->checkboxStyle(function (CheckboxStyle $style) { |
|
| 206 | + $menu->checkboxStyle(function(CheckboxStyle $style) { |
|
| 207 | 207 | $style->fromArray($this->menu->getCheckboxStyle()->toArray()); |
| 208 | 208 | }); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if (!$menu->getRadioStyle()->getIsCustom()) { |
| 212 | - $menu->radioStyle(function (RadioStyle $style) { |
|
| 212 | + $menu->radioStyle(function(RadioStyle $style) { |
|
| 213 | 213 | $style->fromArray($this->menu->getRadioStyle()->toArray()); |
| 214 | 214 | }); |
| 215 | 215 | } |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | $menu->setStyle($this->menu->getStyle()); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $menu->checkboxStyle(function (CheckboxStyle $style) { |
|
| 239 | + $menu->checkboxStyle(function(CheckboxStyle $style) { |
|
| 240 | 240 | $style->fromArray($this->menu->getCheckboxStyle()->toArray()); |
| 241 | 241 | }); |
| 242 | 242 | |
| 243 | - $menu->radioStyle(function (RadioStyle $style) { |
|
| 243 | + $menu->radioStyle(function(RadioStyle $style) { |
|
| 244 | 244 | $style->fromArray($this->menu->getRadioStyle()->toArray()); |
| 245 | 245 | }); |
| 246 | 246 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | private function processItemShortcut(MenuItemInterface $item) : void |
| 285 | 285 | { |
| 286 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($item) { |
|
| 286 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($item) { |
|
| 287 | 287 | $menu->executeAsSelected($item); |
| 288 | 288 | }); |
| 289 | 289 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | private function processSplitItemShortcuts(SplitItem $splitItem) : void |
| 292 | 292 | { |
| 293 | 293 | foreach ($splitItem->getItems() as $item) { |
| 294 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($splitItem, $item) { |
|
| 294 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($splitItem, $item) { |
|
| 295 | 295 | $current = $splitItem->getSelectedItemIndex(); |
| 296 | 296 | |
| 297 | 297 | $splitItem->setSelectedItemIndex( |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | $callback($builder); |
| 333 | 333 | |
| 334 | - $builder->checkboxStyle(function (CheckboxStyle $style) { |
|
| 334 | + $builder->checkboxStyle(function(CheckboxStyle $style) { |
|
| 335 | 335 | $style->fromArray($this->menu->getCheckboxStyle()->toArray()); |
| 336 | 336 | }); |
| 337 | 337 | |
| 338 | - $builder->radioStyle(function (RadioStyle $style) { |
|
| 338 | + $builder->radioStyle(function(RadioStyle $style) { |
|
| 339 | 339 | $style->fromArray($this->menu->getRadioStyle()->toArray()); |
| 340 | 340 | }); |
| 341 | 341 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | private function itemsHaveExtra(array $items) : bool |
| 551 | 551 | { |
| 552 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
| 552 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
| 553 | 553 | return $item->showsItemExtra(); |
| 554 | 554 | })); |
| 555 | 555 | } |
@@ -118,22 +118,22 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $length = $style->getDisplaysExtra() |
| 121 | - ? floor($style->getContentWidth() / $numberOfItems) - (mb_strlen($style->getItemExtra()) + 2) |
|
| 122 | - : floor($style->getContentWidth() / $numberOfItems); |
|
| 121 | + ? floor($style->getContentWidth()/$numberOfItems) - (mb_strlen($style->getItemExtra()) + 2) |
|
| 122 | + : floor($style->getContentWidth()/$numberOfItems); |
|
| 123 | 123 | |
| 124 | 124 | $length -= $this->gutter; |
| 125 | 125 | $length = (int) $length; |
| 126 | 126 | |
| 127 | - $missingLength = $style->getContentWidth() % $numberOfItems; |
|
| 127 | + $missingLength = $style->getContentWidth()%$numberOfItems; |
|
| 128 | 128 | |
| 129 | 129 | return $this->buildRows( |
| 130 | - array_map(function ($index, $item) use ($selected, $length, $style) { |
|
| 130 | + array_map(function($index, $item) use ($selected, $length, $style) { |
|
| 131 | 131 | $isSelected = $selected && $index === $this->selectedItemIndex; |
| 132 | 132 | |
| 133 | 133 | if ($item instanceof CheckboxItem || $item instanceof RadioItem) { |
| 134 | 134 | $markerType = $item->getStyle()->getMarker($item->getChecked()); |
| 135 | 135 | $displaysExtra = $item->getStyle()->getDisplaysExtra(); |
| 136 | - $itemExtraVal = $item->getStyle()->getItemExtra(); |
|
| 136 | + $itemExtraVal = $item->getStyle()->getItemExtra(); |
|
| 137 | 137 | } else { |
| 138 | 138 | $markerType = $style->getMarker($isSelected); |
| 139 | 139 | $displaysExtra = $style->getDisplaysExtra(); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $extraPadLength = $style->getDisplaysExtra() ? 2 + mb_strlen($style->getItemExtra()) : 0; |
| 178 | 178 | |
| 179 | 179 | return array_map( |
| 180 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
| 180 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
| 181 | 181 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
| 182 | 182 | }, |
| 183 | 183 | range(0, max(array_map('count', $cells)) - 1) |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | implode( |
| 192 | 192 | '', |
| 193 | 193 | array_map( |
| 194 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
| 194 | + function($cell) use ($index, $length, $extraPadLength) { |
|
| 195 | 195 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
| 196 | 196 | }, |
| 197 | 197 | $cells |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | bool $isSelected, |
| 209 | 209 | string $itemExtra |
| 210 | 210 | ) : array { |
| 211 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
| 211 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
| 212 | 212 | $invertedColoursSetCode = $isSelected |
| 213 | 213 | ? $style->getInvertedColoursSetCode() |
| 214 | 214 | : ''; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - return array_map(function ($row, $key) use ($style, $length, $itemExtra) { |
|
| 55 | + return array_map(function($row, $key) use ($style, $length, $itemExtra) { |
|
| 56 | 56 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
| 57 | 57 | |
| 58 | 58 | if ($key === 0) { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function getSelectAction() : ?callable |
| 72 | 72 | { |
| 73 | - return function (CliMenu $cliMenu) { |
|
| 73 | + return function(CliMenu $cliMenu) { |
|
| 74 | 74 | $parentItem = $cliMenu->getItemByIndex($cliMenu->getSelectedItemIndex()); |
| 75 | 75 | |
| 76 | 76 | $siblings = $parentItem instanceof SplitItem |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $filtered = array_filter( |
| 81 | 81 | $siblings, |
| 82 | - function (MenuItemInterface $item) { |
|
| 82 | + function(MenuItemInterface $item) { |
|
| 83 | 83 | return $item instanceof self; |
| 84 | 84 | } |
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | array_walk( |
| 88 | 88 | $filtered, |
| 89 | - function (RadioItem $item) { |
|
| 89 | + function(RadioItem $item) { |
|
| 90 | 90 | $item->setUnchecked(); |
| 91 | 91 | } |
| 92 | 92 | ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | ) |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - return array_map(function ($row, $key) use ($style, $length, $itemExtra) { |
|
| 55 | + return array_map(function($row, $key) use ($style, $length, $itemExtra) { |
|
| 56 | 56 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
| 57 | 57 | |
| 58 | 58 | if ($key === 0) { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function getSelectAction() : ?callable |
| 72 | 72 | { |
| 73 | - return function (CliMenu $cliMenu) { |
|
| 73 | + return function(CliMenu $cliMenu) { |
|
| 74 | 74 | $this->toggle(); |
| 75 | 75 | $cliMenu->redraw(); |
| 76 | 76 | |