Esempio n. 1
0
 /**
  * Renders a backtrace message as a string.
  *
  * @param  array  $backtrace The result of `debug_backtrace()`.
  * @return string            A stringified backtrace message for printing to the console.
  */
 public static function render(array $backtrace)
 {
     $messages = array();
     $output = array();
     $formatter = ConsoleUtil::formatters();
     foreach ($backtrace as $trace) {
         @($messages[$trace['file'] . ':' . $trace['line']] = $trace['class'] . $trace['type'] . $trace['function'] . '()');
     }
     $padding = ConsoleUtil::tablify($messages);
     foreach ($messages as $code => $line) {
         $output[] = implode(' @ ', array(str_pad($code, $padding, ' ', STR_PAD_RIGHT), $formatter->gold->apply($line)));
     }
     return PHP_EOL . TAB . TAB . implode(PHP_EOL . TAB . TAB, $output);
 }
Esempio n. 2
0
 /**
  * Display the configuration to the Console.
  *
  * @param  OutputInterface $output The command-line output.
  * @return void
  */
 public function displayConfig(OutputInterface $output)
 {
     // Title and formatting
     $output->writeln($this->formatter->yellow->apply('ACTIVE CONFIGURATION OPTIONS:'));
     $padding = ConsoleUtil::tablify(ConfigStore::get());
     $self = $this;
     // Write the tablified listing to the buffer
     $output->writeln(ConsoleUtil::indent(YAML::dump(ConfigStore::get(), 1), $this->formatter->green->apply('-> '), function ($line) use($self, $padding) {
         $pieces = explode(': ', $line);
         $pieces[0] = str_pad($pieces[0], $padding, ' ', STR_PAD_RIGHT);
         $pieces[1] = $self->formatter->gold->apply($pieces[1]);
         return implode(' : ', $pieces);
     }));
     // Write any stored messages to the buffer
     if (count(ConfigStore::$messages) > 0) {
         foreach (ConfigStore::$messages as $message) {
             $output->writeln($message);
         }
     }
     echo PHP_EOL;
 }