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

JpgTimer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 27
ccs 0
cts 16
cp 0
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Pop() 0 8 1
A Push() 0 4 1
A __construct() 0 3 1
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