ConfigurationRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 35
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasValue() 0 7 1
A getValue() 0 11 2
A getValueFlag() 0 10 3
1
<?php
2
3
namespace Magium\Configuration\Config\Repository;
4
5
class ConfigurationRepository extends \SimpleXMLElement implements ConfigInterface
6
{
7
8 1
    public function hasValue($path)
9
    {
10 1
        list($section, $group, $element) = explode('/', $path);
11 1
        $xpath = sprintf('/*/%s/%s/%s', $section, $group, $element);
12 1
        $element = $this->xpath($xpath);
13 1
        return !empty($element);
14
    }
15
16 11
    public function getValue($path)
17
    {
18 11
        list($section, $group, $element) = explode('/', $path);
19 11
        $xpath = sprintf('/*/%s/%s/%s', $section, $group, $element);
20 11
        $element = $this->xpath($xpath);
21 11
        if (empty($element)) {
22 3
            return null;
23
        }
24 10
        $value = (string)$element[0];
25 10
        return $value;
26
    }
27
28 2
    public function getValueFlag($path)
29
    {
30 2
        $value = $this->getValue($path);
31 2
        foreach (self::ALLOWED_TRUES as $true) {
32 2
            if ($value === $true) {
33 2
                return true;
34
            }
35
        }
36 2
        return false;
37
    }
38
39
}
40