You are here

public function Output::write in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Output/Output.php \Symfony\Component\Console\Output\Output::write()

Writes a message to the output.

Parameters

string|array $messages The message as an array of lines or a single string:

bool $newline Whether to add a newline:

int $type The type of output (one of the OUTPUT constants):

Throws

\InvalidArgumentException When unknown output type is given

Overrides OutputInterface::write

1 call to Output::write()
Output::writeln in vendor/symfony/console/Output/Output.php
Writes a message to the output and adds a newline at the end.

File

vendor/symfony/console/Output/Output.php, line 128

Class

Output
Base class for output classes.

Namespace

Symfony\Component\Console\Output

Code

public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) {
  if (self::VERBOSITY_QUIET === $this->verbosity) {
    return;
  }
  $messages = (array) $messages;
  foreach ($messages as $message) {
    switch ($type) {
      case OutputInterface::OUTPUT_NORMAL:
        $message = $this->formatter
          ->format($message);
        break;
      case OutputInterface::OUTPUT_RAW:
        break;
      case OutputInterface::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);
  }
}