本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::getMessage方法的具体用法?PHP ProgressBar::getMessage怎么用?PHP ProgressBar::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProgressBar
public function testProgressBar()
{
$progressBar = new ProgressBar(new NullOutput());
$output = new InstallOutput(null, $progressBar);
$output->start('Start', 5);
$this->assertEquals(5, $progressBar->getMaxSteps());
$this->assertEquals('Start', $progressBar->getMessage('message'));
$output->step('Step 1');
$this->assertEquals(1, $progressBar->getProgress());
$this->assertEquals('Step 1', $progressBar->getMessage('message'));
$output->end('End');
$this->assertEquals(5, $progressBar->getProgress());
$this->assertEquals('End', $progressBar->getMessage('message'));
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!filter_var($this->host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$host = gethostbyname($this->host);
if ($host == $this->host) {
throw new \InvalidArgumentException('Invalid listen address.');
}
$this->host = $host;
}
if ($this->port < 1 || $this->port > 65535) {
throw new \InvalidArgumentException('Invalid port number.');
}
$result = array();
$validator = new SSLValidator();
$protocols = $validator->getProtocols();
$ciphers = $validator->getCiphers();
$length = 0;
array_walk($protocols, function (&$value) use(&$length) {
$length = max($length, strlen($value));
});
array_walk($ciphers, function (&$value) use(&$length) {
$length = max($length, strlen($value));
});
$length += 7;
$progress = new ProgressBar($output, count($ciphers) * count($protocols));
#$progress->setFormat('verbose');
$progress->start();
foreach ($protocols as $protocol) {
if (!isset($result[$protocol])) {
$result[$protocol] = array();
}
foreach ($ciphers as $cipher) {
$progress->setMessage(sprintf('%s %s', str_replace('_', '.', strtoupper($protocol)), strtoupper($cipher)));
if ($validator->verifySingle($this->host, $this->port, $protocol, $cipher)) {
$result[$protocol][] = $cipher;
}
ob_start();
$progress->advance();
$output->write(' ' . str_pad($progress->getMessage(), $length, ' '));
$output->write("\r");
ob_end_clean();
}
}
$progress->finish();
$output->write("\n\n");
foreach ($result as $protocol => &$ciphers) {
foreach ($ciphers as $cipher) {
$output->writeln(sprintf('<info>%s</info> :: <comment>%s</comment>', str_replace('_', '.', strtoupper($protocol)), strtoupper($cipher)));
}
}
return 0;
}