Duration::isFinished()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Events;
4
5
use ZoiloMora\ElasticAPM\Helper\Stopwatch\Stopwatch;
6
7
trait Duration
8
{
9
    /**
10
     * How long the transaction/span took to complete, in ms with 3 decimal points
11
     *
12
     * @var double|null
13
     */
14
    private $duration;
15
16
    /**
17
     * @var Stopwatch
18
     */
19
    private $stopwatch;
20
21
    /**
22
     * @return double|null
23
     */
24 3
    public function duration()
25
    {
26 3
        return $this->duration;
27
    }
28
29
    /**
30
     * @return void
31
     *
32
     * @throws \ZoiloMora\ElasticAPM\Helper\Stopwatch\Exception\NotStartedException
33
     * @throws \ZoiloMora\ElasticAPM\Helper\Stopwatch\Exception\NotStoppedException
34
     */
35 9
    private function stopClock()
36
    {
37 9
        $this->stopwatch->stop();
38 9
        $this->duration = $this->stopwatch->getDuration();
39 9
    }
40
41
    /**
42
     * @return bool
43
     */
44 11
    public function isFinished()
45
    {
46 11
        return null !== $this->duration;
47
    }
48
}
49