AbstractConfig::getFilename()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace G2R\Config;
4
5
use G2R\Exception\Exception;
6
use Noodlehaus\Config;
7
8
abstract class AbstractConfig extends Config
9
{
10
    protected $path;
11
12 20
    public function __construct($path)
13
    {
14 20
        parent::__construct($path);
15
16 20
        $this->path = $path;
17
18 20
        $this->checkRequirements($this->getRequirements());
19 18
    }
20
21 20
    protected function checkRequirements(array $fields)
22
    {
23 20
        foreach ($fields as $field) {
24 20
            if (is_null($this->get($field))) {
25 2
                throw new Exception(
26 11
                    "The field {$field} is missing in {$this->path}"
27
                );
28
            }
29
        }
30 18
    }
31
32 2
    public function getFilename()
33
    {
34 2
        return $this->path;
35
    }
36
37
    abstract protected function getRequirements();
38
}
39