-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConfigurationRepository.php
More file actions
39 lines (33 loc) · 1006 Bytes
/
ConfigurationRepository.php
File metadata and controls
39 lines (33 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Magium\Configuration\Config\Repository;
class ConfigurationRepository extends \SimpleXMLElement implements ConfigInterface
{
public function hasValue($path)
{
list($section, $group, $element) = explode('/', $path);
$xpath = sprintf('/*/%s/%s/%s', $section, $group, $element);
$element = $this->xpath($xpath);
return !empty($element);
}
public function getValue($path)
{
list($section, $group, $element) = explode('/', $path);
$xpath = sprintf('/*/%s/%s/%s', $section, $group, $element);
$element = $this->xpath($xpath);
if (empty($element)) {
return null;
}
$value = (string)$element[0];
return $value;
}
public function getValueFlag($path)
{
$value = $this->getValue($path);
foreach (self::ALLOWED_TRUES as $true) {
if ($value === $true) {
return true;
}
}
return false;
}
}