Passed
Push — develop ( d6d0d2...d144b2 )
by Kevin
02:38
created

CacheFactory::getCache()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.2
c 0
b 0
f 0
cc 4
eloc 10
nc 2
nop 1
1
<?php
2
3
namespace Magium\Configuration\Manager;
4
5
use Zend\Cache\StorageFactory;
6
7
class CacheFactory
8
{
9
10
    public function getCache(\SimpleXMLElement $element)
11
    {
12
        $config = [
13
            'adapter'   => (string)$element->adapter,
14
            'options'   => []
15
        ];
16
        if (isset($element->options)) {
17
            foreach ($element->options->children() as $value) {
18
                if ($value instanceof \SimpleXMLElement) {
19
                    $config['options'][$value->getName()] = (string)$value;
20
                }
21
            }
22
        }
23
        $cache = StorageFactory::factory($config);
24
        return $cache;
25
    }
26
27
}
28