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

YAMLFileReader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 15
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 12 2
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