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.

PayloadResponseSerializer::deserialize()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.6511

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 7
cts 12
cp 0.5833
rs 9.6666
c 0
b 0
f 0
cc 3
nc 2
nop 2
crap 3.6511
1
<?php
2
3
/*
4
 * This file is part of the Slack API library.
5
 *
6
 * (c) Cas Leentfaar <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CL\Slack\Serializer;
13
14
use CL\Slack\Payload\PayloadResponseInterface;
15
16
/**
17
 * @author Cas Leentfaar <[email protected]>
18
 */
19
class PayloadResponseSerializer extends AbstractSerializer
20
{
21
    /**
22
     * @param array  $payloadResponse
23
     * @param string $payloadResponseClass
24
     *
25
     * @return PayloadResponseInterface
26
     */
27 114
    public function deserialize(array $payloadResponse, $payloadResponseClass)
28
    {
29 114
        $payloadResponseObject = $this->serializer->deserialize(
30 114
            json_encode($payloadResponse),
31 114
            $payloadResponseClass,
32
            'json'
33 114
        );
34
35 114
        if (!($payloadResponseObject instanceof PayloadResponseInterface)) {
36
            throw new \RuntimeException(sprintf(
37
                'The serializer expected the response data to be converted into an instance of "%s", got: %s',
38
                $payloadResponseClass,
39
                is_object($payloadResponseObject) ? 'instance of ' . get_class($payloadResponseObject) : gettype($payloadResponseObject)
40
            ));
41
        }
42
43 114
        return $payloadResponseObject;
44
    }
45
}
46