PHPFileReader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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