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)

Constructor

mixed
getVariables()

Get variables

setVariables(array $variables)

Set variables

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

Set a variable and its value

mixed
getParseResult()

Get parseResult

setParseResult(array $parseResult)

Set parseResult

mixed
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|string $value, int $limes = 6, int $comma = 0)

Wrapper around PhpMyAdmin\Util::formatByteDown

Details

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

Constructor

Parameters

DatabaseInterface $dbi DatabaseInterface object
ExpressionLanguage $expression ExpressionLanguage object

at line 131
mixed getVariables()

Get variables

Return Value

mixed

at line 143
Advisor setVariables(array $variables)

Set variables

Parameters

array $variables Variables

Return Value

Advisor

at line 158
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 170
mixed getParseResult()

Get parseResult

Return Value

mixed

at line 182
Advisor setParseResult(array $parseResult)

Set parseResult

Parameters

array $parseResult Parse result

Return Value

Advisor

at line 194
mixed getRunResult()

Get runResult

Return Value

mixed

at line 206
Advisor setRunResult(array $runResult)

Set runResult

Parameters

array $runResult Run result

Return Value

Advisor

at line 218
array run()

Parses and executes advisor rules

Return Value

array with run and parse results

at line 263
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 278
bool runRules()

Executes advisor rules

Return Value

bool

at line 354
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 407
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 467
protected array defineRulesFiles()

Defines the rules files to use

Return Value

array

at line 513
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 533
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 653
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 686
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 702
static string formatByteDown(double|string $value, int $limes = 6, int $comma = 0)

Wrapper around PhpMyAdmin\Util::formatByteDown

This function is used when evaluating advisory_rules.txt

Parameters

double|string $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