AbstractConfig   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 31
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A checkRequirements() 0 10 3
A getFilename() 0 4 1
getRequirements() 0 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