class Formatter (View source)

Utilities that are used for formatting queries.

Constants

private FORMATTERS

Properties

static array<string, bool> $shortClauses

Clauses that are usually short.

static array<string, bool> $inlineClauses

Clauses that must be inlined.

Methods

__construct(FormattingOptions $options = new FormattingOptions())

No description

string
formatList(TokensList $list)

Formats the given list of tokens.

string
escapeConsole(string $string)

No description

string
toString(Token $token)

Tries to print the query and returns the result.

static string
format(string $query, FormattingOptions $options = new FormattingOptions())

Formats a query.

static int
getGroupLength(TokensList $list)

Computes the length of a group.

static int|false
isClause(Token $token)

Checks if a token is a statement or a clause inside a statement.

Details

protected __construct(FormattingOptions $options = new FormattingOptions())

No description

Parameters

FormattingOptions $options

string formatList(TokensList $list)

Formats the given list of tokens.

Parameters

TokensList $list

the list of tokens

Return Value

string

string escapeConsole(string $string)

No description

Parameters

string $string

Return Value

string

string toString(Token $token)

Tries to print the query and returns the result.

Parameters

Token $token

the token to be printed

Return Value

string

static string format(string $query, FormattingOptions $options = new FormattingOptions())

Formats a query.

Parameters

string $query

The query to be formatted

FormattingOptions $options

the formatting options

Return Value

string

the formatted string

static int getGroupLength(TokensList $list)

Computes the length of a group.

A group is delimited by a pair of brackets.

Parameters

TokensList $list

the list of tokens

Return Value

int

static int|false isClause(Token $token)

Checks if a token is a statement or a clause inside a statement.

Parameters

Token $token

the token to be checked

Return Value

int|false