Completed
Push — master ( 5909ec...c2adaf )
by Aydin
13s
created
examples/nested-submenu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 use PhpSchool\CliMenu\CliMenu;
4 4
 use PhpSchool\CliMenu\Builder\CliMenuBuilder;
5 5
 
6
-require_once(__DIR__ . '/../vendor/autoload.php');
6
+require_once(__DIR__.'/../vendor/autoload.php');
7 7
 
8
-$itemCallable = function (CliMenu $menu) {
8
+$itemCallable = function(CliMenu $menu) {
9 9
     echo $menu->getSelectedItem()->getText();
10 10
 };
11 11
 
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
     ->addLineBreak('-')
17 17
     ->addSubMenu('sub-menu-1', 'Options')
18 18
         ->setTitle('CLI Menu > Options')
19
-        ->addItem('First option', function (CliMenu $menu) {
19
+        ->addItem('First option', function(CliMenu $menu) {
20 20
             echo sprintf('Executing option: %s', $menu->getSelectedItem()->getText());
21 21
         })
22 22
         ->addSubMenu('sub-menu-nested-1', 'Secret Options')
23 23
             ->setTitle('CLI Menu > Options > Secret Options')
24
-            ->addItem('First secret option', function (CliMenu $menu) {
24
+            ->addItem('First secret option', function(CliMenu $menu) {
25 25
                 echo sprintf('Executing secret option: %s', $menu->getSelectedItem()->getText());
26 26
             })
27 27
             ->addLineBreak('-')
Please login to merge, or discard this patch.
src/MenuItem/SplitItem.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Assert\Assertion;
6 6
 use PhpSchool\CliMenu\CliMenu;
7
-use PhpSchool\CliMenu\CliMenuBuilder;
8 7
 use PhpSchool\CliMenu\MenuStyle;
9 8
 use PhpSchool\CliMenu\Util\StringUtil;
10 9
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
         $length = $style->getDisplaysExtra()
118
-            ? floor($style->getContentWidth() / $numberOfItems) - (mb_strlen($style->getItemExtra()) + 2)
119
-            : floor($style->getContentWidth() / $numberOfItems);
118
+            ? floor($style->getContentWidth()/$numberOfItems) - (mb_strlen($style->getItemExtra()) + 2)
119
+            : floor($style->getContentWidth()/$numberOfItems);
120 120
         
121 121
         $length -= $this->gutter;
122 122
         
123
-        $missingLength = $style->getContentWidth() % $numberOfItems;
123
+        $missingLength = $style->getContentWidth()%$numberOfItems;
124 124
         
125 125
         return $this->buildRows(
126
-            array_map(function ($index, $item) use ($selected, $length, $style) {
126
+            array_map(function($index, $item) use ($selected, $length, $style) {
127 127
                 $isSelected = $selected && $index === $this->selectedItemIndex;
128 128
                 $marker = $item->canSelect()
129 129
                     ? sprintf('%s ', $style->getMarker($isSelected))
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $extraPadLength = $style->getDisplaysExtra() ? 2 + mb_strlen($style->getItemExtra()) : 0;
156 156
         
157 157
         return array_map(
158
-            function ($i) use ($cells, $length, $missingLength, $extraPadLength) {
158
+            function($i) use ($cells, $length, $missingLength, $extraPadLength) {
159 159
                 return $this->buildRow($cells, $i, $length, $missingLength, $extraPadLength);
160 160
             },
161 161
             range(0, max(array_map('count', $cells)) - 1)
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             implode(
170 170
                 '',
171 171
                 array_map(
172
-                    function ($cell) use ($index, $length, $extraPadLength) {
172
+                    function($cell) use ($index, $length, $extraPadLength) {
173 173
                         return $cell[$index] ?? str_repeat(' ', $length + $this->gutter + $extraPadLength);
174 174
                     },
175 175
                     $cells
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         bool $isSelected,
187 187
         string $itemExtra
188 188
     ) : array {
189
-        return array_map(function ($row, $index) use ($length, $style, $isSelected, $itemExtra) {
189
+        return array_map(function($row, $index) use ($length, $style, $isSelected, $itemExtra) {
190 190
             $invertedColoursSetCode = $isSelected
191 191
                 ? $style->getInvertedColoursSetCode()
192 192
                 : '';
Please login to merge, or discard this patch.
src/MenuItem/AsciiArtItem.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         Assertion::inArray($position, [self::POSITION_CENTER, self::POSITION_RIGHT, self::POSITION_LEFT]);
43 43
 
44 44
         $this->setText($text);
45
-        $this->position  = $position;
45
+        $this->position = $position;
46 46
         $this->alternateText = $alt;
47 47
     }
48 48
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
         $padding = $style->getContentWidth() - $this->artLength;
60 60
 
61
-        return array_map(function ($row) use ($padding) {
61
+        return array_map(function($row) use ($padding) {
62 62
             switch ($this->position) {
63 63
                 case self::POSITION_LEFT:
64 64
                     break;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     break;
68 68
                 case self::POSITION_CENTER:
69 69
                 default:
70
-                    $left = ceil($padding / 2);
70
+                    $left = ceil($padding/2);
71 71
                     $row = sprintf('%s%s', str_repeat(' ', $left), $row);
72 72
                     break;
73 73
             }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function setText(string $text) : void
107 107
     {
108
-        $this->text = implode("\n", array_map(function (string $line) {
108
+        $this->text = implode("\n", array_map(function(string $line) {
109 109
             return rtrim($line, ' ');
110 110
         }, explode("\n", $text)));
111 111
 
Please login to merge, or discard this patch.
examples/split-item.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,23 +4,23 @@
 block discarded – undo
4 4
 use PhpSchool\CliMenu\CliMenu;
5 5
 use PhpSchool\CliMenu\Builder\CliMenuBuilder;
6 6
 
7
-require_once(__DIR__ . '/../vendor/autoload.php');
7
+require_once(__DIR__.'/../vendor/autoload.php');
8 8
 
9
-$itemCallable = function (CliMenu $menu) {
9
+$itemCallable = function(CliMenu $menu) {
10 10
     echo $menu->getSelectedItem()->getText();
11 11
 };
12 12
 
13 13
 $menu = (new CliMenuBuilder)
14 14
     ->setWidth(150)
15
-    ->addSplitItem(function (SplitItemBuilder $b) use ($itemCallable) {
16
-        $b->addSubMenu('Sub Menu on a split item', function (CliMenuBuilder $b) {
15
+    ->addSplitItem(function(SplitItemBuilder $b) use ($itemCallable) {
16
+        $b->addSubMenu('Sub Menu on a split item', function(CliMenuBuilder $b) {
17 17
             $b->setTitle('Behold the awesomeness')
18 18
                 ->addItem('This is awesome', function() { print 'Yes!'; })
19
-                ->addSplitItem(function (SplitItemBuilder $b) {
19
+                ->addSplitItem(function(SplitItemBuilder $b) {
20 20
                     $b->addItem('Split Item 1', function() { print 'Item 1!'; })
21 21
                         ->addItem('Split Item 2', function() { print 'Item 2!'; })
22 22
                         ->addItem('Split Item 3', function() { print 'Item 3!'; })
23
-                        ->addSubMenu('Split Item Nested Sub Menu', function (CliMenuBuilder $b) {
23
+                        ->addSubMenu('Split Item Nested Sub Menu', function(CliMenuBuilder $b) {
24 24
                             $b->addItem('One', function() { print 'One!'; })
25 25
                                 ->addItem('Two', function() { print 'Two!'; })
26 26
                                 ->addItem('Three', function() { print 'Three!'; });
Please login to merge, or discard this patch.
examples/submenu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 use PhpSchool\CliMenu\CliMenu;
4 4
 use PhpSchool\CliMenu\Builder\CliMenuBuilder;
5 5
 
6
-require_once(__DIR__ . '/../vendor/autoload.php');
6
+require_once(__DIR__.'/../vendor/autoload.php');
7 7
 
8
-$itemCallable = function (CliMenu $menu) {
8
+$itemCallable = function(CliMenu $menu) {
9 9
     echo $menu->getSelectedItem()->getText();
10 10
 };
11 11
 
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
     ->addItem('First Item', $itemCallable)
15 15
     ->addItem('Second Item', $itemCallable)
16 16
     ->addLineBreak('-')
17
-    ->addSubMenu('Options', function (CliMenuBuilder $b) {
17
+    ->addSubMenu('Options', function(CliMenuBuilder $b) {
18 18
         $b->setTitle('CLI Menu > Options')
19
-            ->addItem('First option', function (CliMenu $menu) {
19
+            ->addItem('First option', function(CliMenu $menu) {
20 20
                 echo sprintf('Executing option: %s', $menu->getSelectedItem()->getText());
21 21
             })
22 22
             ->addLineBreak('-');
Please login to merge, or discard this patch.
src/Builder/CliMenuBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -374,7 +374,7 @@
 block discarded – undo
374 374
 
375 375
     private function itemsHaveExtra(array $items) : bool
376 376
     {
377
-        return !empty(array_filter($items, function (MenuItemInterface $item) {
377
+        return !empty(array_filter($items, function(MenuItemInterface $item) {
378 378
             return $item->showsItemExtra();
379 379
         }));
380 380
     }
Please login to merge, or discard this patch.