Completed
Pull Request — master (#82)
by
unknown
01:49
created
examples/ascii-art.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 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 8
 $art = <<<ART
9 9
         _ __ _
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 LEARNING FOR ELEPHPANTS
16 16
 ART;
17 17
 
18
-$itemCallable = function (CliMenu $menu) {
18
+$itemCallable = function(CliMenu $menu) {
19 19
     echo $menu->getSelectedItem()->getText();
20 20
 };
21 21
 
Please login to merge, or discard this patch.
examples/basic-separation.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.
examples/remove-defaults.php 1 patch
Spacing   +3 added lines, -3 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\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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     ->addItem('Second Item', $itemCallable)
16 16
     ->addItem('Third Item', $itemCallable)
17 17
     ->disableDefaultItems()
18
-    ->addItem('CUSTOM CLOSE', function (CliMenu $menu) {
18
+    ->addItem('CUSTOM CLOSE', function(CliMenu $menu) {
19 19
         $menu->close();
20 20
     })
21 21
     ->build();
Please login to merge, or discard this patch.
examples/submenu.php 1 patch
Spacing   +3 added lines, -3 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\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,7 +16,7 @@  discard block
 block discarded – undo
16 16
     ->addLineBreak('-')
17 17
     ->addSubMenu('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
         ->addLineBreak('-')
Please login to merge, or discard this patch.
examples/useful-separation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@
 block discarded – undo
4 4
 use PhpSchool\CliMenu\CliMenuBuilder;
5 5
 use PhpSchool\CliMenu\MenuItem\MenuItem;
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
 
Please login to merge, or discard this patch.
src/Terminal/UnixTerminal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
             exec('stty -icanon');
107 107
             $this->isCanonical = true;
108 108
         } else {
109
-            exec('stty ' . $this->getOriginalConfiguration());
109
+            exec('stty '.$this->getOriginalConfiguration());
110 110
             $this->isCanonical = false;
111 111
         }
112 112
     }
Please login to merge, or discard this patch.
src/CliMenu.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpSchool\CliMenu;
4 4
 
5
-use PhpSchool\CliMenu\Exception\InvalidInstantiationException;
6 5
 use PhpSchool\CliMenu\Exception\InvalidTerminalException;
7 6
 use PhpSchool\CliMenu\Exception\MenuNotOpenException;
8 7
 use PhpSchool\CliMenu\MenuItem\LineBreakItem;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@
 block discarded – undo
59 59
      */
60 60
     private $currentFrame;
61 61
 
62
+    /**
63
+     * @param string $title
64
+     */
62 65
     public function __construct(
63 66
         ?string $title,
64 67
         array $items,
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                 : $this->selectedItem++;
193 193
 
194 194
             if (!array_key_exists($this->selectedItem, $this->items)) {
195
-                $this->selectedItem  = $direction === 'up'
195
+                $this->selectedItem = $direction === 'up'
196 196
                     ? end($itemKeys)
197 197
                     : reset($itemKeys);
198 198
             } elseif ($this->getSelectedItem()->canSelect()) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator())));
248 248
         }
249 249
 
250
-        array_map(function ($item, $index) use ($frame) {
250
+        array_map(function($item, $index) use ($frame) {
251 251
             $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem));
252 252
         }, $this->items, array_keys($this->items));
253 253
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             ? $this->style->getSelectedUnsetCode()
297 297
             : $this->style->getUnselectedUnsetCode();
298 298
 
299
-        $rows = array_map(function ($row) use ($setColour, $unsetColour) {
299
+        $rows = array_map(function($row) use ($setColour, $unsetColour) {
300 300
             return sprintf(
301 301
                 "%s%s%s%s%s%s%s\n\r",
302 302
                 str_repeat(' ', $this->style->getMargin()),
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
             );
310 310
         }, $rows);
311 311
 
312
-        $item->setNumberOfRows( count( $rows ) );
312
+        $item->setNumberOfRows(count($rows));
313 313
 
314
-        return array( $rows, $item );
314
+        return array($rows, $item);
315 315
     }
316 316
 
317 317
     /**
Please login to merge, or discard this patch.
src/MenuStyle.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpSchool\CliMenu;
4 4
 
5
-use PhpSchool\CliMenu\Exception\InvalidInstantiationException;
6 5
 use PhpSchool\CliMenu\Terminal\TerminalFactory;
7 6
 use PhpSchool\CliMenu\Terminal\TerminalInterface;
8 7
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
 
268 268
     public function setWidth(int $width) : self
269 269
     {
270
-        $availableWidth = $this->terminal->getWidth() - ($this->margin * 2) - ($this->padding * 2);
270
+        $availableWidth = $this->terminal->getWidth() - ($this->margin*2) - ($this->padding*2);
271 271
 
272 272
         if ($width >= $availableWidth) {
273 273
             $width = $availableWidth;
Please login to merge, or discard this patch.
examples/toggle-item-extra.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 use PhpSchool\CliMenu\CliMenuBuilder;
5 5
 use PhpSchool\CliMenu\MenuItem\MenuItemInterface;
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
     static $i = 1;
11 11
 
12 12
     foreach ($menu->getItems() as $item) {
13
-        $i % 2 === 0
13
+        $i%2 === 0
14 14
             ? $item->showItemExtra()
15 15
             : $item->hideItemExtra();
16 16
 
Please login to merge, or discard this patch.