Directory   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 31
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B parse() 0 15 7
A getContexts() 0 3 1
1
<?php
2
3
namespace ntentan\config;
4
5
class Directory
6
{
7
8
    private $path;
9
    private $contexts = [];
10
11 3
    public function __construct($path) {
12 3
        $this->path = $path;
13 3
    }
14
15 3
    public function parse($path = '') {
16 3
        $config = [];
17 3
        $dir = "$this->path/$path";
18 3
        $files = scandir($dir);
19 3
        foreach ($files as $file) {
20 3
            if (fnmatch("*.conf.php", $file)) {
21 3
                $prefix = substr($file, 0, -9);
22 3
                $config[$prefix] = File::read("$dir/$file");
23 3
            } else if (is_dir("{$this->path}/$file") && $file != '.' && $file != '..' && $path === '') {
24 3
                $this->contexts[] = $file;
25
            }
26
        }
27
28 3
        return $config;
29
    }
30
31 3
    public function getContexts() {
32 3
        return $this->contexts;
33
    }
34
35
}
36