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.

PayloadSerializer::serialize()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.7691

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 7
cts 11
cp 0.6364
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4.7691
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\AdvancedSerializeInterface;
15
use CL\Slack\Payload\PayloadInterface;
16
17
/**
18
 * @author Cas Leentfaar <[email protected]>
19
 */
20
class PayloadSerializer extends AbstractSerializer
21
{
22
    /**
23
     * @param PayloadInterface $payload
24
     *
25
     * @return array The serialized payload data
26
     */
27 59
    public function serialize(PayloadInterface $payload)
28
    {
29 59
        if ($payload instanceof AdvancedSerializeInterface) {
30 1
            $payload->beforeSerialize($this->serializer);
31 1
        }
32
33 59
        $serializedPayload = $this->serializer->serialize($payload, 'json');
34
35 59
        if (!$serializedPayload || !is_string($serializedPayload)) {
36
            throw new \RuntimeException(sprintf(
37
                'Failed to serialize payload; expected it to be a string, got: %s',
38
                var_export($serializedPayload, true)
39
            ));
40
        }
41
42 59
        return json_decode($serializedPayload, true);
43
    }
44
}
45