當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProgressBar::getMessage方法代碼示例

本文整理匯總了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'));
 }
開發者ID:gjb2048,項目名稱:moodle-plugin-ci,代碼行數:14,代碼來源:InstallOutputTest.php

示例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;
 }
開發者ID:sgc-fireball,項目名稱:libphp,代碼行數:52,代碼來源:Validator.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar::getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。