@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | $largestItemExtra = $this->calculateItemExtra(); |
136 | 136 | |
137 | 137 | $length = $largestItemExtra > 0 |
138 | - ? floor($style->getContentWidth() / $numberOfItems) - ($largestItemExtra + 2) |
|
139 | - : floor($style->getContentWidth() / $numberOfItems); |
|
138 | + ? floor($style->getContentWidth()/$numberOfItems) - ($largestItemExtra + 2) |
|
139 | + : floor($style->getContentWidth()/$numberOfItems); |
|
140 | 140 | |
141 | 141 | $length -= $this->gutter; |
142 | 142 | $length = (int) $length; |
143 | 143 | |
144 | - $missingLength = $style->getContentWidth() % $numberOfItems; |
|
144 | + $missingLength = $style->getContentWidth()%$numberOfItems; |
|
145 | 145 | |
146 | 146 | return $this->buildRows( |
147 | - mapWithKeys($this->items, function (int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
147 | + mapWithKeys($this->items, function(int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
148 | 148 | $isSelected = $selected && $index === $this->selectedItemIndex; |
149 | 149 | |
150 | 150 | $marker = $item->getStyle()->getMarker($item, $isSelected); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $extraPadLength = $largestItemExtra > 0 ? 2 + $largestItemExtra : 0; |
184 | 184 | |
185 | 185 | return array_map( |
186 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
186 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
187 | 187 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
188 | 188 | }, |
189 | 189 | range(0, max(array_map('count', $cells)) - 1) |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | implode( |
198 | 198 | '', |
199 | 199 | array_map( |
200 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
200 | + function($cell) use ($index, $length, $extraPadLength) { |
|
201 | 201 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
202 | 202 | }, |
203 | 203 | $cells |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | bool $isSelected, |
215 | 215 | string $itemExtra |
216 | 216 | ) : array { |
217 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
217 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
218 | 218 | $invertedColoursSetCode = $isSelected |
219 | 219 | ? $style->getInvertedColoursSetCode() |
220 | 220 | : ''; |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | private function calculateItemExtra() : int |
339 | 339 | { |
340 | 340 | return max(array_map( |
341 | - function (MenuItemInterface $item) { |
|
341 | + function(MenuItemInterface $item) { |
|
342 | 342 | return mb_strlen($item->getStyle()->getItemExtra()); |
343 | 343 | }, |
344 | - array_filter($this->items, function (MenuItemInterface $item) { |
|
344 | + array_filter($this->items, function(MenuItemInterface $item) { |
|
345 | 345 | return $item->getStyle()->getDisplaysExtra(); |
346 | 346 | }) |
347 | 347 | )); |
@@ -366,21 +366,21 @@ discard block |
||
366 | 366 | public function propagateStyles(CliMenu $parent): void |
367 | 367 | { |
368 | 368 | collect($this->items) |
369 | - ->filter(function (int $k, MenuItemInterface $item) use ($parent) { |
|
369 | + ->filter(function(int $k, MenuItemInterface $item) use ($parent) { |
|
370 | 370 | return $parent->getStyleLocator()->hasStyleForMenuItem($item); |
371 | 371 | }) |
372 | - ->filter(function (int $k, MenuItemInterface $item) { |
|
372 | + ->filter(function(int $k, MenuItemInterface $item) { |
|
373 | 373 | return !$item->getStyle()->hasChangedFromDefaults(); |
374 | 374 | }) |
375 | - ->each(function (int $k, $item) use ($parent) { |
|
375 | + ->each(function(int $k, $item) use ($parent) { |
|
376 | 376 | $item->setStyle(clone $parent->getItemStyleForItem($item)); |
377 | 377 | }); |
378 | 378 | |
379 | 379 | collect($this->items) |
380 | - ->filter(function (int $k, MenuItemInterface $item) { |
|
380 | + ->filter(function(int $k, MenuItemInterface $item) { |
|
381 | 381 | return $item instanceof PropagatesStyles; |
382 | 382 | }) |
383 | - ->each(function (int $k, $item) use ($parent) { |
|
383 | + ->each(function(int $k, $item) use ($parent) { |
|
384 | 384 | $item->propagateStyles($parent); |
385 | 385 | }); |
386 | 386 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | function filter(array $array, callable $callback) : array |
20 | 20 | { |
21 | - return array_filter($array, function ($v, $k) use ($callback) { |
|
21 | + return array_filter($array, function($v, $k) use ($callback) { |
|
22 | 22 | return $callback($k, $v); |
23 | 23 | }, ARRAY_FILTER_USE_BOTH); |
24 | 24 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | : $this->selectedItem++; |
336 | 336 | |
337 | 337 | if ($this->selectedItem !== null && !array_key_exists($this->selectedItem, $this->items)) { |
338 | - $this->selectedItem = $direction === 'UP' |
|
338 | + $this->selectedItem = $direction === 'UP' |
|
339 | 339 | ? (int) end($itemKeys) |
340 | 340 | : (int) reset($itemKeys); |
341 | 341 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
506 | 506 | } |
507 | 507 | |
508 | - array_map(function ($item, $index) use ($frame) { |
|
508 | + array_map(function($item, $index) use ($frame) { |
|
509 | 509 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
510 | 510 | }, $this->items, array_keys($this->items)); |
511 | 511 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | $borderColour = ''; |
557 | 557 | } |
558 | 558 | |
559 | - return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
559 | + return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
560 | 560 | return sprintf( |
561 | 561 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
562 | 562 | str_repeat(' ', $this->style->getMargin()), |
@@ -751,22 +751,22 @@ discard block |
||
751 | 751 | public function propagateStyles() : void |
752 | 752 | { |
753 | 753 | collect($this->items) |
754 | - ->filter(function (int $k, MenuItemInterface $item) { |
|
754 | + ->filter(function(int $k, MenuItemInterface $item) { |
|
755 | 755 | return $this->itemStyleLocator->hasStyleForMenuItem($item); |
756 | 756 | }) |
757 | - ->filter(function (int $k, MenuItemInterface $item) { |
|
757 | + ->filter(function(int $k, MenuItemInterface $item) { |
|
758 | 758 | return !$item->getStyle()->hasChangedFromDefaults(); |
759 | 759 | }) |
760 | - ->each(function (int $k, $item) { |
|
760 | + ->each(function(int $k, $item) { |
|
761 | 761 | $item->setStyle(clone $this->getItemStyleForItem($item)); |
762 | 762 | }); |
763 | 763 | |
764 | 764 | |
765 | 765 | collect($this->items) |
766 | - ->filter(function (int $k, MenuItemInterface $item) { |
|
766 | + ->filter(function(int $k, MenuItemInterface $item) { |
|
767 | 767 | return $item instanceof PropagatesStyles; |
768 | 768 | }) |
769 | - ->each(function (int $k, $item) { |
|
769 | + ->each(function(int $k, $item) { |
|
770 | 770 | $item->propagateStyles($this); |
771 | 771 | }); |
772 | 772 | } |
@@ -111,7 +111,7 @@ |
||
111 | 111 | $builder->enableAutoShortcuts($this->autoShortcutsRegex); |
112 | 112 | } |
113 | 113 | |
114 | - each($this->extraItemStyles, function (int $i, array $extraItemStyle) use ($builder) { |
|
114 | + each($this->extraItemStyles, function(int $i, array $extraItemStyle) use ($builder) { |
|
115 | 115 | $builder->registerItemStyle($extraItemStyle['class'], $extraItemStyle['style']); |
116 | 116 | }); |
117 | 117 |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $builder->enableAutoShortcuts($this->autoShortcutsRegex); |
195 | 195 | } |
196 | 196 | |
197 | - each($this->extraItemStyles, function (int $i, array $extraItemStyle) use ($builder) { |
|
197 | + each($this->extraItemStyles, function(int $i, array $extraItemStyle) use ($builder) { |
|
198 | 198 | $builder->registerItemStyle($extraItemStyle['class'], $extraItemStyle['style']); |
199 | 199 | }); |
200 | 200 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | private function processItemShortcut(MenuItemInterface $item) : void |
260 | 260 | { |
261 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($item) { |
|
261 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($item) { |
|
262 | 262 | $menu->executeAsSelected($item); |
263 | 263 | }); |
264 | 264 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | private function processSplitItemShortcuts(SplitItem $splitItem) : void |
267 | 267 | { |
268 | 268 | foreach ($splitItem->getItems() as $item) { |
269 | - $this->processIndividualShortcut($item, function (CliMenu $menu) use ($splitItem, $item) { |
|
269 | + $this->processIndividualShortcut($item, function(CliMenu $menu) use ($splitItem, $item) { |
|
270 | 270 | $current = $splitItem->getSelectedItemIndex(); |
271 | 271 | |
272 | 272 | $splitItem->setSelectedItemIndex( |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $builder->enableAutoShortcuts($this->autoShortcutsRegex); |
305 | 305 | } |
306 | 306 | |
307 | - each($this->extraItemStyles, function (int $i, array $extraItemStyle) use ($builder) { |
|
307 | + each($this->extraItemStyles, function(int $i, array $extraItemStyle) use ($builder) { |
|
308 | 308 | $builder->registerItemStyle($extraItemStyle['class'], $extraItemStyle['style']); |
309 | 309 | }); |
310 | 310 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | |
514 | 514 | private function itemsHaveExtra(array $items) : bool |
515 | 515 | { |
516 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
516 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
517 | 517 | return $item->showsItemExtra(); |
518 | 518 | })); |
519 | 519 | } |