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

YamlLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSupported() 0 4 1
A __construct() 0 4 1
A load() 0 8 2
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