Completed
Push — master ( bf1c9e...8c1053 )
by Woody
13s
created

YamlLoader::load()   A

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
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Northwoods\Config\Loader;
4
5
use Symfony\Component\Yaml\Parser;
6
7
class YamlLoader implements LoaderInterface
8
{
9 3
    public static function isSupported()
10
    {
11 3
        return class_exists(Parser::class);
12
    }
13
14
    /**
15
     * @var Parser
16
     */
17
    private $parser;
18
19 3
    public function __construct()
20
    {
21 3
        $this->parser = new Parser();
22 3
    }
23
24 2
    public function load($path)
25
    {
26 2
        if (is_file("$path.yaml")) {
27 2
            return $this->parser->parse(file_get_contents("$path.yaml"));
28
        } else {
29 2
            return [];
30
        }
31
    }
32
}
33