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.
Passed
Push — master ( d51b8c...fe7d43 )
by Cees-Jan
02:47
created

psr7_response_json_decode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WyriHaximus;
4
5
use Psr\Http\Message\ResponseInterface;
6
use RingCentral\Psr7\Response;
7
8
function psr7_response_json_encode(ResponseInterface $response): string
9
{
10 1
    return json_encode(psr7_response_encode($response));
11
}
12
13
function psr7_response_encode(ResponseInterface $response): array
14
{
15 2
    $json = [];
16 2
    $json['protocol_version'] = $response->getProtocolVersion();
17 2
    $json['status_code'] = $response->getStatusCode();
18 2
    $json['reason_phrase'] = $response->getReasonPhrase();
19 2
    $json['headers'] = $response->getHeaders();
20 2
    $json['body'] = $response->getBody()->getContents();
21
22 2
    return $json;
23
}
24
25
/**
26
 * @throws NotAnEncodedResponseException
27
 */
28
function psr7_response_json_decode(string $json): ResponseInterface
29
{
30 1
    return psr7_response_decode(json_decode($json, true));
31
}
32
33
/**
34
 * @throws NotAnEncodedResponseException
35
 */
36
function psr7_response_decode(array $json): ResponseInterface
37
{
38
    $properties = [
39 2
        'protocol_version',
40
        'status_code',
41
        'reason_phrase',
42
        'headers',
43
        'body',
44
    ];
45
46 2
    foreach ($properties as $property) {
47 2
        if (!isset($json[$property])) {
48 2
            throw new NotAnEncodedResponseException($json);
49
        }
50
    }
51
52 2
    return new Response(
53 2
        $json['status_code'],
54 2
        $json['headers'],
55 2
        $json['body'],
56 2
        $json['protocol_version'],
57 2
        $json['reason_phrase']
58
    );
59
}
60