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 ( 6ef5d2...d19825 )
by Cees-Jan
08:45 queued 02:16
created

Process   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 80
ccs 37
cts 37
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 2
A deregisterRpc() 0 6 1
A create() 0 17 2
A registerClass() 0 10 1
1
<?php
2
3
namespace WyriHaximus\React\ChildProcess\Messenger;
4
5
use React\EventLoop\LoopInterface;
6
use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory;
7
use WyriHaximus\React\ChildProcess\Messenger\Messages\Factory as MessagesFactory;
8
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
9
use WyriHaximus\React\ChildProcess\Messenger\Messenger;
10
11
class Process
12
{
13
    /**
14
     * @var LoopInterface
15
     */
16
    protected $loop;
17
18
    /**
19
     * @var Messenger
20
     */
21
    protected $messenger;
22
23
    /**
24
     * @param LoopInterface $loop
25
     * @param Messenger $messenger
26
     * @return Process
27
     */
28 2
    public static function create(LoopInterface $loop, Messenger $messenger)
29
    {
30
        try {
31 2
            return new Process($loop, $messenger);
32 1
        } catch (\Exception $exeption) {
33 1
            $messenger->error(MessagesFactory::error([
34 1
                'message' => $exeption->getMessage(),
35 1
                'code' => $exeption->getCode(),
36 1
                'line' => $exeption->getLine(),
37 1
                'file' => $exeption->getFile(),
38 1
            ]));
39
            $loop->addTimer(1, function () use ($loop) {
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a object<React\EventLoop\numeric>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40 1
                $loop->stop();
41 1
            });
42
        }
43
44 1
    }
45
46
    /**
47
     * Process constructor.
48
     * @param LoopInterface $loop
49
     * @param Messenger $messenger
50
     */
51 2
    protected function __construct(LoopInterface $loop, Messenger $messenger)
52
    {
53 2
        $this->loop = $loop;
54 2
        $this->messenger = $messenger;
55 2
        $this->messenger->registerRpc(
56 2
            MessengerFactory::PROCESS_REGISTER,
57
            function (Payload $payload) {
58 2
                if (!is_subclass_of($payload['className'], 'WyriHaximus\React\ChildProcess\Messenger\ChildInterface')) {
59 1
                    throw new \Exception('Given class doesn\'t implement ChildInterface');
60
                }
61
62 1
                $this->registerClass($payload['className']);
63 1
                $this->deregisterRpc();
64
65 1
                return \React\Promise\resolve([]);
66
            }
67 2
        );
68 1
    }
69
70
    /**
71
     * @param string $className
72
     */
73 1
    protected function registerClass($className)
74
    {
75 1
        call_user_func_array([
76 1
            $className,
77 1
            'create',
78 1
        ], [
79 1
            $this->messenger,
80 1
            $this->loop,
81 1
        ]);
82 1
    }
83
84
    protected function deregisterRpc()
85
    {
86 1
        $this->loop->futureTick(function () {
87 1
            $this->messenger->deregisterRpc(MessengerFactory::PROCESS_REGISTER);
88 1
        });
89 1
    }
90
}
91