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.

Message::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
ccs 0
cts 0
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\React\ChildProcess\Messenger\Messages;
6
7
use JsonSerializable;
8
9
final class Message implements JsonSerializable, ActionableMessageInterface
10
{
11
    protected Payload $payload;
12
13
    public function __construct(Payload $payload)
14
    {
15 3
        $this->payload = $payload;
16
    }
17 3
18 3
    public function getPayload(): Payload
19
    {
20
        return $this->payload;
21
    }
22
23 2
    /**
24
     * @return array<string, string|Payload>
25 2
     */
26
    public function jsonSerialize(): array
27
    {
28
        return [
29
            'type' => 'message',
30
            'payload' => $this->payload,
31 2
        ];
32
    }
33
34 2
    public function handle(object $bindTo, string $source): void
35 2
    {
36
        $cb = function (Payload $payload): void {
37
            /**
38
             * @psalm-suppress UndefinedMethod
39
             */
40
            $this->emit('message', [ /** @phpstan-ignore-line  */
0 ignored issues
show
Bug introduced by
The method emit() does not exist on WyriHaximus\React\ChildP...senger\Messages\Message. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            $this->/** @scrutinizer ignore-call */ 
41
                   emit('message', [ /** @phpstan-ignore-line  */

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...
41
                $payload,
42
                $this,
43
            ]);
44
        };
45 1
        $cb = $cb->bindTo($bindTo);
46 1
        /**
47 1
         * @psalm-suppress PossiblyInvalidFunctionCall
48 1
         */
49
        $cb($this->payload);
50 1
    }
51
}
52