Completed
Pull Request — master (#78)
by Aydin
02:26
created
examples/confirm.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
     $menu->confirm('PHP School FTW!')
10 10
         ->display('OK');
11 11
 };
Please login to merge, or discard this patch.
examples/disabled-items.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/MenuItem/SelectableTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             )
53 53
         );
54 54
 
55
-        return array_map(function ($row, $key) use ($style, $marker, $length) {
55
+        return array_map(function($row, $key) use ($style, $marker, $length) {
56 56
             $text = $this->disabled ? $style->getDisabledItemText($row) : $row;
57 57
 
58 58
             if ($key === 0) {
Please login to merge, or discard this patch.
examples/basic.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,20 +3,20 @@
 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
 
12 12
 $menu = (new CliMenuBuilder)
13 13
     ->setTitle('Basic CLI Menu')
14 14
     ->addItem('First Item', $itemCallable)
15
-    ->addItem('Second Item', function (CliMenu $menu) {
15
+    ->addItem('Second Item', function(CliMenu $menu) {
16 16
         $menu->getStyle()->setBg('red');
17 17
         $menu->redraw();
18 18
     })
19
-    ->addItem('Third Item', function (CliMenu $menu) {
19
+    ->addItem('Third Item', function(CliMenu $menu) {
20 20
         $menu->getStyle()->setBg('default');
21 21
         $menu->redraw();
22 22
     })
Please login to merge, or discard this patch.
examples/input-password.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
     $result = $menu->askPassword()
10 10
         ->setPlaceholderText('')
11 11
         ->ask();
Please login to merge, or discard this patch.
examples/input-text.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
     $result = $menu->askText()
10 10
         ->setPlaceholderText('Enter something here')
11 11
         ->ask();
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
     $result = $menu->askNumber()
10 10
         ->setPlaceholderText(10)
11 11
         ->ask();
Please login to merge, or discard this patch.
examples/input-advanced.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
     $username = $menu->askText()
10 10
         ->setPromptText('Enter username')
11 11
         ->setPlaceholderText('alice')
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
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     {
106 106
         return max(
107 107
             array_map(
108
-                function (string $line) {
108
+                function(string $line) {
109 109
                     return mb_strlen($line);
110 110
                 },
111 111
                 $lines
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $lines = 5; //1. empty 2. prompt text 3. empty 4. input 5. 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 calculateYPositionWithError() : int
124 124
     {
125 125
         $lines = 7; //1. empty 2. prompt text 3. empty 4. input 5. empty 6. error 7. empty
126 126
 
127
-        return ceil($this->parentMenu->getCurrentFrame()->count() / 2) - ceil($lines /2) + 1;
127
+        return ceil($this->parentMenu->getCurrentFrame()->count()/2) - ceil($lines/2) + 1;
128 128
     }
129 129
 
130 130
     private function calculateXPosition(Input $input, string $userInput) : int
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
         );
139 139
 
140 140
         $parentStyle     = $this->parentMenu->getStyle();
141
-        $halfWidth       = ($width + ($this->style->getPadding() * 2)) / 2;
142
-        $parentHalfWidth = ceil($parentStyle->getWidth() / 2);
141
+        $halfWidth       = ($width + ($this->style->getPadding()*2))/2;
142
+        $parentHalfWidth = ceil($parentStyle->getWidth()/2);
143 143
 
144 144
         return $parentHalfWidth - $halfWidth;
145 145
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         );
170 170
 
171 171
         $textLength = mb_strlen(StringUtil::stripAnsiEscapeSequence($text));
172
-        $leftFill   = ($width / 2) - ($textLength / 2);
172
+        $leftFill   = ($width/2) - ($textLength/2);
173 173
         $rightFill  = ceil($width - $leftFill - $textLength);
174 174
 
175 175
         $this->drawLine(
Please login to merge, or discard this patch.