PHPFileReader::assertConfigIsValid()   A
last analyzed

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
/**
9
 * @internal
10
 */
11
final class PHPFileReader implements FileReader
12
{
13
    private $filename;
14
15
    public function read($filename)
16
    {
17
        Assertion::file($filename);
18
19
        $this->filename = $filename;
20
21
        $config = include $this->filename;
22
23
        $this->assertConfigIsValid($config);
24
25
        return $config;
26
    }
27
28
    private function assertConfigIsValid($config)
29
    {
30
        if (!is_array($config)) {
31
            throw InvalidConfigException::fromPHPFileError($this->filename);
32
        }
33
    }
34
}
35