Completed
Push — develop ( a410d7...efad38 )
by Alec
04:48 queued 01:47
created

Timer::assertStartAndStop()   A

Complexity

Conditions 5
Paths 12

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5.0187

Importance

Changes 0
Metric Value
cc 5
eloc 10
nc 12
nop 2
dl 0
loc 15
ccs 10
cts 11
cp 0.9091
crap 5.0187
rs 9.6111
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools;
4
5
use function AlecRabbit\typeOf;
6
7
class Timer extends AbstractTimer
8
{
9
    /**
10
     * @return float
11
     */
12 13
    public function current(): float
13
    {
14
        return
15 13
            microtime(true);
16
    }
17
18
    /**
19
     * @param float $start
20
     * @param float $stop
21
     */
22 4
    protected function assertStartAndStop($start, $stop): void
23
    {
24 4
        $start_ok = false;
25 4
        $stop_ok = false;
26 4
        if (is_float($start)) {
0 ignored issues
show
introduced by
The condition is_float($start) is always true.
Loading history...
27 2
            $start_ok = true;
28
        }
29 4
        if (is_float($stop)) {
0 ignored issues
show
introduced by
The condition is_float($stop) is always true.
Loading history...
30 2
            $stop_ok = true;
31
        }
32 4
        if (!$start_ok) {
0 ignored issues
show
introduced by
The condition $start_ok is always true.
Loading history...
33 2
            throw new \RuntimeException('Start value is NOT ok. [' . typeOf($start) . ']');
34
        }
35 2
        if (!$stop_ok) {
0 ignored issues
show
introduced by
The condition $stop_ok is always true.
Loading history...
36
            throw new \RuntimeException('Stop value is NOT ok. [' . typeOf($stop) . ']');
37
        }
38 2
    }
39
40
}
41