Completed
Pull Request — master (#19)
by Andreas
03:20
created

YAMLFileReader::read()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace TomPHP\ContainerConfigurator\FileReader;
4
5
use Assert\Assertion;
6
use Symfony\Component\Yaml;
7
use TomPHP\ContainerConfigurator\Exception\InvalidConfigException;
8
9
final class YAMLFileReader implements FileReader
10
{
11
    public function read($filename)
12
    {
13
        Assertion::file($filename);
14
15
        try {
16
            $config = Yaml\Yaml::parse(file_get_contents($filename));
17
        } catch (Yaml\Exception\ParseException $exception) {
18
            throw InvalidConfigException::fromYAMLFileError($filename, $exception->getMessage());
19
        }
20
21
        return $config;
22
    }
23
}
24