Duration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 40
ccs 8
cts 8
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A duration() 0 3 1
A stopClock() 0 4 1
A isFinished() 0 3 1
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