Passed
Push — main ( 484639...0ca30d )
by Siad
05:19
created

StatsTimer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 73.68%

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 40
ccs 14
cts 19
cp 0.7368
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSeries() 0 3 1
A getName() 0 3 1
A finish() 0 3 1
A start() 0 5 1
A getTime() 0 3 1
1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19
20
namespace Phing\Util;
21
22
/**
23
 * @author  Siad Ardroumli <[email protected]>
24
 */
25
class StatsTimer
26
{
27
    protected $name;
28
29
    protected $series;
30
31
    protected $clock;
32
33 4
    public function __construct($name, Clock $clock)
34
    {
35 4
        $this->name = $name;
36 4
        $this->clock = $clock;
37 4
        $this->series = new Series();
38 4
    }
39
40
    public function start()
41
    {
42
        $duration = new Duration();
43
        $duration->setStartTime($this->clock->getCurrentTime());
44
        $this->series->add($duration);
45
    }
46
47 4
    public function finish()
48
    {
49 4
        $this->series->setFinishTime($this->clock->getCurrentTime());
50 4
    }
51
52 1
    public function getName()
53
    {
54 1
        return $this->name;
55
    }
56
57 3
    public function getTime()
58
    {
59 3
        return $this->series->getTotalTime();
60
    }
61
62 4
    public function getSeries()
63
    {
64 4
        return $this->series;
65
    }
66
}
67