Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class MetaOutput
00016 {
00017 private $out = null;
00018
00019 public function __construct(TextOutput $out)
00020 {
00021 $this->out = $out;
00022 }
00023
00027 public function getOutput()
00028 {
00029 return $this->out;
00030 }
00031
00035 public function newLine()
00036 {
00037 $this->out->newLine();
00038
00039 return $this;
00040 }
00041
00045 public function log($text, $bold = false)
00046 {
00047 return $this->defaultText($text, ConsoleMode::FG_WHITE, $bold);
00048 }
00049
00053 public function logLine($text, $bold = false)
00054 {
00055 return $this->defaultTextLine($text, ConsoleMode::FG_WHITE, $bold);
00056 }
00057
00061 public function info($text, $bold = false)
00062 {
00063 return $this->defaultText($text, ConsoleMode::FG_GREEN, $bold);
00064 }
00065
00069 public function infoLine($text, $bold = false)
00070 {
00071 return $this->defaultTextLine($text, ConsoleMode::FG_GREEN, $bold);
00072 }
00073
00077 public function warning($text)
00078 {
00079 return $this->defaultText($text, ConsoleMode::FG_BROWN, true);
00080 }
00081
00085 public function warningLine($text)
00086 {
00087 return $this->defaultTextLine($text, ConsoleMode::FG_BROWN, true);
00088 }
00089
00093 public function error($text, $bold = false)
00094 {
00095 return $this->defaultText($text, ConsoleMode::FG_RED, $bold);
00096 }
00097
00101 public function errorLine($text, $bold = false)
00102 {
00103 return $this->defaultTextLine($text, ConsoleMode::FG_RED, $bold);
00104 }
00105
00109 public function remark($text)
00110 {
00111 return $this->defaultText($text, ConsoleMode::FG_BLUE, true);
00112 }
00113
00117 public function remarkLine($text)
00118 {
00119 return $this->defaultTextLine($text, ConsoleMode::FG_BLUE, true);
00120 }
00121
00125 private function defaultText($text, $color, $bold)
00126 {
00127 $this->out->
00128 setMode(
00129 $bold ? ConsoleMode::ATTR_BOLD : ConsoleMode::ATTR_RESET_ALL,
00130 $color,
00131 ConsoleMode::BG_BLACK
00132 )->
00133 write($text);
00134
00135 if ($this->out instanceof ColoredTextOutput)
00136 $this->out->resetAll();
00137
00138 return $this;
00139 }
00140
00144 private function defaultTextLine($text, $color, $bold)
00145 {
00146 $this->out->
00147 setMode(
00148 $bold ? ConsoleMode::ATTR_BOLD : ConsoleMode::ATTR_RESET_ALL,
00149 $color,
00150 ConsoleMode::BG_BLACK
00151 )->
00152 writeLine($text);
00153
00154 if ($this->out instanceof ColoredTextOutput)
00155 $this->out->resetAll();
00156
00157 return $this;
00158 }
00159 }
00160 ?>