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
Pull Request — master (#13)
by Cees-Jan
01:37
created

OutstandingCalls   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCall() 0 4 1
A getNewUniqid() 0 8 2
A newCall() 0 10 1
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 2
    public function newCall(callable $canceller = null)
17
    {
18 2
        $uniqid = $this->getNewUniqid();
19
20 2
        $this->calls[$uniqid] = new OutstandingCall($uniqid, $canceller, function (OutstandingCall $call) {
21
            unset($this->calls[$call->getUniqid()]);
22 2
        });
23
24 2
        return $this->calls[$uniqid];
25
    }
26
27
    /**
28
     * @param string $uniqid
29
     *
30
     * @return OutstandingCall
31
     */
32 1
    public function getCall($uniqid)
33
    {
34 1
        return $this->calls[$uniqid];
35
    }
36
37
    /**
38
     * @return string
39
     */
40 2
    protected function getNewUniqid()
41
    {
42
        do {
43 2
            $uniqid = (string)microtime(true) . '.' . bin2hex(random_bytes(4));
44 2
        } while (isset($this->calls[$uniqid]));
45
46 2
        return $uniqid;
47
    }
48
}
49