format() public static method

Formats a query.
public static format ( string $query, array $options = [] ) : string
$query string The query to be formatted
$options array The formatting options.
return string The formatted string.
コード例 #1
0
ファイル: CLI.php プロジェクト: pboutin44/maintest
 public function runHighlight()
 {
     $params = $this->parseHighlight();
     if ($params === false) {
         return 1;
     }
     if (isset($params['h'])) {
         $this->usageHighlight();
         return 0;
     }
     if (isset($params['q'])) {
         echo Formatter::format($params['q'], array('type' => $params['f']));
         echo "\n";
         return 0;
     }
     echo "ERROR: Missing parameters!\n";
     $this->usageHighlight();
     return 1;
 }
コード例 #2
0
 /**
  * @dataProvider formatQueries
  */
 public function testFormat($query, $expected, $options)
 {
     $this->assertEquals($expected, Formatter::format($query, $options));
 }
コード例 #3
0
ファイル: Cli.php プロジェクト: cweiske/php-sqllint
 /**
  * Reformat the given file
  */
 protected function formatFile($filename)
 {
     $this->renderer->startRendering($filename);
     $sql = $this->loadSql($filename);
     if ($sql === false) {
         return false;
     }
     $typeMap = array('none' => 'text', 'ansi' => 'cli', 'html' => 'html');
     $options = array('type' => $typeMap[$this->highlight]);
     echo \SqlParser\Utils\Formatter::format($sql, $options) . "\n";
 }