Exemple #1
0
 /**
  * @param string $string
  *
  * @param null $format
  *
  * @return string
  */
 public function format($string, $format = null)
 {
     if ($format === null) {
         $format = $this->getOutputFormat();
     }
     // print output with ansi support
     if (($format & OutputFormat::NORMAL) === OutputFormat::NORMAL) {
         return $this->formatter->formatAnsi($string);
     } else {
         if (($format & OutputFormat::PLAIN) === OutputFormat::PLAIN) {
             return $this->formatter->formatPlain($string);
         }
     }
     // return raw output
     return $string;
 }
Exemple #2
0
 function it_renders_output_according_to_processing_settings(IConsoleFormatter $formatter, IOutputBuffer $buffer)
 {
     $buffer->flush()->willReturn('text1');
     $this->setOutputFormat(OutputFormat::NORMAL);
     $formatter->formatAnsi('text1')->shouldBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
     $buffer->flush()->willReturn('text2');
     $this->setOutputFormat(OutputFormat::PLAIN);
     $formatter->formatPlain('text2')->shouldBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
     $buffer->flush()->willReturn('');
     $this->setOutputFormat(OutputFormat::RAW);
     $formatter->formatPlain('')->shouldNotBeCalled();
     $buffer->flush()->shouldBeCalled();
     $this->flushBuffer();
 }