Completed
Pull Request — master (#127)
by Aydin
02:02
created
examples/input-custom.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 use PhpSchool\CliMenu\Input\InputIO;
7 7
 use PhpSchool\CliMenu\MenuStyle;
8 8
 
9
-require_once(__DIR__ . '/../vendor/autoload.php');
9
+require_once(__DIR__.'/../vendor/autoload.php');
10 10
 
11
-$itemCallable = function (CliMenu $menu) {
11
+$itemCallable = function(CliMenu $menu) {
12 12
     $style = (new MenuStyle())
13 13
         ->setBg('yellow')
14 14
         ->setFg('black');
Please login to merge, or discard this patch.
examples/input-number.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 use PhpSchool\CliMenu\CliMenu;
4 4
 use PhpSchool\CliMenu\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
     $number = $menu->askNumber();
10 10
     $number->getStyle()
11 11
         ->setBg('180')
Please login to merge, or discard this patch.
examples/borders.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 use PhpSchool\CliMenu\CliMenu;
4 4
 use PhpSchool\CliMenu\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
 
Please login to merge, or discard this patch.
src/CliMenuBuilder.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -5,12 +5,9 @@
 block discarded – undo
5 5
 use PhpSchool\CliMenu\Action\ExitAction;
6 6
 use PhpSchool\CliMenu\Action\GoBackAction;
7 7
 use PhpSchool\CliMenu\MenuItem\AsciiArtItem;
8
-use PhpSchool\CliMenu\MenuItem\LineBreakItem;
9 8
 use PhpSchool\CliMenu\MenuItem\MenuItemInterface;
10
-use PhpSchool\CliMenu\MenuItem\MenuMenuItem;
11 9
 use PhpSchool\CliMenu\MenuItem\SelectableItem;
12 10
 use PhpSchool\CliMenu\MenuItem\SplitItem;
13
-use PhpSchool\CliMenu\MenuItem\StaticItem;
14 11
 use PhpSchool\CliMenu\Terminal\TerminalFactory;
15 12
 use PhpSchool\CliMenu\Util\ColourUtil;
16 13
 use PhpSchool\Terminal\Terminal;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
     private function itemsHaveExtra(array $items) : bool
371 371
     {
372
-        return !empty(array_filter($items, function (MenuItemInterface $item) {
372
+        return !empty(array_filter($items, function(MenuItemInterface $item) {
373 373
             return $item->showsItemExtra();
374 374
         }));
375 375
     }
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
             throw new RuntimeException(sprintf('Menu: "%s" cannot be retrieved until menu has been built', $id));
425 425
         }
426 426
 
427
-        return $this->subMenus['submenu-placeholder-' . $id];
427
+        return $this->subMenus['submenu-placeholder-'.$id];
428 428
     }
429 429
     
430 430
     private function buildSplitItems(array $items) : array
431 431
     {
432
-        return array_map(function ($item) {
432
+        return array_map(function($item) {
433 433
             if (!is_string($item) || 0 !== strpos($item, 'splititem-placeholder-')) {
434 434
                 return $item;
435 435
             }
Please login to merge, or discard this patch.
src/MenuItem/SplitItem.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,9 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpSchool\CliMenu\MenuItem;
4 4
 
5
-use Assert\Assertion;
6 5
 use PhpSchool\CliMenu\CliMenu;
7
-use PhpSchool\CliMenu\CliMenuBuilder;
8 6
 use PhpSchool\CliMenu\MenuStyle;
9 7
 use PhpSchool\CliMenu\Util\StringUtil;
10 8
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
             $this->setDefaultSelectedItem();
109 109
         }
110 110
 
111
-        $length        = floor($style->getContentWidth() / $numberOfItems) - $this->margin;
112
-        $missingLength = $style->getContentWidth() % $numberOfItems;
111
+        $length        = floor($style->getContentWidth()/$numberOfItems) - $this->margin;
112
+        $missingLength = $style->getContentWidth()%$numberOfItems;
113 113
         
114 114
         return $this->buildRows(
115
-            array_map(function ($index, $item) use ($selected, $length, $style) {
115
+            array_map(function($index, $item) use ($selected, $length, $style) {
116 116
                 $isSelected = $selected && $index === $this->selectedItemIndex;
117 117
                 $marker = $item->canSelect()
118 118
                     ? sprintf('%s ', $style->getMarker($isSelected))
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     private function buildRows(array $cells, int $missingLength, int $length) : array
134 134
     {
135 135
         return array_map(
136
-            function ($i) use ($cells, $length, $missingLength) {
136
+            function($i) use ($cells, $length, $missingLength) {
137 137
                 return $this->buildRow($cells, $i, $length, $missingLength);
138 138
             },
139 139
             range(0, max(array_map('count', $cells)) - 1)
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             implode(
148 148
                 '',
149 149
                 array_map(
150
-                    function ($cell) use ($index, $length) {
150
+                    function($cell) use ($index, $length) {
151 151
                         return $cell[$index] ?? str_repeat(' ', $length + $this->margin);
152 152
                     },
153 153
                     $cells
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
     private function buildCell(array $content, int $length, MenuStyle $style, bool $isSelected) : array
161 161
     {
162
-        return array_map(function ($row) use ($length, $style, $isSelected) {
162
+        return array_map(function($row) use ($length, $style, $isSelected) {
163 163
             $invertedColoursSetCode = $isSelected
164 164
                 ? $style->getInvertedColoursSetCode()
165 165
                 : '';
Please login to merge, or discard this patch.
examples/split-item.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@
 block discarded – undo
3 3
 use PhpSchool\CliMenu\CliMenu;
4 4
 use PhpSchool\CliMenu\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
 
Please login to merge, or discard this patch.
src/BuilderUtils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function addSubMenu(string $name, CliMenuBuilder $subMenuBuilder = null) : Builder
66 66
     {
67
-        $this->menuItems[]  = $id = 'submenu-placeholder-' . $name;
67
+        $this->menuItems[] = $id = 'submenu-placeholder-'.$name;
68 68
 
69 69
         if (null === $subMenuBuilder) {
70 70
             $this->subMenuBuilders[$id] = new CliMenuBuilder($this);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     private function buildSubMenus(array $items) : array
79 79
     {
80
-        return array_map(function ($item) {
80
+        return array_map(function($item) {
81 81
             if (!is_string($item) || 0 !== strpos($item, 'submenu-placeholder-')) {
82 82
                 return $item;
83 83
             }
Please login to merge, or discard this patch.