Conditions | 4 |
Paths | 4 |
Total Lines | 29 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function getWidgets() |
||
16 | { |
||
17 | $widgets = parent::getWidgets(); |
||
18 | |||
19 | $upperThreshold = DebugBar::config()->get('warn_request_time_seconds'); |
||
20 | $warningRatio = DebugBar::config()->get('warn_warning_ratio'); |
||
21 | |||
22 | // Can be disabled by setting the value to false |
||
23 | if (!is_numeric($upperThreshold)) { |
||
24 | return $widgets; |
||
25 | } |
||
26 | |||
27 | $widgets['time']['indicator'] = 'PhpDebugBar.DebugBar.WarnableRequestTimeIndicator'; |
||
28 | $widgets['time']['warn'] = 'ok'; |
||
29 | // Request duration rather than Request Duration |
||
30 | $widgets['time']['tooltip'] = ucfirst(strtolower((string) $widgets['time']['tooltip'])); |
||
31 | |||
32 | $warningThreshold = $upperThreshold * $warningRatio; |
||
33 | if ($this->getRequestDuration() > $upperThreshold) { |
||
34 | $widgets['time']['warn'] = 'danger'; |
||
35 | $widgets['time']['tooltip'] .= ' > ' . $upperThreshold . ' seconds'; |
||
36 | } elseif ($this->getRequestDuration() > $warningThreshold) { |
||
37 | $widgets['time']['warn'] = 'warning'; |
||
38 | $widgets['time']['tooltip'] .= ' > ' . $warningThreshold . ' seconds'; |
||
39 | } else { |
||
40 | $widgets['time']['tooltip'] .= ' < ' . $warningThreshold . ' seconds'; |
||
41 | } |
||
42 | |||
43 | return $widgets; |
||
44 | } |
||
46 |