ConsoleKit\TextFormater::format PHP Méthode

format() public méthode

Formats $text according to the formater's options
public format ( string $text )
$text string
    public function format($text)
    {
        $lines = explode("\n", $text);
        foreach ($lines as &$line) {
            $line = (string) $this->quote . str_repeat(' ', $this->indent * $this->indentWidth) . $line;
        }
        return Colors::colorize(implode("\n", $lines), $this->fgColor, $this->bgColor);
    }

Usage Example

Exemple #1
0
 /**
  * Show a list of available options
  */
 protected function showOptions()
 {
     $this->writeln("Options:", Colors::YELLOW);
     $rows = array(array(Colors::colorize('--version', Colors::GREEN), "Show version number"), array(Colors::colorize('--working-dir=DIR', Colors::GREEN), "If specified, use the given directory as working directory"), array(Colors::colorize('--config=FILE', Colors::GREEN), "Use an alternative config file"));
     $formater = new TextFormater(array('indent' => 2));
     $table = new Table(null, $rows, array('border' => false, 'frame' => false));
     $this->writeln($formater->format($table->render()));
 }
All Usage Examples Of ConsoleKit\TextFormater::format