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
Pull Request — master (#31)
by
unknown
05:59
created

MSGPack::parse()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 4
eloc 13
c 3
b 0
f 2
nc 4
nop 1
dl 0
loc 23
ccs 10
cts 10
cp 1
crap 4
rs 8.7972
1
<?php
2
3
namespace Nathanmac\Utilities\Parser\Formats;
4
5
use Nathanmac\Utilities\Parser\Exceptions\ParserException;
6
7
/**
8
 * MSGPack 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 MSGPack implements FormatInterface
15
{
16
    /**
17
     * Parse Payload Data
18
     *
19
     * @param string $payload
20
     *
21
     * @throws ParserException
22
     *
23
     * @return array
24
     */
25 7
    public function parse($payload)
26
    {
27 7
        if (function_exists('msgpack_unpack')) {
28 6
            if ($payload) {
29 4
                $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
0 ignored issues
show
Unused Code introduced by
The parameter $errno is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $errstr is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $errfile is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $errline is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $errcontext is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
                    throw new ParserException('Failed To Parse MSGPack');  // @codeCoverageIgnore
31 4
                });
32
33 4
                $msg = msgpack_unpack(trim($payload));
34 2
                if ( ! $msg) {
35
                    set_error_handler($prevHandler);  // @codeCoverageIgnore
36
                    throw new ParserException('Failed To Parse MSGPack');  // @codeCoverageIgnore
37
                }
38
39 2
                set_error_handler($prevHandler);
40
41 2
                return $msg;
42
            }
43 2
            return [];
44
        }
45
46
        throw new ParserException('Failed To Parse MSGPack - Supporting Library Not Available');  // @codeCoverageIgnore
47
    }
48
}
49