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::build()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 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