class Formatter (View source)

Utilities that are used for formatting queries.

Constants

private FORMATTERS

Properties

array<string,bool|string|array<int,array<string,int|string>>> $options

The formatting options.

static array<string,bool> $shortClauses

Clauses that are usually short.

static array<string,bool> $inlineClauses

Clauses that must be inlined.

Methods

__construct(array $options = [])

No description

array
getMergedOptions(array $options)

The specified formatting options are merged with the default values.

array
getDefaultOptions()

The default formatting options.

array
getDefaultFormats()

The styles used for HTML formatting.

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, array $options = [])

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

__construct(array $options = [])

No description

Parameters

array $options

the formatting options

protected array getMergedOptions(array $options)

The specified formatting options are merged with the default values.

Parameters

array $options

Return Value

array

protected array getDefaultOptions()

The default formatting options.

Return Value

array

protected array getDefaultFormats()

The styles used for HTML formatting.

[$type, $flags, $span, $callback].

Return Value

array

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, array $options = [])

Formats a query.

Parameters

string $query

The query to be formatted

array $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