Skip to content

Commit 32ff204

Browse files
committed
feat: add console default line max length
1 parent 6ce62f7 commit 32ff204

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Console.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ class Console
5858
'light_gray' => '47',
5959
];
6060

61+
/**
62+
* Max default line length.
63+
*
64+
* @var int
65+
*/
66+
public static $maxLineLength = 80;
67+
6168
/**
6269
* Get new line char.
6370
*
@@ -84,8 +91,6 @@ public static function header()
8491
return;
8592
}
8693

87-
$version = Scanner::getVersion();
88-
self::newLine(2);
8994
$header = <<<EOD
9095
█████╗ ███╗ ███╗██╗ ██╗███████╗ ██████╗ █████╗ ███╗ ██╗
9196
██╔══██╗████╗ ████║██║ ██║██╔════╝██╔════╝██╔══██╗████╗ ██║
@@ -95,6 +100,15 @@ public static function header()
95100
╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝
96101
Github: https://github.com/marcocesarato/PHP-Antimalware-Scanner
97102
EOD;
103+
$headerArray = explode("\n", $header);
104+
foreach ($headerArray as $key => $value) {
105+
$diff = strlen($value) - mb_strlen($value);
106+
$headerArray[$key] = str_pad($value, self::$maxLineLength + $diff, ' ', STR_PAD_BOTH);
107+
}
108+
$header = implode(PHP_EOL, $headerArray);
109+
$version = Scanner::getVersion();
110+
111+
self::newLine();
98112
self::displayLine($header, 2, 'green');
99113
$title = self::title('version ' . $version);
100114
self::display($title, 'green');
@@ -132,8 +146,11 @@ public static function header()
132146
*
133147
* @return string
134148
*/
135-
public static function title($text, $char = ' ', $length = 64)
149+
public static function title($text, $char = ' ', $length = null)
136150
{
151+
if ($length === null) {
152+
$length = self::$maxLineLength;
153+
}
137154
$result = '';
138155
$strLength = strlen($text);
139156
$spaces = $length - $strLength;
@@ -528,7 +545,7 @@ public static function helplist($type = null)
528545
*/
529546
public static function wordWrap($text)
530547
{
531-
return wordwrap($text, 80);
548+
return wordwrap($text, self::$maxLineLength);
532549
}
533550

534551
/**

0 commit comments

Comments
 (0)