Test Failed
Pull Request — master (#144)
by
unknown
05:06
created

JpgTimer::Pop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Util;
8
9
/**
10
 * @class JpgTimer
11
 * // Description: General timing utility class to handle
12
 * // time measurement of generating graphs. Multiple
13
 * // timers can be started.
14
 */
15
class JpgTimer
16
{
17
    private $start;
18
    private $idx;
19
20
    public function __construct()
21
    {
22
        $this->idx = 0;
23
    }
24
25
    // Push a new timer start on stack
26
    public function Push()
27
    {
28
        list($ms, $s)              = explode(' ', microtime());
29
        $this->start[$this->idx++] = floor($ms * 1000) + 1000 * $s;
30
    }
31
32
    // Pop the latest timer start and return the diff with the
33
    // current time
34
    public function Pop()
35
    {
36
        assert($this->idx > 0);
37
        list($ms, $s) = explode(' ', microtime());
38
        $etime        = floor($ms * 1000) + (1000 * $s);
39
        --$this->idx;
40
41
        return $etime - $this->start[$this->idx];
42
    }
43
} // @class
44