configureSchema()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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