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.

YAML::parse()   A
last analyzed

Complexity

Conditions 4
Paths 7

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

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