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

Timer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 0 4 1
A assertStop() 0 4 2
A assertStart() 0 4 2
A assertStartAndStop() 0 4 1
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