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.
Completed
Push — master ( a10806...afde92 )
by Cees-Jan
03:04
created

OutstandingCalls   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCall() 0 4 1
A newCall() 0 10 1
A getCalls() 0 4 1
A getNewUniqid() 0 8 2
1
<?php
2
3
namespace WyriHaximus\React\ChildProcess\Messenger;
4
5
class OutstandingCalls
6
{
7
    /**
8
     * @var OutstandingCall[]
9
     */
10
    protected $calls = [];
11
12
    /**
13
     * @param  callable        $canceller
14
     * @return OutstandingCall
15
     */
16 3
    public function newCall(callable $canceller = null)
17
    {
18 3
        $uniqid = $this->getNewUniqid();
19
20 3
        $this->calls[$uniqid] = new OutstandingCall($uniqid, $canceller, function (OutstandingCall $call) {
21 1
            unset($this->calls[$call->getUniqid()]);
22 3
        });
23
24 3
        return $this->calls[$uniqid];
25
    }
26
27
    /**
28
     * @param string $uniqid
29
     *
30
     * @return OutstandingCall
31
     */
32 2
    public function getCall($uniqid)
33
    {
34 2
        return $this->calls[$uniqid];
35
    }
36
37
    /**
38
     * @return array
39
     */
40 2
    public function getCalls()
41
    {
42 2
        return array_values($this->calls);
43
    }
44
45
    /**
46
     * @return string
47
     */
48 3
    protected function getNewUniqid()
49
    {
50
        do {
51 3
            $uniqid = (string)microtime(true) . '.' . bin2hex(random_bytes(4));
52 3
        } while (isset($this->calls[$uniqid]));
53
54 3
        return $uniqid;
55
    }
56
}
57