helpers.php ➔ measure_timing()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
use DJStarCOM\ServerTiming\ServerTiming;
4
5
if (!function_exists('measure_timing')) {
6
    function measure_timing(string $key, $callable = null)
7
    {
8
        /** @var ServerTiming $timing */
9
        $timing = app(ServerTiming::class);
10
11
        if (is_callable($callable)) {
12
            $timing->setDuration($key, $callable);
13
            return;
14
        }
15
16
        $timing->measure($key);
17
    }
18
}
19