public function formatToken(Token $token) { $attrs = array(); $color = isset($this->colors[$token->getType()]) ? $this->colors[$token->getType()] : $this->colors[Token::TYPE_PLAIN_TEXT]; $attrs['style'] = 'color: ' . $color; $description = $token->getDescription(); if ($description) { $attrs['title'] = htmlentities($description); } return $this->formatTag($token->getValue(), $attrs); }
public function formatToken(Token $token) { if (!isset($this->colors[$token->getType()])) { return $token->getValue(); } $colorName = $this->colors[$token->getType()]; if (!isset(static::$availableForegroundColors[$colorName])) { return $token->getValue(); } $colorCodes = static::$availableForegroundColors[$colorName]; return sprintf("[%sm%s[%sm", $colorCodes['set'], $token->getValue(), $colorCodes['unset']); }
public function formatToken(Token $token) { return $token->getDescription() ?: $token->getValue(); }