Ejemplo n.º 1
0
 /**
  * Writes a message to the output.
  *
  * @param string|array $messages The message as an array of lines or a single string
  * @param bool $newline Whether to add a newline
  * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
  */
 public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
 {
     $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
     $type = $types & $options ?: self::OUTPUT_NORMAL;
     if (is_string($messages)) {
         if ("<aside>⏎</aside>" === $messages) {
             return;
         }
         $preparedMessage = $messages . ($newline ? '' : "\n");
         switch ($type) {
             case OutputInterface::OUTPUT_NORMAL:
                 $preparedMessage = $this->formatter->format($messages) . ($newline ? '' : "\n");
                 break;
             case OutputInterface::OUTPUT_RAW:
                 break;
             case OutputInterface::OUTPUT_PLAIN:
                 $preparedMessage = strip_tags($this->formatter->format($messages)) . ($newline ? '' : "\n");
                 break;
         }
     } elseif (is_array($messages)) {
         $preparedMessage = implode("\n", $messages) . ($newline ? '' : "\n");
     } else {
         return;
         // TODO: Throw an error?
     }
     $this->executeAction->notifyMessage($preparedMessage);
 }