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


PHP OutputFormatter::format方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Formatter\OutputFormatter::format方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputFormatter::format方法的具體用法?PHP OutputFormatter::format怎麽用?PHP OutputFormatter::format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Formatter\OutputFormatter的用法示例。


在下文中一共展示了OutputFormatter::format方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: removeFormat

 /**
  * {@inheritdoc}
  */
 public function removeFormat($string)
 {
     $this->innerFormatter->setDecorated(false);
     $formatted = $this->innerFormatter->format($string);
     $this->innerFormatter->setDecorated(true);
     return $formatted;
 }
開發者ID:webmozart,項目名稱:console,代碼行數:10,代碼來源:AnsiFormatter.php

示例2: format

 public function format($message)
 {
     $message = preg_replace('/<info>(.*),\\s*(.*)<\\/info>/i', '<info>$2 ($1)</info>', $message);
     $formatted = parent::format($message);
     $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
     return preg_replace_callback("{\\[([0-9;]+)m(.*?)\\[(?:" . $clearEscapeCodes . ";)*?" . $clearEscapeCodes . "m}s", array($this, 'formatHtml'), $formatted);
 }
開發者ID:bookin,項目名稱:yii2-composer-web,代碼行數:7,代碼來源:BootstrapOutputFormatter.php

示例3: testNotDecoratedFormatter

 public function testNotDecoratedFormatter()
 {
     $formatter = new OutputFormatter(false);
     $this->assertTrue($formatter->hasStyle('error'));
     $this->assertTrue($formatter->hasStyle('info'));
     $this->assertTrue($formatter->hasStyle('comment'));
     $this->assertTrue($formatter->hasStyle('question'));
     $this->assertEquals("some error", $formatter->format('<error>some error</error>'));
     $this->assertEquals("some info", $formatter->format('<info>some info</info>'));
     $this->assertEquals("some comment", $formatter->format('<comment>some comment</comment>'));
     $this->assertEquals("some question", $formatter->format('<question>some question</question>'));
     $formatter->setDecorated(true);
     $this->assertEquals("[37;41msome error[0m", $formatter->format('<error>some error</error>'));
     $this->assertEquals("[32msome info[0m", $formatter->format('<info>some info</info>'));
     $this->assertEquals("[33msome comment[0m", $formatter->format('<comment>some comment</comment>'));
     $this->assertEquals("[30;46msome question[0m", $formatter->format('<question>some question</question>'));
 }
開發者ID:RogerWebb,項目名稱:symfony,代碼行數:17,代碼來源:OutputFormatterTest.php

示例4: testContentWithLineBreaks

    public function testContentWithLineBreaks()
    {
        $formatter = new OutputFormatter(true);
        $this->assertEquals(<<<EOF
[32m
some text[0m
EOF
, $formatter->format(<<<EOF
<info>
some text</info>
EOF
));
        $this->assertEquals(<<<EOF
[32msome text
[0m
EOF
, $formatter->format(<<<EOF
<info>some text
</info>
EOF
));
        $this->assertEquals(<<<EOF
[32m
some text
[0m
EOF
, $formatter->format(<<<EOF
<info>
some text
</info>
EOF
));
        $this->assertEquals(<<<EOF
[32m
some text
more text
[0m
EOF
, $formatter->format(<<<EOF
<info>
some text
more text
</info>
EOF
));
    }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:46,代碼來源:OutputFormatterTest.php

示例5: renderCodeCoverage

 private function renderCodeCoverage(array $reportLines, $widestLine)
 {
     $output = '';
     $widestLineNum = mb_strlen(count($reportLines));
     foreach ($reportLines as $i => $line) {
         $source = $this->formatter->escape(str_pad($line['line'], $widestLine));
         $lineNum = str_pad((string) ($i + 1), $widestLineNum, ' ', STR_PAD_LEFT);
         switch ($line['code']) {
             case self::COVERAGE_COVERED:
                 $output .= $this->formatter->format(sprintf('<bg=white;fg=green>[%s] %s</>', $lineNum, $source));
                 break;
             case self::COVERAGE_NOT_COVERED:
                 $output .= $this->formatter->format(sprintf('<bg=white;fg=red>[%s] %s</>', $lineNum, $source));
                 break;
             case self::COVERAGE_META:
                 $output .= $this->formatter->format(sprintf('<bg=white;fg=black>[%s] %s</>', $lineNum, $source));
                 break;
         }
         $output .= PHP_EOL;
     }
     return $output;
 }
開發者ID:addvilz,項目名稱:phpspec-cover,代碼行數:22,代碼來源:Reporter.php

示例6: getMessageFormat

 /**
  * @see Stream::getMessageFormat()
  * @param mixed $level
  * @param array $context
  * @return string
  */
 protected function getMessageFormat($level, array $context = array())
 {
     $parentFormat = parent::getMessageFormat($level, $context);
     $consoleFormat = "<{$level}>{$parentFormat}</{$level}>";
     return $this->formatter->format($consoleFormat);
 }
開發者ID:phlib,項目名稱:logger,代碼行數:12,代碼來源:CliColor.php

示例7: format

 public function format($message)
 {
     $formatted = parent::format($message);
     return preg_replace_callback("{\\[([0-9;]+)m(.*?)\\[0m}s", array($this, 'formatHtml'), $formatted);
 }
開發者ID:Flesh192,項目名稱:magento,代碼行數:5,代碼來源:HtmlOutputFormatter.php

示例8: write

 public function write($message)
 {
     $this->messages[] = $this->outputFormatter->format($message);
 }
開發者ID:mac2000,項目名稱:silex_migrations_service_provider,代碼行數:4,代碼來源:HtmlOutputWriter.php

示例9: write

 /**
  * Writes a line.
  * @param string $line
  * @return void
  */
 private function write($line = '')
 {
     echo $this->formatter->format($line);
 }
開發者ID:sseidelmann,項目名稱:performance-measurement,代碼行數:9,代碼來源:Meter.php

示例10: format

 public function format($message)
 {
     $formatted = parent::format($message);
     $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
     return preg_replace_callback("{\\[([0-9;]+)m(.*?)\\[(?:" . $clearEscapeCodes . ";)*?" . $clearEscapeCodes . "m}s", array($this, 'formatHtml'), $formatted);
 }
開發者ID:alancleaver,項目名稱:composer,代碼行數:6,代碼來源:HtmlOutputFormatter.php

示例11: loadFileOrEmpty

 /**
  * @param string $filename
  *
  * @return array
  */
 private static function loadFileOrEmpty($filename)
 {
     if (!file_exists($filename)) {
         return [];
     }
     try {
         if (!is_array($content = Yaml::parse(file_get_contents($filename)))) {
             $content = [];
         }
         return $content;
     } catch (ParseException $exception) {
         $errorFormatter = new OutputFormatter(true);
         echo $errorFormatter->format(sprintf('<error>[WARNING] YAML File "%s" is invalid, falling back to "[]" as parsed-value.</error>' . PHP_EOL . '<error>Error: %s</error>' . PHP_EOL, $errorFormatter->escape($filename), $errorFormatter->escape($exception->getMessage()))) . PHP_EOL;
         return [];
     }
 }
開發者ID:gushphp,項目名稱:gush,代碼行數:21,代碼來源:ConfigFactory.php

示例12: format

 public function format($event)
 {
     $message = parent::format($event);
     $colorizer = new OutputFormatter(true);
     return $colorizer->format($message);
 }
開發者ID:alex-oleshkevich,項目名稱:zf-extras,代碼行數:6,代碼來源:SimpleStyled.php

示例13: removeFormat

 /**
  * {@inheritdoc}
  */
 public function removeFormat($string)
 {
     return $this->innerFormatter->format($string);
 }
開發者ID:webmozart,項目名稱:console,代碼行數:7,代碼來源:PlainFormatter.php

示例14: testNestedStyles

 public function testNestedStyles()
 {
     $formatter = new OutputFormatter(true);
     $this->assertSame("[32mTest [39m[37;41merror[39;49m[32m and [39m[33mcomment[39m[32m inside a info.[39m", $formatter->format('<info>Test <error>error</error> and <comment>comment</comment> inside a info.</info>'));
 }
開發者ID:tronsha,項目名稱:cerberus,代碼行數:5,代碼來源:ConsoleTest.php


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