Completed
Push — master ( 8c1053...9934c8 )
by Woody
07:00
created

YamlLoader::isSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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