Translated using Weblate (Slovenian)
[phpmyadmin.git] / libraries / advisor.lib.php
blob6f3e0b0241db2801061c1283a4b7d21647493417
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Contains Advisor functions
6 * @package PhpMyAdmin
7 */
9 /**
10 * Formats interval like 10 per hour
12 * @param integer $num number to format
13 * @param integer $precision required precision
15 * @return string formatted string
17 function ADVISOR_bytime($num, $precision)
19 if ($num >= 1) { // per second
20 $per = __('per second');
21 } elseif ($num * 60 >= 1) { // per minute
22 $num = $num * 60;
23 $per = __('per minute');
24 } elseif ($num * 60 * 60 >= 1 ) { // per hour
25 $num = $num * 60 * 60;
26 $per = __('per hour');
27 } else {
28 $num = $num * 60 * 60 * 24;
29 $per = __('per day');
32 $num = round($num, $precision);
34 if ($num == 0) {
35 $num = '<' . pow(10, -$precision);
38 return "$num $per";
41 /**
42 * Wrapper for PMA\libraries\Util::timespanFormat
44 * This function is used when evaluating advisory_rules.txt
46 * @param int $seconds the timespan
48 * @return string the formatted value
50 function ADVISOR_timespanFormat($seconds)
52 return PMA\libraries\Util::timespanFormat($seconds);
55 /**
56 * Wrapper around PMA\libraries\Util::formatByteDown
58 * This function is used when evaluating advisory_rules.txt
60 * @param double $value the value to format
61 * @param int $limes the sensitiveness
62 * @param int $comma the number of decimals to retain
64 * @return string the formatted value with unit
66 function ADVISOR_formatByteDown($value, $limes = 6, $comma = 0)
68 return implode(' ', PMA\libraries\Util::formatByteDown($value, $limes, $comma));