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.

functions.php ➔ childProcessPromise()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 28

Duplication

Lines 10
Ratio 35.71 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 1
nop 2
dl 10
loc 28
ccs 13
cts 13
cp 1
crap 3
rs 9.472
c 0
b 0
f 0
1
<?php
2
3
namespace WyriHaximus\React;
4
5
use React\ChildProcess\Process;
6
use React\EventLoop\LoopInterface;
7
use React\Promise\Deferred;
8
use React\Stream\ReadableStreamInterface;
9
10
/**
11
 * Promise that resolves once child process exits
12
 *
13
 * @param LoopInterface $loop    ReactPHP event loop.
14
 * @param Process       $process Child Process to run.
15
 *
16
 * @return \React\Promise\PromiseInterface
17
 */
18
function childProcessPromise(LoopInterface $loop, Process $process)
19 1
{
20
    $deferred = new Deferred();
21 1
    $buffers = [
22 1
        'stderr' => '',
23 1
        'stdout' => '',
24
    ];
25
26 1
    $process->on('exit', function ($exitCode) use ($deferred, &$buffers) {
27 1
        $deferred->resolve(new ProcessOutcome($exitCode, $buffers['stderr'], $buffers['stdout']));
28
    });
29
30 1
    \WyriHaximus\React\futurePromise($loop, $process)->then(function (Process $process) use ($loop, &$buffers) {
31
        $process->start($loop);
32 1 View Code Duplication
        if ($process->stderr instanceof ReadableStreamInterface) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33 1
            $process->stderr->on('data', function ($output) use (&$buffers) {
34
                $buffers['stderr'] .= $output;
35 1
            });
36 1
        }
37 1 View Code Duplication
        if ($process->stdout instanceof ReadableStreamInterface) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            $process->stdout->on('data', function ($output) use (&$buffers) {
39 1
                $buffers['stdout'] .= $output;
40
            });
41
        }
42
    });
43
44
    return $deferred->promise();
45
}
46