Test Failed
Pull Request — develop (#18)
by Kevin
02:51
created

AbstractContextConfigurationFile::getContexts()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Magium\Configuration\File\Context;
4
5
use Magium\Configuration\Config\Config;
6
use Magium\Configuration\File\AbstractAdapter;
7
8
abstract class AbstractContextConfigurationFile extends AbstractAdapter
9
{
10
    protected function configureSchema(\DOMElement $element)
11
    {
12
        $schema = realpath(__DIR__ . '/../../../assets/context.xsd');
13
        $element->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.magiumlib.com/ConfigurationContext');
14
        $element->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://www.magiumlib.com/ConfigurationContext ' . $schema);
15
        return $schema;
16
    }
17
18 View Code Duplication
    public function getContexts()
19
    {
20
        $contexts = [Config::CONTEXT_DEFAULT];
21
        $configuredContexts = $this->toXml()->xpath('//s:context');
22
        foreach ($configuredContexts as $context) {
23
            $contexts[] = (string)$context['id'];
24
        }
25
        return $contexts;
26
    }
27
}
28