Completed
Push — master ( 3ef429...ea7bca )
by Matt
12s
created

YamlDecoder::decode()   A

Complexity

Conditions 2
Paths 2

Duplication

Lines 0
Ratio 0 %

Size

Total Lines 8
Code Lines 5

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 1
b 0
f 1
1
<?php
2
3
namespace League\JsonReference\Decoder;
4
5
use League\JsonReference\DecoderInterface;
6
use League\JsonReference\DecodingException;
7
8
use Symfony\Component\Yaml\Exception\ParseException;
9
use Symfony\Component\Yaml\Yaml;
10
11
final class YamlDecoder implements DecoderInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 4
    public function decode($schema)
17
    {
18
        try {
19 4
            return Yaml::parse($schema, Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
20 2
        } catch (ParseException $e) {
21 2
            throw new DecodingException(sprintf('Invalid Yaml: %s', $e->getMessage()), $e->getCode(), $e);
22
        }
23
    }
24
}
25