Completed
Push — master ( 03d9da...2dac9a )
by Tom
13s
created

PHPFileReader::assertConfigIsValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace TomPHP\ContainerConfigurator\FileReader;
4
5
use Assert\Assertion;
6
use TomPHP\ContainerConfigurator\Exception\InvalidConfigException;
7
8
final class PHPFileReader implements FileReader
9
{
10
    private $filename;
11
12
    public function read($filename)
13
    {
14
        Assertion::file($filename);
15
16
        $this->filename = $filename;
17
18
        $config = include $this->filename;
19
20
        $this->assertConfigIsValid($config);
21
22
        return $config;
23
    }
24
25
    private function assertConfigIsValid($config)
26
    {
27
        if (!is_array($config)) {
28
            throw InvalidConfigException::fromPHPFileError($this->filename);
29
        }
30
    }
31
}
32