YamlAndNeonParser::decode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Configuration\Parser;
11
12
use Nette\Neon\Neon;
13
use Symfony\Component\Yaml\Yaml;
14
use Throwable;
15
16
final class YamlAndNeonParser
17
{
18 2
    public function decodeFromFile(string $filePath) : array
19
    {
20 2
        $fileContent = file_get_contents($filePath);
21
22 2
        return $this->decode($fileContent);
23
    }
24
25 5
    public function decode(string $content) : array
26
    {
27
        try {
28 5
            return Neon::decode($content);
29 1
        } catch (Throwable $throwable) {
30 1
            return Yaml::parse($content);
31
        }
32
    }
33
}
34