diff --git a/FSHL/Output/SymfonyConsole.php b/FSHL/Output/SymfonyConsole.php new file mode 100644 index 0000000..b850cc5 --- /dev/null +++ b/FSHL/Output/SymfonyConsole.php @@ -0,0 +1,104 @@ +getFormatter(); + * + * $colors = array( + * 'html-tag' => 'magenta', + * 'html-tagin' => 'yellow', + * 'html-quote' => null, + * ); + * + * foreach ($colors as $tag => $color) { + * $style = new OutputFormatterStyle($color, null, array()); + * $formatter->setStyle($tag, $style); + * } + * + * @author Daniel Leech + * @license http://fshl.kukulich.cz/#license + */ +class SymfonyConsole implements FSHL\Output +{ + /** + * Last used class. + * + * @var string + */ + private $lastStyle = null; + + /** + * Outputs a template part. + * + * @param string $part + * @param string $class + * @return string + */ + public function template($part, $class) + { + $output = ''; + + if ($this->lastStyle !== $class) { + if (null !== $this->lastStyle) { + $output .= 'lastStyle . '>'; + } + if (null !== $class) { + $output .= '<' . $class . '>'; + } + + $this->lastStyle = $class; + } + + return $output . $part; + } + + /** + * Outputs a keyword. + * + * @param string $part + * @param string $class + * @return string + */ + public function keyword($part, $class) + { + $output = ''; + + if ($this->lastStyle !== $class) { + if (null !== $this->lastStyle) { + $output .= 'lastStyle . '>'; + } + if (null !== $class) { + $output .= '<' . $this->lastStyle . '>'; + } + + $this->lastStyle = $class; + } + + return $output . $part; + } +}