本文整理汇总了PHP中Symfony\Component\Console\Helper\FormatterHelper::formatSection方法的典型用法代码示例。如果您正苦于以下问题:PHP FormatterHelper::formatSection方法的具体用法?PHP FormatterHelper::formatSection怎么用?PHP FormatterHelper::formatSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\FormatterHelper
的用法示例。
在下文中一共展示了FormatterHelper::formatSection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = [])
{
if (!array_key_exists($level, $this->formats)) {
return;
}
$string = \Spiral\interpolate($message, $context);
if (!empty($this->formats[$level])) {
//Formatting string
$string = \Spiral\interpolate('<{format}>{string}</{format}>', ['string' => $string, 'format' => $this->formats[$level]]);
}
if (!empty($this->section) && !empty($this->formatter)) {
$string = $this->formatter->formatSection($this->section, $string);
}
$this->output->writeln($string);
}
示例2: testFormatSection
public function testFormatSection()
{
$formatter = new FormatterHelper();
$this->assertEquals(
'<info>[cli]</info> Some text to display',
$formatter->formatSection('cli', 'Some text to display'),
'::formatSection() formats a message in a section'
);
}
示例3: searchInRequires
/**
* Search for dependencies in this package.
*
* @param PackageInterface $package The package to search in.
* @param string $type One of "prod" or "dev".
* @param array|Link[] $requires The require links.
*
* @return void
*/
private function searchInRequires(PackageInterface $package, $type, array $requires)
{
if (isset($requires[$this->packageName])) {
$link = $requires[$this->packageName];
$constraint = $link->getPrettyConstraint();
$section = $package->getPrettyString();
$message = sprintf('<comment>%s</comment> %s %s', 'dev' == $type ? 'require-dev' : 'require', $this->packageName, $constraint);
$this->progress->clear();
// Hack to get the cursor on the line beginning
$this->output->write("\n[1A");
$this->output->writeln($this->formatter->formatSection($section, $message));
$this->progress->display();
}
}