@@ -71,7 +71,7 @@ |
||
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | |
74 | - return mapWithKeys($rows, function (int $key, string $row) use ($style, $length) { |
|
74 | + return mapWithKeys($rows, function(int $key, string $row) use ($style, $length) { |
|
75 | 75 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
76 | 76 | |
77 | 77 | if ($key === 0) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | Assertion::inArray($position, [self::POSITION_CENTER, self::POSITION_RIGHT, self::POSITION_LEFT]); |
50 | 50 | |
51 | 51 | $this->setText($text); |
52 | - $this->position = $position; |
|
52 | + $this->position = $position; |
|
53 | 53 | $this->alternateText = $alt; |
54 | 54 | |
55 | 55 | $this->style = new DefaultStyle(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $padding = $style->getContentWidth() - $this->artLength; |
69 | 69 | |
70 | - return array_map(function ($row) use ($padding) { |
|
70 | + return array_map(function($row) use ($padding) { |
|
71 | 71 | switch ($this->position) { |
72 | 72 | case self::POSITION_LEFT: |
73 | 73 | break; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | break; |
77 | 77 | case self::POSITION_CENTER: |
78 | 78 | default: |
79 | - $left = (int) ceil($padding / 2); |
|
79 | + $left = (int) ceil($padding/2); |
|
80 | 80 | $row = sprintf('%s%s', str_repeat(' ', $left), $row); |
81 | 81 | break; |
82 | 82 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function setText(string $text) : void |
116 | 116 | { |
117 | - $this->text = implode("\n", array_map(function (string $line) { |
|
117 | + $this->text = implode("\n", array_map(function(string $line) { |
|
118 | 118 | return rtrim($line, ' '); |
119 | 119 | }, explode("\n", $text))); |
120 | 120 |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | : $this->selectedItem++; |
335 | 335 | |
336 | 336 | if ($this->selectedItem !== null && !array_key_exists($this->selectedItem, $this->items)) { |
337 | - $this->selectedItem = $direction === 'UP' |
|
337 | + $this->selectedItem = $direction === 'UP' |
|
338 | 338 | ? (int) end($itemKeys) |
339 | 339 | : (int) reset($itemKeys); |
340 | 340 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator()))); |
505 | 505 | } |
506 | 506 | |
507 | - array_map(function ($item, $index) use ($frame) { |
|
507 | + array_map(function($item, $index) use ($frame) { |
|
508 | 508 | $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem)); |
509 | 509 | }, $this->items, array_keys($this->items)); |
510 | 510 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | $borderColour = ''; |
556 | 556 | } |
557 | 557 | |
558 | - return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
558 | + return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) { |
|
559 | 559 | return sprintf( |
560 | 560 | "%s%s%s%s%s%s%s%s%s%s%s%s\n", |
561 | 561 | str_repeat(' ', $this->style->getMargin()), |
@@ -745,19 +745,19 @@ discard block |
||
745 | 745 | public function propagateStyles() : void |
746 | 746 | { |
747 | 747 | each( |
748 | - array_filter($this->items, function (MenuItemInterface $item) { |
|
748 | + array_filter($this->items, function(MenuItemInterface $item) { |
|
749 | 749 | return !$item->getStyle()->hasChangedFromDefaults(); |
750 | 750 | }), |
751 | - function (int $index, $item) { |
|
751 | + function(int $index, $item) { |
|
752 | 752 | $item->setStyle(clone $this->getItemStyleForItem($item)); |
753 | 753 | } |
754 | 754 | ); |
755 | 755 | |
756 | 756 | each( |
757 | - array_filter($this->items, function (MenuItemInterface $item) { |
|
757 | + array_filter($this->items, function(MenuItemInterface $item) { |
|
758 | 758 | return $item instanceof PropagatesStyles; |
759 | 759 | }), |
760 | - function (int $index, PropagatesStyles $item) { |
|
760 | + function(int $index, PropagatesStyles $item) { |
|
761 | 761 | $item->propagateStyles($this); |
762 | 762 | } |
763 | 763 | ); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | { |
58 | 58 | $this->styles = mapWithKeys( |
59 | 59 | $this->styles, |
60 | - function ($styleClass, ItemStyle $instance) use ($other) { |
|
60 | + function($styleClass, ItemStyle $instance) use ($other) { |
|
61 | 61 | return $instance->hasChangedFromDefaults() |
62 | 62 | ? $instance |
63 | 63 | : $other->getStyle($styleClass); |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | return mapWithKeys( |
22 | 22 | $this->wrapAndIndentText($marker, $item->getText(), $availableTextWidth), |
23 | - function (int $key, string $row) use ($menuStyle, $itemStyle, $availableTextWidth, $disabled) { |
|
23 | + function(int $key, string $row) use ($menuStyle, $itemStyle, $availableTextWidth, $disabled) { |
|
24 | 24 | $text = $disabled ? $menuStyle->getDisabledItemText($row) : $row; |
25 | 25 | |
26 | 26 | return $key === 0 && $itemStyle->getDisplaysExtra() |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | $largestItemExtra = $this->calculateItemExtra(); |
135 | 135 | |
136 | 136 | $length = $largestItemExtra > 0 |
137 | - ? floor($style->getContentWidth() / $numberOfItems) - ($largestItemExtra + 2) |
|
138 | - : floor($style->getContentWidth() / $numberOfItems); |
|
137 | + ? floor($style->getContentWidth()/$numberOfItems) - ($largestItemExtra + 2) |
|
138 | + : floor($style->getContentWidth()/$numberOfItems); |
|
139 | 139 | |
140 | 140 | $length -= $this->gutter; |
141 | 141 | $length = (int) $length; |
142 | 142 | |
143 | - $missingLength = $style->getContentWidth() % $numberOfItems; |
|
143 | + $missingLength = $style->getContentWidth()%$numberOfItems; |
|
144 | 144 | |
145 | 145 | return $this->buildRows( |
146 | - mapWithKeys($this->items, function (int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
146 | + mapWithKeys($this->items, function(int $index, MenuItemInterface $item) use ($selected, $length, $style) { |
|
147 | 147 | $isSelected = $selected && $index === $this->selectedItemIndex; |
148 | 148 | |
149 | 149 | $marker = $item->getStyle()->getMarker($item, $isSelected); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $extraPadLength = $largestItemExtra > 0 ? 2 + $largestItemExtra : 0; |
183 | 183 | |
184 | 184 | return array_map( |
185 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
185 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
186 | 186 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
187 | 187 | }, |
188 | 188 | range(0, max(array_map('count', $cells)) - 1) |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | implode( |
197 | 197 | '', |
198 | 198 | array_map( |
199 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
199 | + function($cell) use ($index, $length, $extraPadLength) { |
|
200 | 200 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
201 | 201 | }, |
202 | 202 | $cells |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | bool $isSelected, |
214 | 214 | string $itemExtra |
215 | 215 | ) : array { |
216 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
216 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
217 | 217 | $invertedColoursSetCode = $isSelected |
218 | 218 | ? $style->getInvertedColoursSetCode() |
219 | 219 | : ''; |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | private function calculateItemExtra() : int |
338 | 338 | { |
339 | 339 | return max(array_map( |
340 | - function (MenuItemInterface $item) { |
|
340 | + function(MenuItemInterface $item) { |
|
341 | 341 | return mb_strlen($item->getStyle()->getItemExtra()); |
342 | 342 | }, |
343 | - array_filter($this->items, function (MenuItemInterface $item) { |
|
343 | + array_filter($this->items, function(MenuItemInterface $item) { |
|
344 | 344 | return $item->getStyle()->getDisplaysExtra(); |
345 | 345 | }) |
346 | 346 | )); |
@@ -365,19 +365,19 @@ discard block |
||
365 | 365 | public function propagateStyles(CliMenu $parent): void |
366 | 366 | { |
367 | 367 | each( |
368 | - array_filter($this->getItems(), function (MenuItemInterface $item) { |
|
368 | + array_filter($this->getItems(), function(MenuItemInterface $item) { |
|
369 | 369 | return !$item->getStyle()->hasChangedFromDefaults(); |
370 | 370 | }), |
371 | - function ($index, $item) use ($parent) { |
|
371 | + function($index, $item) use ($parent) { |
|
372 | 372 | $item->setStyle(clone $parent->getItemStyleForItem($item)); |
373 | 373 | } |
374 | 374 | ); |
375 | 375 | |
376 | 376 | each( |
377 | - array_filter($this->getItems(), function (MenuItemInterface $item) { |
|
377 | + array_filter($this->getItems(), function(MenuItemInterface $item) { |
|
378 | 378 | return $item instanceof PropagatesStyles; |
379 | 379 | }), |
380 | - function ($index, PropagatesStyles $item) use ($parent) { |
|
380 | + function($index, PropagatesStyles $item) use ($parent) { |
|
381 | 381 | $item->propagateStyles($parent); |
382 | 382 | } |
383 | 383 | ); |