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.

ExamplesChildProcess::isPrime()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 4
nc 4
nop 1
1
<?php
2
3
use React\EventLoop\LoopInterface;
4
use WyriHaximus\React\ChildProcess\Messenger\ChildInterface;
5
use WyriHaximus\React\ChildProcess\Messenger\Messages\Factory as MessagesFactory;
6
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
7
use WyriHaximus\React\ChildProcess\Messenger\Messenger;
8
9
final class ExamplesChildProcess implements ChildInterface
10
{
11
    public static function create(Messenger $messenger, LoopInterface $loop): void
12
    {
13
        $messenger->registerRpc('error', function (Payload $payload) {
0 ignored issues
show
Unused Code introduced by
The parameter $payload is not used and could be removed. ( Ignorable by Annotation )

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

13
        $messenger->registerRpc('error', function (/** @scrutinizer ignore-unused */ Payload $payload) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
14
            throw new Exception('whoops');
15
        });
16
17
        $messenger->registerRpc('isPrime', function (Payload $payload) {
18
            return \React\Promise\resolve([
19
                'isPrime' => self::isPrime($payload['number']),
20
            ]);
21
        });
22
        $messenger->on('message', function (Payload $payload, Messenger $messenger) {
23
            $messenger->message(MessagesFactory::message([
24
                'time' => (new DateTime('@' . $payload['time'] * $payload['i']))->format('c'),
25
            ]));
26
        });
27
        $messenger->registerRpc('format', function (Payload $payload) {
28
            return \React\Promise\resolve([
29
                'formattedTime' => (new DateTime('@' . $payload['unixTime']))->format('c'),
30
            ]);
31
        });
32
        $messenger->registerRpc('overflow', function () {
33
            \ini_set('memory_limit', '20M');
34
35
            $string = '';
36
            while (true) {
37
                $string .= '0123456789';
38
            }
39
        });
40
    }
41
42
    public static function isPrime($n)
43
    {
44
        // Source: https://stackoverflow.com/a/39743570
45
        for ($i = $n >> 1; $i && $n % $i--; /* void */) {
46
            /* void */
47
        }
48
49
        return !$i && $n > 1;
50
    }
51
}
52