public function write($messages, $newline = false, $type = Output::OUTPUT_NORMAL, $stream = null) { if (Output::VERBOSITY_QUIET === $this->output->getVerbosity()) { return; } $messages = (array) $messages; foreach ($messages as $message) { switch ($type) { case Output::OUTPUT_NORMAL: $message = $this->formatter->format($message); break; case Output::OUTPUT_RAW: break; case Output::OUTPUT_PLAIN: $message = strip_tags($this->formatter->format($message)); break; default: throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); } $this->doWrite($message, $newline, $stream); } }
public static function strlenWithoutDecoration(Formatter $formatter, $string) { $isDecorated = $formatter->isDecorated(); $formatter->setDecorated(false); // remove <...> formatting $string = $formatter->format($string); // remove already formatted characters $string = preg_replace("/\\[[^m]*m/", '', $string); $formatter->setDecorated($isDecorated); return self::strlen($string); }