ConfigurationRepository::getValueFlag()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 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