С версии: 1.0
Автор: Bernhard Schussek (bschussek@gmail.com)
Пример #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));
     }
 }
Пример #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;
 }
Пример #3
0
 /**
  * @dataProvider getTestCases
  */
 public function testConvert($style, $converted)
 {
     $this->assertEquals($converted, StyleConverter::convert($style));
 }