Timer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 44
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A assertStartAndStop() 0 4 1
A assertStop() 0 2 1
A assertStart() 0 2 1
A current() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Timers;
4
5
use AlecRabbit\Formatters\TimerReportFormatter;
6
use AlecRabbit\Reports\TimerReport;
7
use AlecRabbit\Timers\Core\AbstractTimer;
8
9
/**
10
 * Class Timer
11
 * @package AlecRabbit\Timers
12
 */
13
class Timer extends AbstractTimer
14
{
15 19
    public function __construct(?string $name = null, bool $start = true)
16
    {
17 19
        parent::__construct($name, $start);
18 19
        $this->setBindings(
19 19
            TimerReport::class,
20 19
            TimerReportFormatter::class
21
        );
22 19
    }
23
24
25
    /**
26
     * @return float
27
     */
28 16
    public function current(): float
29
    {
30
        return
0 ignored issues
show
Bug Best Practice introduced by
The expression return microtime(true) could return the type string which is incompatible with the type-hinted return double. Consider adding an additional type-check to rule them out.
Loading history...
31 16
            microtime(true);
32
    }
33
34
    /**
35
     * @param float $start
36
     * @param float $stop
37
     */
38 4
    protected function assertStartAndStop($start, $stop): void
39
    {
40 4
        $this->assertStart($start);
41 3
        $this->assertStop($stop);
42 2
    }
43
44
    /**
45
     * @param float $start
46
     */
47 3
    protected function assertStart(/** @scrutinizer ignore-unused */ float $start): void
48
    {
49
        // Intentionally left blank
50 3
    }
51
52
    /**
53
     * @param float $stop
54
     */
55 2
    protected function assertStop(/** @scrutinizer ignore-unused */ float $stop): void
56
    {
57
        // Intentionally left blank
58 2
    }
59
}
60