Passed
Pull Request — master (#14)
by
unknown
02:46
created

YamlLoader::unload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Northwoods\Config\Loader;
5
6
use Symfony\Component\Yaml\Parser;
7
8
class YamlLoader implements LoaderInterface
9
{
10 3
    public static function isSupported(): bool
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
11
    {
12 3
        return class_exists(Parser::class);
13
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
14
15
    /** @var Parser */
16
    private $parser;
0 ignored issues
show
Coding Style introduced by
Private member variable "parser" must contain a leading underscore
Loading history...
17
18 3
    public function __construct(Parser $parser = null)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
19
    {
20 3
        $this->parser = $parser ?? new Parser();
21 3
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
22
23 2
    public function load(string $path): array
24
    {
25 2
        if (is_file("$path.yaml")) {
26 2
            return $this->parser->parse(file_get_contents("$path.yaml"));
27
        }
28
29 2
        return [];
30
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
31
32
    public function unload(string $path, array $data) {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
33
        
34
        throw LoaderException::notSupportedMethod('unload', static::class);
35
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
36
}
37