convert() публичный статический Метод

Converts a {@link Style} instance to an {@link OutputFormatterStyle}.
public static convert ( Style $style ) : Symfony\Component\Console\Formatter\OutputFormatterStyle
$style Webmozart\Console\Api\Formatter\Style The style to convert.
Результат Symfony\Component\Console\Formatter\OutputFormatterStyle The converted style.
Пример #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));
 }