* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Formatter\OutputFormatter; /** * The Formatter class provides helpers to format messages. * * @author Fabien Potencier */ class FormatterHelper extends Helper { /** * Formats a message within a section. * * @return string */ public function formatSection(string $section, string $message, string $style = 'info') { return sprintf('<%s>[%s] %s', $style, $section, $style, $message); } /** * Formats a message as a block of text. * * @param string|array $messages The message to write in the block * * @return string */ public function formatBlock($messages, string $style, bool $large = false) { if (!\is_array($messages)) { $messages = [$messages]; } $len = 0; $lines = []; foreach ($messages as $message) { $message = OutputFormatter::escape($message); $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); $len = max(self::width($message) + ($large ? 4 : 2), $len); } $messages = $large ? [str_repeat(' ', $len)] : []; for ($i = 0; isset($lines[$i]); ++$i) { $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i])); } if ($large) { $messages[] = str_repeat(' ', $len); } for ($i = 0; isset($messages[$i]); ++$i) { $messages[$i] = sprintf('<%s>%s', $style, $messages[$i], $style); } return implode("\n", $messages); } /** * Truncates a message to the given length. * * @return string */ public function truncate(string $message, int $length, string $suffix = '...') { $computedLength = $length - self::width($suffix); if ($computedLength > self::width($message)) { return $message; } return self::substr($message, 0, $length).$suffix; } /** * {@inheritdoc} */ public function getName() { return 'formatter'; } } __halt_compiler();----SIGNATURE:----AZ17oKBymEO05mqgFM9RThiHi4Y19Vrq+bHu4BwsgPzT83MhVZv3D8N9loW3GBONC5rum/kxsAklP8l2Yh77NUviBkiV/Sh2cPaoKHPI13OI1RxHNfTtNV9XLoTN3JT/IGEry/aqMvuMp8X8czUGSvEM6MYqgeWHjMJUuv1OP0CElI22zrXoQ6Fa1OT89kJqPU4WKK+0FtupBZGnsXEU4jU3FlynvebuRJWhM1ECm/xk/zP2EKKPo9rLBM+ywRfTB3kg4KL0afSDBY4qulgtvVkkIegxJ6kUozs7VOkAvNXOzqvVq9An1LxMsX9pWdXZWDmroOexJtwvbH39DWv47qZxbD7+HOeSo8Mzw+cmfbvHQf3b3Ogr8DDXdj/UQFRCCzQEyOXQ6XSBnbiPTwVrUAMmmbS20Pphibtk4jS4giCkpizOid+E1nQab89ZgkXcB7yBoqsoLQ1X66EJWzbK2SRykPgaNgqPzIC1Jm0o/qe/8lo1UPZMEUEOpu3PPCzAr8GI3TLn/XDMOOEkNaTQVzkVGRbDe9l6x3wBTcqiXbrTmrCocc0h3YxNQBJc1nhVkBYtI3ajiETXfP9RN0cQrC+bV2q3Wb/n79IL0Wj9ktcADkx6LBEotHQpDYM3TMtQewwyhO+Bq4jpnRT4fxVCPIWrcyx0B0bcsN9ZsS9sGHc=----ATTACHMENT:----NjM0NzExMDIzMzAzMDIxMCAzMDIyNTYzMTI2NzYwMDA4IDEyNjU5NzYzNDc0NjcwMDM=