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.

Serialize::parse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 12
ccs 6
cts 6
cp 1
crap 3
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
namespace Nathanmac\Utilities\Parser\Formats;
4
5
use Nathanmac\Utilities\Parser\Exceptions\ParserException;
6
7
/**
8
 * Serialize Formatter
9
 *
10
 * @package    Nathanmac\Utilities\Parser\Formats
11
 * @author     Nathan Macnamara <[email protected]>
12
 * @license    https://github.com/nathanmac/Parser/blob/master/LICENSE.md  MIT
13
 */
14
class Serialize implements FormatInterface
15
{
16
    /**
17
     * Parse Payload Data
18
     *
19
     * @param string $payload
20
     *
21
     * @throws ParserException
22
     * @return array
23
     *
24
     */
25 15
    public function parse($payload)
26
    {
27 15
        if ($payload) {
28
            try {
29 12
                return unserialize(trim($payload));
30 6
            } catch (\Exception $ex) {
31 6
                throw new ParserException('Failed To Parse Serialized Data');
32
            }
33
        }
34
35 3
        return [];
36
    }
37
}
38