Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Ejemplo n.º 1
0
 /**
  * Creates the formatter.
  *
  * @param StyleSet $styleSet The style set to use.
  */
 public function __construct(StyleSet $styleSet = null)
 {
     $this->innerFormatter = new OutputFormatter(false);
     if (!$styleSet) {
         $styleSet = new DefaultStyleSet();
     }
     foreach ($styleSet->toArray() as $tag => $style) {
         $this->innerFormatter->setStyle($tag, StyleConverter::convert($style));
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function format($string, Style $style = null)
 {
     if (null !== $style) {
         $this->innerFormatter->getStyleStack()->push(StyleConverter::convert($style));
     }
     $formatted = $this->innerFormatter->format($string);
     if (null !== $style) {
         $this->innerFormatter->getStyleStack()->pop();
     }
     return $formatted;
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider getTestCases
  */
 public function testConvert($style, $converted)
 {
     $this->assertEquals($converted, StyleConverter::convert($style));
 }