GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TimerPool   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 6
c 2
b 0
f 2
lcom 1
cbo 1
dl 0
loc 64
ccs 18
cts 18
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A start() 0 4 1
A stop() 0 6 2
A build() 0 8 2
1
<?php
2
3
namespace Isswp101\Timer;
4
5
class TimerPool
6
{
7
    /**
8
     * @var Timer[]
9
     */
10
    protected $timers = [];
11
12
    /**
13
     * @var string[]
14
     */
15
    protected $markers = [];
16
17
    /**
18
     * @var string
19
     */
20
    private $format;
21
22
    /**
23
     * Create a new TimerPool instance.
24
     *
25
     * @param string $format
26
     */
27 3
    public function __construct($format = 'H:i:s.ms')
28
    {
29 3
        $this->timers = [];
30 3
        $this->format = $format;
31 3
    }
32
33
    /**
34
     * Start timer with a specific marker.
35
     *
36
     * @param string $marker
37
     */
38 3
    public function start($marker)
39
    {
40 3
        $this->timers[$marker] = new Timer($this->format);
41 3
    }
42
43
    /**
44
     * Stop timer with a specific marker.
45
     *
46
     * @param string $marker
47
     */
48 3
    public function stop($marker)
49
    {
50 3
        if (array_key_exists($marker, $this->timers)) {
51 3
            $this->timers[$marker]->stop();
52 3
        }
53 3
    }
54
55
    /**
56
     * Return sorted times.
57
     *
58
     * @return string[]
59
     */
60 3
    public function build()
61
    {
62 3
        foreach ($this->timers as $marker => $timer) {
63 3
            $this->markers[$marker] = $timer->time();
64 3
        }
65 3
        arsort($this->markers);
66 3
        return $this->markers;
67
    }
68
}
69