@@ -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 |
@@ -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 = ''; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $extraPadLength = $largestItemExtra > 0 ? 2 + $largestItemExtra : 0; |
186 | 186 | |
187 | 187 | return array_map( |
188 | - function ($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
188 | + function($i) use ($cells, $length, $missingLength, $extraPadLength) { |
|
189 | 189 | return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength); |
190 | 190 | }, |
191 | 191 | range(0, max(array_map('count', $cells)) - 1) |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | implode( |
200 | 200 | '', |
201 | 201 | array_map( |
202 | - function ($cell) use ($index, $length, $extraPadLength) { |
|
202 | + function($cell) use ($index, $length, $extraPadLength) { |
|
203 | 203 | return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength); |
204 | 204 | }, |
205 | 205 | $cells |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | bool $isSelected, |
217 | 217 | string $itemExtra |
218 | 218 | ) : array { |
219 | - return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
219 | + return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) { |
|
220 | 220 | $invertedColoursSetCode = $isSelected |
221 | 221 | ? $style->getInvertedColoursSetCode() |
222 | 222 | : ''; |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | private function calculateItemExtra() : int |
341 | 341 | { |
342 | 342 | return max(array_map( |
343 | - function (MenuItemInterface $item) { |
|
343 | + function(MenuItemInterface $item) { |
|
344 | 344 | return mb_strlen($item->getStyle()->getItemExtra()); |
345 | 345 | }, |
346 | - array_filter($this->items, function (MenuItemInterface $item) { |
|
346 | + array_filter($this->items, function(MenuItemInterface $item) { |
|
347 | 347 | return $item->getStyle()->getDisplaysExtra(); |
348 | 348 | }) |
349 | 349 | )); |
@@ -368,19 +368,19 @@ discard block |
||
368 | 368 | public function propagateStyles(CliMenu $parent): void |
369 | 369 | { |
370 | 370 | each( |
371 | - array_filter($this->getItems(), function (MenuItemInterface $item) { |
|
371 | + array_filter($this->getItems(), function(MenuItemInterface $item) { |
|
372 | 372 | return !$item->getStyle()->hasChangedFromDefaults(); |
373 | 373 | }), |
374 | - function ($index, $item) use ($parent) { |
|
374 | + function($index, $item) use ($parent) { |
|
375 | 375 | $item->setStyle(clone $parent->getItemStyleForItem($item)); |
376 | 376 | } |
377 | 377 | ); |
378 | 378 | |
379 | 379 | each( |
380 | - array_filter($this->getItems(), function (MenuItemInterface $item) { |
|
380 | + array_filter($this->getItems(), function(MenuItemInterface $item) { |
|
381 | 381 | return $item instanceof PropagatesStyles; |
382 | 382 | }), |
383 | - function ($index, PropagatesStyles $item) use ($parent) { |
|
383 | + function($index, PropagatesStyles $item) use ($parent) { |
|
384 | 384 | $item->propagateStyles($parent); |
385 | 385 | } |
386 | 386 | ); |
@@ -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); |