class Advisor

Advisor class

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

mixed
ruleExprEvaluate(string $expr)

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

static array
parseRulesFile()

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 41
__construct(DatabaseInterface $dbi, ExpressionLanguage $expression)

Constructor

Parameters

DatabaseInterface $dbi DatabaseInterface object
ExpressionLanguage $expression ExpressionLanguage object

at line 127
mixed getVariables()

Get variables

Return Value

mixed

at line 139
Advisor setVariables(array $variables)

Set variables

Parameters

array $variables Variables

Return Value

Advisor

at line 154
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 166
mixed getParseResult()

Get parseResult

Return Value

mixed

at line 178
Advisor setParseResult(array $parseResult)

Set parseResult

Parameters

array $parseResult Parse result

Return Value

Advisor

at line 190
mixed getRunResult()

Get runResult

Return Value

mixed

at line 202
Advisor setRunResult(array $runResult)

Set runResult

Parameters

array $runResult Run result

Return Value

Advisor

at line 214
array run()

Parses and executes advisor rules

Return Value

array with run and parse results

at line 252
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 267
bool runRules()

Executes advisor rules

Return Value

bool

at line 343
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 357
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 375
static array splitJustification(array $rule)

Splits justification to text and formula.

Parameters

array $rule the rule

Return Value

array

at line 396
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 486
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 504
static array parseRulesFile()

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

Return Value

array with parsed data

at line 625
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 658
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 674
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