@@ -14,7 +14,7 @@ |
||
14 | 14 | public static function wordwrap(string $str, int $width, string $break = "\n") : string |
15 | 15 | { |
16 | 16 | $length = 0; |
17 | - return implode(' ', array_map(function ($word) use (&$length, $width, $break) { |
|
17 | + return implode(' ', array_map(function($word) use (&$length, $width, $break) { |
|
18 | 18 | $length += (mb_strlen($word) + 1); |
19 | 19 | |
20 | 20 | if ($length > $width) { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | private function itemsHaveExtra(array $items) : bool |
285 | 285 | { |
286 | - return !empty(array_filter($items, function (MenuItemInterface $item) { |
|
286 | + return !empty(array_filter($items, function(MenuItemInterface $item) { |
|
287 | 287 | return $item->showsItemExtra(); |
288 | 288 | })); |
289 | 289 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | private function buildSubMenus(array $items) : array |
350 | 350 | { |
351 | - return array_map(function ($item) { |
|
351 | + return array_map(function($item) { |
|
352 | 352 | if (!is_string($item)) { |
353 | 353 | return $item; |
354 | 354 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * Get terminal details |
12 | 12 | */ |
13 | - public function getDetails() : string ; |
|
13 | + public function getDetails() : string; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Get the available width of the terminal |
@@ -23,9 +23,9 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function addRows(array $params = []) : void |
26 | - { |
|
27 | - list($rows, $item) = $params; |
|
28 | - $item->setStartRowNumber(count($this->rows)); |
|
26 | + { |
|
27 | + list($rows, $item) = $params; |
|
28 | + $item->setStartRowNumber(count($this->rows)); |
|
29 | 29 | foreach ($rows as $row) { |
30 | 30 | $this->rows[] = $row; |
31 | 31 | } |
@@ -16,52 +16,52 @@ |
||
16 | 16 | */ |
17 | 17 | private $text; |
18 | 18 | |
19 | - /** |
|
20 | - * @var int |
|
21 | - */ |
|
22 | - private $numberOfRows = 0; |
|
19 | + /** |
|
20 | + * @var int |
|
21 | + */ |
|
22 | + private $numberOfRows = 0; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var int |
|
26 | - */ |
|
27 | - private $startRowNumber = 0; |
|
24 | + /** |
|
25 | + * @var int |
|
26 | + */ |
|
27 | + private $startRowNumber = 0; |
|
28 | 28 | |
29 | 29 | public function __construct(string $text) |
30 | 30 | { |
31 | 31 | $this->text = $text; |
32 | 32 | } |
33 | 33 | |
34 | - /** |
|
35 | - * Returns the number of terminal rows the item takes |
|
36 | - */ |
|
37 | - public function getNumberOfRows() { |
|
38 | - return $this->numberOfRows; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Sets the row number the item starts at in the frame |
|
43 | - */ |
|
44 | - public function setStartRowNumber(int $rowNumber) { |
|
45 | - $this->startRowNumber = $rowNumber; |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Returns the row number the item starts at in the frame |
|
50 | - */ |
|
51 | - public function getStartRowNumber() { |
|
52 | - return $this->startRowNumber; |
|
53 | - } |
|
34 | + /** |
|
35 | + * Returns the number of terminal rows the item takes |
|
36 | + */ |
|
37 | + public function getNumberOfRows() { |
|
38 | + return $this->numberOfRows; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Sets the row number the item starts at in the frame |
|
43 | + */ |
|
44 | + public function setStartRowNumber(int $rowNumber) { |
|
45 | + $this->startRowNumber = $rowNumber; |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Returns the row number the item starts at in the frame |
|
50 | + */ |
|
51 | + public function getStartRowNumber() { |
|
52 | + return $this->startRowNumber; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * The output text for the item |
57 | 57 | */ |
58 | 58 | public function getRows(MenuStyle $style, bool $selected = false) : array |
59 | 59 | { |
60 | - $rows = explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth())); |
|
60 | + $rows = explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth())); |
|
61 | 61 | |
62 | - $this->numberOfRows = count($rows); |
|
62 | + $this->numberOfRows = count($rows); |
|
63 | 63 | |
64 | - return $rows; |
|
64 | + return $rows; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -23,38 +23,38 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @var bool |
25 | 25 | */ |
26 | - private $disabled = false; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var int |
|
30 | - */ |
|
31 | - private $numberOfRows = 0; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var int |
|
35 | - */ |
|
36 | - private $startRowNumber = 0; |
|
37 | - |
|
38 | - /** |
|
39 | - * Returns the number of terminal rows the item takes |
|
40 | - */ |
|
41 | - public function getNumberOfRows() { |
|
42 | - return $this->numberOfRows; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Sets the row number the item starts at in the frame |
|
47 | - */ |
|
48 | - public function setStartRowNumber(int $rowNumber) { |
|
49 | - $this->startRowNumber = $rowNumber; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Returns the row number the item starts at in the frame |
|
54 | - */ |
|
55 | - public function getStartRowNumber() { |
|
56 | - return $this->startRowNumber; |
|
57 | - } |
|
26 | + private $disabled = false; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var int |
|
30 | + */ |
|
31 | + private $numberOfRows = 0; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var int |
|
35 | + */ |
|
36 | + private $startRowNumber = 0; |
|
37 | + |
|
38 | + /** |
|
39 | + * Returns the number of terminal rows the item takes |
|
40 | + */ |
|
41 | + public function getNumberOfRows() { |
|
42 | + return $this->numberOfRows; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Sets the row number the item starts at in the frame |
|
47 | + */ |
|
48 | + public function setStartRowNumber(int $rowNumber) { |
|
49 | + $this->startRowNumber = $rowNumber; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Returns the row number the item starts at in the frame |
|
54 | + */ |
|
55 | + public function getStartRowNumber() { |
|
56 | + return $this->startRowNumber; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * The output text for the item |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | $length, |
75 | 75 | sprintf("\n%s", str_repeat(' ', mb_strlen($marker))) |
76 | 76 | ) |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - $this->numberOfRows = count($rows); |
|
79 | + $this->numberOfRows = count($rows); |
|
80 | 80 | |
81 | 81 | return array_map(function ($row, $key) use ($style, $length) { |
82 | 82 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
@@ -78,7 +78,7 @@ |
||
78 | 78 | |
79 | 79 | $this->numberOfRows = count($rows); |
80 | 80 | |
81 | - return array_map(function ($row, $key) use ($style, $length) { |
|
81 | + return array_map(function($row, $key) use ($style, $length) { |
|
82 | 82 | $text = $this->disabled ? $style->getDisabledItemText($row) : $row; |
83 | 83 | |
84 | 84 | if ($key === 0) { |
@@ -9,20 +9,20 @@ |
||
9 | 9 | */ |
10 | 10 | interface MenuItemInterface |
11 | 11 | { |
12 | - /** |
|
13 | - * Returns the number of terminal rows the item takes |
|
14 | - */ |
|
15 | - public function getNumberOfRows() : int; |
|
16 | - |
|
17 | - /** |
|
18 | - * Sets the row number the item starts at in the frame |
|
19 | - */ |
|
20 | - public function setStartRowNumber(int $rowNumber) : void; |
|
21 | - |
|
22 | - /** |
|
23 | - * Returns the row number the item starts at in the frame |
|
24 | - */ |
|
25 | - public function getStartRowNumber() : int; |
|
12 | + /** |
|
13 | + * Returns the number of terminal rows the item takes |
|
14 | + */ |
|
15 | + public function getNumberOfRows() : int; |
|
16 | + |
|
17 | + /** |
|
18 | + * Sets the row number the item starts at in the frame |
|
19 | + */ |
|
20 | + public function setStartRowNumber(int $rowNumber) : void; |
|
21 | + |
|
22 | + /** |
|
23 | + * Returns the row number the item starts at in the frame |
|
24 | + */ |
|
25 | + public function getStartRowNumber() : int; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * The output text for the item |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $lines; |
22 | 22 | |
23 | - /** |
|
24 | - * @var int |
|
25 | - */ |
|
26 | - private $numberOfRows = 0; |
|
23 | + /** |
|
24 | + * @var int |
|
25 | + */ |
|
26 | + private $numberOfRows = 0; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var int |
|
30 | - */ |
|
31 | - private $startRowNumber = 0; |
|
28 | + /** |
|
29 | + * @var int |
|
30 | + */ |
|
31 | + private $startRowNumber = 0; |
|
32 | 32 | |
33 | 33 | public function __construct(string $breakChar = ' ', int $lines = 1) |
34 | 34 | { |
@@ -36,26 +36,26 @@ discard block |
||
36 | 36 | $this->lines = $lines; |
37 | 37 | } |
38 | 38 | |
39 | - /** |
|
40 | - * Returns the number of terminal rows the item takes |
|
41 | - */ |
|
42 | - public function getNumberOfRows() { |
|
43 | - return $this->numberOfRows; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Sets the row number the item starts at in the frame |
|
48 | - */ |
|
49 | - public function setStartRowNumber(int $rowNumber) { |
|
50 | - $this->startRowNumber = $rowNumber; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Returns the row number the item starts at in the frame |
|
55 | - */ |
|
56 | - public function getStartRowNumber() { |
|
57 | - return $this->startRowNumber; |
|
58 | - } |
|
39 | + /** |
|
40 | + * Returns the number of terminal rows the item takes |
|
41 | + */ |
|
42 | + public function getNumberOfRows() { |
|
43 | + return $this->numberOfRows; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Sets the row number the item starts at in the frame |
|
48 | + */ |
|
49 | + public function setStartRowNumber(int $rowNumber) { |
|
50 | + $this->startRowNumber = $rowNumber; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Returns the row number the item starts at in the frame |
|
55 | + */ |
|
56 | + public function getStartRowNumber() { |
|
57 | + return $this->startRowNumber; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * The output text for the item |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | ), $this->lines)) |
71 | 71 | ); |
72 | 72 | |
73 | - $this->numberOfRows = count($rows); |
|
73 | + $this->numberOfRows = count($rows); |
|
74 | 74 | |
75 | - return $rows; |
|
75 | + return $rows; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private $artLength; |
34 | 34 | |
35 | - /** |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - private $numberOfRows = 0; |
|
35 | + /** |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + private $numberOfRows = 0; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var int |
|
42 | - */ |
|
43 | - private $startRowNumber = 0; |
|
40 | + /** |
|
41 | + * @var int |
|
42 | + */ |
|
43 | + private $startRowNumber = 0; |
|
44 | 44 | |
45 | 45 | public function __construct(string $text, string $position = self::POSITION_CENTER) |
46 | 46 | { |
@@ -51,26 +51,26 @@ discard block |
||
51 | 51 | $this->artLength = max(array_map('mb_strlen', explode("\n", $text))); |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Returns the number of terminal rows the item takes |
|
56 | - */ |
|
57 | - public function getNumberOfRows() { |
|
58 | - return $this->numberOfRows; |
|
59 | - } |
|
54 | + /** |
|
55 | + * Returns the number of terminal rows the item takes |
|
56 | + */ |
|
57 | + public function getNumberOfRows() { |
|
58 | + return $this->numberOfRows; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Sets the row number the item starts at in the frame |
|
63 | - */ |
|
64 | - public function setStartRowNumber(int $rowNumber) { |
|
65 | - $this->startRowNumber = $rowNumber; |
|
66 | - } |
|
61 | + /** |
|
62 | + * Sets the row number the item starts at in the frame |
|
63 | + */ |
|
64 | + public function setStartRowNumber(int $rowNumber) { |
|
65 | + $this->startRowNumber = $rowNumber; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns the row number the item starts at in the frame |
|
70 | - */ |
|
71 | - public function getStartRowNumber() { |
|
72 | - return $this->startRowNumber; |
|
73 | - } |
|
68 | + /** |
|
69 | + * Returns the row number the item starts at in the frame |
|
70 | + */ |
|
71 | + public function getStartRowNumber() { |
|
72 | + return $this->startRowNumber; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * The output text for the item |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | return $row; |
105 | - }, explode("\n", $this->text)); |
|
105 | + }, explode("\n", $this->text)); |
|
106 | 106 | |
107 | - $this->numberOfRows = count($rows); |
|
107 | + $this->numberOfRows = count($rows); |
|
108 | 108 | |
109 | - return $rows; |
|
109 | + return $rows; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -77,7 +77,7 @@ |
||
77 | 77 | */ |
78 | 78 | public function getRows(MenuStyle $style, bool $selected = false) : array |
79 | 79 | { |
80 | - $rows = array_map(function ($row) use ($style) { |
|
80 | + $rows = array_map(function($row) use ($style) { |
|
81 | 81 | $length = mb_strlen($row); |
82 | 82 | |
83 | 83 | $padding = $style->getContentWidth() - $length; |