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 ( a10806...afde92 )
by Cees-Jan
03:04
created

LineEncoder::encode()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 17.6982

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 5
cts 16
cp 0.3125
rs 8.439
c 0
b 0
f 0
cc 6
eloc 18
nc 4
nop 1
crap 17.6982
1
<?php
2
3
namespace WyriHaximus\React\ChildProcess\Messenger\Messages;
4
5
use Cake\Utility\Hash;
6
use Exception;
7
use Throwable;
8
9
final class LineEncoder
10
{
11
    const META_KEY = 'a';
12
    const TYPE_KEY = 'b';
13
    const VALUE_KEY = 'c';
14
    const THROWABLES_KEY = 'd';
15
    const TYPE_THROWABLE = 'e';
16
    const TYPE_ARRAY = 'f';
17
18 2
    public static function encode($line)
19
    {
20 2
        if ($line instanceof Exception || $line instanceof Throwable) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
21
            return [
22 2
                self::META_KEY => [
23 2
                    self::TYPE_KEY => self::TYPE_THROWABLE,
24
                ],
25 2
                self::VALUE_KEY => \WyriHaximus\throwable_encode($line),
26
            ];
27
        }
28
29
        $throwables = [];
30
        $line = Hash::flatten($line);
31
        foreach ($line as $key => $value) {
32
            if (!($value instanceof Exception) && !($value instanceof Throwable)) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
33
                continue;
34
            }
35
36
            $throwables[] = $key;
37
            $line[$key] = \WyriHaximus\throwable_encode($value);
38
        }
39
40
        return [
41
            self::META_KEY => [
42
                self::TYPE_KEY => self::TYPE_ARRAY,
43
                self::THROWABLES_KEY => $throwables,
44
            ],
45
            self::VALUE_KEY => $line,
46
        ];
47
    }
48
}
49