Completed
Pull Request — master (#79)
by Aydin
05:55
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.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 : $this->selectedItem++;
216 216
 
217 217
             if (!array_key_exists($this->selectedItem, $this->items)) {
218
-                $this->selectedItem  = $direction === 'up'
218
+                $this->selectedItem = $direction === 'up'
219 219
                     ? end($itemKeys)
220 220
                     : reset($itemKeys);
221 221
             } elseif ($this->getSelectedItem()->canSelect()) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
             $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator())));
276 276
         }
277 277
 
278
-        array_map(function ($item, $index) use ($frame) {
278
+        array_map(function($item, $index) use ($frame) {
279 279
             $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem));
280 280
         }, $this->items, array_keys($this->items));
281 281
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             ? $this->style->getSelectedUnsetCode()
310 310
             : $this->style->getUnselectedUnsetCode();
311 311
 
312
-        return array_map(function ($row) use ($setColour, $unsetColour) {
312
+        return array_map(function($row) use ($setColour, $unsetColour) {
313 313
             return sprintf(
314 314
                 "%s%s%s%s%s%s%s\n\r",
315 315
                 str_repeat(' ', $this->style->getMargin()),
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.
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.