Completed
Push — master ( 306131...5909ec )
by Aydin
06:33 queued 03:57
created
examples/crazy-redraw.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 use PhpSchool\CliMenu\MenuItem\LineBreakItem;
6 6
 use PhpSchool\CliMenu\MenuItem\MenuItemInterface;
7 7
 
8
-require_once(__DIR__ . '/../vendor/autoload.php');
8
+require_once(__DIR__.'/../vendor/autoload.php');
9 9
 
10
-$itemCallable = function (CliMenu $menu) {
11
-    $colour = function () {
10
+$itemCallable = function(CliMenu $menu) {
11
+    $colour = function() {
12 12
         return array_rand(array_flip(['blue', 'green', 'red', 'yellow']));
13 13
     };
14
-    $int = function () {
14
+    $int = function() {
15 15
         return rand(1, 20);
16 16
     };
17 17
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
     $items = $menu->getItems();
28 28
     
29
-    array_walk($items, function (MenuItemInterface $item) use ($menu) {
29
+    array_walk($items, function(MenuItemInterface $item) use ($menu) {
30 30
         $menu->removeItem($item);
31 31
     });
32 32
 
33
-    $items = array_filter($items, function (MenuItemInterface $item) {
33
+    $items = array_filter($items, function(MenuItemInterface $item) {
34 34
         return !$item instanceof LineBreakItem;
35 35
     });
36 36
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     array_walk(
43 43
         $items,
44
-        function (MenuItemInterface $item) use ($menu) {
44
+        function(MenuItemInterface $item) use ($menu) {
45 45
             $menu->addItem($item);
46 46
         }
47 47
     );
Please login to merge, or discard this patch.
src/MenuItem/SelectableTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
             )
46 46
         );
47 47
 
48
-        return array_map(function ($row, $key) use ($style, $length) {
48
+        return array_map(function($row, $key) use ($style, $length) {
49 49
             $text = $this->disabled ? $style->getDisabledItemText($row) : $row;
50 50
 
51 51
             if ($key === 0) {
Please login to merge, or discard this patch.
src/Input/Number.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,11 +79,11 @@
 block discarded – undo
79 79
 
80 80
     public function ask() : InputResult
81 81
     {
82
-        $this->inputIO->registerControlCallback(InputCharacter::UP, function (string $input) {
82
+        $this->inputIO->registerControlCallback(InputCharacter::UP, function(string $input) {
83 83
             return $this->validate($input) ? $input + 1 : $input;
84 84
         });
85 85
 
86
-        $this->inputIO->registerControlCallback(InputCharacter::DOWN, function (string $input) {
86
+        $this->inputIO->registerControlCallback(InputCharacter::DOWN, function(string $input) {
87 87
             return $this->validate($input) ? $input - 1 : $input;
88 88
         });
89 89
 
Please login to merge, or discard this patch.
src/Dialogue/Confirm.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
         $this->emptyRow();
37 37
 
38 38
         $confirmText = sprintf(' < %s > ', $confirmText);
39
-        $leftFill    = ($promptWidth / 2) - (mb_strlen($confirmText) / 2);
39
+        $leftFill    = ($promptWidth/2) - (mb_strlen($confirmText)/2);
40 40
 
41 41
         $this->write(sprintf(
42 42
             "%s%s%s%s%s%s%s\n",
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\Util\ColourUtil;
8 7
 use PhpSchool\Terminal\Terminal;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
     protected function calculateContentWidth() : void
314 314
     {
315 315
         $this->contentWidth = $this->width
316
-            - ($this->paddingLeftRight * 2)
316
+            - ($this->paddingLeftRight*2)
317 317
             - ($this->borderRightWidth + $this->borderLeftWidth);
318 318
 
319 319
         if ($this->contentWidth < 0) {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
     public function setMarginAuto() : self
467 467
     {
468 468
         $this->marginAuto = true;
469
-        $this->margin = floor(($this->terminal->getWidth() - $this->width) / 2);
469
+        $this->margin = floor(($this->terminal->getWidth() - $this->width)/2);
470 470
 
471 471
         $this->generateBorderRows();
472 472
         $this->generatePaddingTopBottomRows();
Please login to merge, or discard this patch.
src/Input/InputIO.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         return max(
100 100
             array_map(
101
-                function (string $line) {
101
+                function(string $line) {
102 102
                     return mb_strlen($line);
103 103
                 },
104 104
                 $lines
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
     {
111 111
         $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. empty
112 112
 
113
-        return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1;
113
+        return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1;
114 114
     }
115 115
 
116 116
     private function calculateYPositionWithError() : int
117 117
     {
118 118
         $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty
119 119
 
120
-        return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1;
120
+        return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1;
121 121
     }
122 122
 
123 123
     private function calculateXPosition(Input $input, string $userInput) : int
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
         );
132 132
 
133 133
         $parentStyle     = $this->parentMenu->getStyle();
134
-        $halfWidth       = ($width + ($input->getStyle()->getPaddingLeftRight() * 2)) / 2;
135
-        $parentHalfWidth = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin());
134
+        $halfWidth       = ($width + ($input->getStyle()->getPaddingLeftRight()*2))/2;
135
+        $parentHalfWidth = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin());
136 136
 
137 137
         return $parentHalfWidth - $halfWidth;
138 138
     }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         );
165 165
 
166 166
         $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text));
167
-        $leftFill   = ($width / 2) - ($textLength / 2);
167
+        $leftFill   = ($width/2) - ($textLength/2);
168 168
         $rightFill  = ceil($width - $leftFill - $textLength);
169 169
 
170 170
         $this->drawLine(
Please login to merge, or discard this patch.
src/Dialogue/Dialogue.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@
 block discarded – undo
69 69
     {
70 70
         //y
71 71
         $textLines          = count(explode("\n", $this->text)) + 2;
72
-        $this->y            = ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($textLines / 2) + 1;
72
+        $this->y            = ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($textLines/2) + 1;
73 73
 
74 74
         //x
75 75
         $parentStyle        = $this->parentMenu->getStyle();
76
-        $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight() * 2)) / 2;
77
-        $widthHalfLength    = ceil($parentStyle->getWidth() / 2 + $parentStyle->getMargin());
76
+        $dialogueHalfLength = (mb_strlen($this->text) + ($this->style->getPaddingLeftRight()*2))/2;
77
+        $widthHalfLength    = ceil($parentStyle->getWidth()/2 + $parentStyle->getMargin());
78 78
         $this->x            = $widthHalfLength - $dialogueHalfLength;
79 79
     }
80 80
 
Please login to merge, or discard this patch.
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.
src/CliMenu.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                 : $this->selectedItem++;
286 286
 
287 287
             if (!array_key_exists($this->selectedItem, $this->items)) {
288
-                $this->selectedItem  = $direction === 'UP'
288
+                $this->selectedItem = $direction === 'UP'
289 289
                     ? end($itemKeys)
290 290
                     : reset($itemKeys);
291 291
             }
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
             $frame->addRows($this->drawMenuItem(new LineBreakItem($this->style->getTitleSeparator())));
388 388
         }
389 389
 
390
-        array_map(function ($item, $index) use ($frame) {
390
+        array_map(function($item, $index) use ($frame) {
391 391
             $frame->addRows($this->drawMenuItem($item, $index === $this->selectedItem));
392 392
         }, $this->items, array_keys($this->items));
393 393
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             $borderColour = '';
439 439
         }
440 440
 
441
-        return array_map(function ($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) {
441
+        return array_map(function($row) use ($invertedColoursSetCode, $invertedColoursUnsetCode, $borderColour) {
442 442
             return sprintf(
443 443
                 "%s%s%s%s%s%s%s%s%s%s%s%s\n",
444 444
                 str_repeat(' ', $this->style->getMargin()),
Please login to merge, or discard this patch.