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 ( 78c5cf...93608b )
by Cees-Jan
07:34 queued 05:28
created

OutstandingCalls::newCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4286
cc 1
eloc 5
nc 1
nop 1
crap 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 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 string
39
     */
40 3
    protected function getNewUniqid()
41
    {
42
        do {
43 3
            $uniqid = uniqid('', true);
44 3
        } while (isset($this->calls[$uniqid]));
45
46 3
        return $uniqid;
47
    }
48
}
49