当前位置: 首页>>代码示例>>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;未经允许,请勿转载。