public function OutputFormatterStyle::apply in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Formatter/OutputFormatterStyle.php \Symfony\Component\Console\Formatter\OutputFormatterStyle::apply()
Applies the style to a given text.
Parameters
string $text The text to style:
Return value
string
Overrides OutputFormatterStyleInterface::apply
File
- vendor/
symfony/ console/ Formatter/ OutputFormatterStyle.php, line 193
Class
- OutputFormatterStyle
- Formatter style class for defining styles.
Namespace
Symfony\Component\Console\FormatterCode
public function apply($text) {
$setCodes = array();
$unsetCodes = array();
if (null !== $this->foreground) {
$setCodes[] = $this->foreground['set'];
$unsetCodes[] = $this->foreground['unset'];
}
if (null !== $this->background) {
$setCodes[] = $this->background['set'];
$unsetCodes[] = $this->background['unset'];
}
if (count($this->options)) {
foreach ($this->options as $option) {
$setCodes[] = $option['set'];
$unsetCodes[] = $option['unset'];
}
}
if (0 === count($setCodes)) {
return $text;
}
return sprintf("\33[%sm%s\33[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
}