class Advisor

Advisor class

Constants

GENERIC_RULES_FILE

BEFORE_MYSQL80003_RULES_FILE

Properties

protected $dbi
protected $variables
protected $globals
protected $parseResult
protected $runResult
protected $expression

Methods

__construct(DatabaseInterface $dbi, ExpressionLanguage $expression)

No description

array
getVariables()

Get variables

setVariables(array $variables)

Set variables

setVariable(string|int $variable, mixed $value)

Set a variable and its value

array
getParseResult()

Get parseResult

setParseResult(array $parseResult)

Set parseResult

array
getRunResult()

Get runResult

setRunResult(array $runResult)

Set runResult

array
run()

Parses and executes advisor rules

void
storeError(string $description, Throwable $exception)

Stores current error in run results.

bool
runRules()

Executes advisor rules

static string
escapePercent(string $str)

Escapes percent string to be used in format string.

string
translate(string $str, string|null $param = null)

Wrapper function for translating.

static array
splitJustification(array $rule)

Splits justification to text and formula.

void
addRule(string $type, array $rule)

Adds a rule to the result list

array
defineRulesFiles()

Defines the rules files to use

mixed
ruleExprEvaluate(string $expr)

Runs a code expression, replacing variable names with their respective values

static array
parseRulesFile(string $filename)

Reads the rule file into an array, throwing errors messages on syntax errors.

static string
byTime(float $num, int $precision)

Formats interval like 10 per hour

static string
timespanFormat(int $seconds)

Wrapper for PhpMyAdmin\Util::timespanFormat

static string
formatByteDown(double|int $value, int $limes = 6, int $comma = 0)

Wrapper around PhpMyAdmin\Util::formatByteDown

Details

at line 53
__construct(DatabaseInterface $dbi, ExpressionLanguage $expression)

Parameters

DatabaseInterface $dbi DatabaseInterface object
ExpressionLanguage $expression ExpressionLanguage object

at line 139
array getVariables()

Get variables

Return Value

array

at line 151
Advisor setVariables(array $variables)

Set variables

Parameters

array $variables Variables

Return Value

Advisor

at line 166
Advisor setVariable(string|int $variable, mixed $value)

Set a variable and its value

Parameters

string|int $variable Variable to set
mixed $value Value to set

Return Value

Advisor

at line 178
array getParseResult()

Get parseResult

Return Value

array

at line 190
Advisor setParseResult(array $parseResult)

Set parseResult

Parameters

array $parseResult Parse result

Return Value

Advisor

at line 202
array getRunResult()

Get runResult

Return Value

array

at line 214
Advisor setRunResult(array $runResult)

Set runResult

Parameters

array $runResult Run result

Return Value

Advisor

at line 226
array run()

Parses and executes advisor rules

Return Value

array with run and parse results

at line 268
void storeError(string $description, Throwable $exception)

Stores current error in run results.

Parameters

string $description description of an error.
Throwable $exception exception raised

Return Value

void

at line 281
bool runRules()

Executes advisor rules

Return Value

bool

at line 355
static string escapePercent(string $str)

Escapes percent string to be used in format string.

Parameters

string $str string to escape

Return Value

string

at line 368
string translate(string $str, string|null $param = null)

Wrapper function for translating.

Parameters

string $str the string
string|null $param the parameters

Return Value

string

Exceptions

Exception

at line 386
static array splitJustification(array $rule)

Splits justification to text and formula.

Parameters

array $rule the rule

Return Value

array

at line 406
void addRule(string $type, array $rule)

Adds a rule to the result list

Parameters

string $type type of rule
array $rule rule itself

Return Value

void

Exceptions

Exception

at line 466
protected array defineRulesFiles()

Defines the rules files to use

Return Value

array

at line 512
mixed ruleExprEvaluate(string $expr)

Runs a code expression, replacing variable names with their respective values

Parameters

string $expr expression to evaluate

Return Value

mixed result of evaluated expression

Exceptions

Exception

at line 532
static array parseRulesFile(string $filename)

Reads the rule file into an array, throwing errors messages on syntax errors.

Parameters

string $filename Name of file to parse

Return Value

array with parsed data

at line 652
static string byTime(float $num, int $precision)

Formats interval like 10 per hour

Parameters

float $num number to format
int $precision required precision

Return Value

string formatted string

at line 685
static string timespanFormat(int $seconds)

Wrapper for PhpMyAdmin\Util::timespanFormat

This function is used when evaluating advisory_rules.txt

Parameters

int $seconds the timespan

Return Value

string the formatted value

at line 701
static string formatByteDown(double|int $value, int $limes = 6, int $comma = 0)

Wrapper around PhpMyAdmin\Util::formatByteDown

This function is used when evaluating advisory_rules.txt

Parameters

double|int $value the value to format
int $limes the sensitiveness
int $comma the number of decimals to retain

Return Value

string the formatted value with unit