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

Rpc::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
namespace WyriHaximus\React\ChildProcess\Messenger\Messages;
4
5
use React\Promise\Deferred;
6
use React\Promise\RejectedPromise;
7
8
class Rpc implements \JsonSerializable, ActionableMessageInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $target;
14
15
    /**
16
     * @var Payload
17
     */
18
    protected $payload;
19
20
    /**
21
     * @var string
22
     */
23
    protected $uniqid;
24
25
    /**
26
     * @param string $target
27
     * @param Payload $payload
28
     * @param string $uniqid
29
     */
30 11
    public function __construct($target, Payload $payload, $uniqid = '')
31
    {
32 11
        $this->target = $target;
33 11
        $this->payload = $payload;
34 11
        $this->uniqid = $uniqid;
35 11
    }
36
37
    /**
38
     * @return Payload
39
     */
40 3
    public function getPayload()
41
    {
42 3
        return $this->payload;
43
    }
44
45
    /**
46
     * @param $uniqid
47
     * @return static
48
     */
49 3
    public function setUniqid($uniqid)
50
    {
51 3
        return new static($this->target, $this->payload, $uniqid);
52
    }
53
54
    /**
55
     * @return string
56
     */
57 9
    public function jsonSerialize()
58
    {
59
        return [
60 9
            'type' => 'rpc',
61 9
            'uniqid' => $this->uniqid,
62 9
            'target' => $this->target,
63 9
            'payload' => $this->payload,
64 9
        ];
65
    }
66
67
    /**
68
     * @param $bindTo
69
     * @param $source
70
     */
71 4
    public function handle($bindTo, $source)
72
    {
73
        $cb = function ($target, $payload, $uniqid) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $cb. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
74 4
            if (!$this->hasRpc($target)) {
0 ignored issues
show
Bug introduced by
The method hasRpc() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75 1
                $this->getStderr()->write($this->createLine(Factory::rpcError($uniqid, [
0 ignored issues
show
Bug introduced by
The method getStderr() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method createLine() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76 1
                    'message' => 'Target doesn\'t exist',
77 1
                ])));
78 1
                return;
79
            }
80
81 3
            $this->callRpc($target, $payload)->then(
0 ignored issues
show
Bug introduced by
The method callRpc() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
82
                function (array $payload) use ($uniqid) {
83 1
                    $this->getStdout()->write($this->createLine(Factory::rpcSuccess($uniqid, $payload)));
0 ignored issues
show
Bug introduced by
The method getStdout() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method createLine() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84 3
                },
85
                function ($error) use ($uniqid) {
86 1
                    $this->getStderr()->write($this->createLine(Factory::rpcError($uniqid, [
0 ignored issues
show
Bug introduced by
The method getStderr() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method createLine() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
87 1
                        'error' => $error,
88 1
                    ])));
89 3
                },
90 1
                function (array $payload) use ($uniqid) {
91 1
                    $this->getStdout()->write($this->createLine(Factory::rpcNotify($uniqid, $payload)));
0 ignored issues
show
Bug introduced by
The method getStdout() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method createLine() does not seem to exist on object<WyriHaximus\React...Messenger\Messages\Rpc>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92 1
                }
93 3
            );
94 4
        };
95 4
        $cb = $cb->bindTo($bindTo);
96 4
        $cb($this->target, $this->payload, $this->uniqid);
97 4
    }
98
}
99