Passed
Push — develop ( efad38...adafda )
by Alec
02:51
created

Timer::assertStop()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
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
        $this->assertStart($start);
25 3
        $this->assertStop($stop);
26 2
    }
27
28
    /**
29
     * @param $start
30
     */
31 4
    protected function assertStart($start): void
32
    {
33 4
        if (!\is_float($start)) {
34 1
            throw new \RuntimeException('Start value is NOT ok. [' . typeOf($start) . ']');
35
        }
36 3
    }
37
38
    /**
39
     * @param $stop
40
     */
41 3
    protected function assertStop($stop): void
42
    {
43 3
        if (!is_float($stop)) {
44 1
            throw new \RuntimeException('Stop value is NOT ok. [' . typeOf($stop) . ']');
45
        }
46 2
    }
47
48
}
49