measure_timing()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 11
rs 10
c 1
b 0
f 0
1
<?php
2
3
use BeyondCode\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