Driver_Access   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A file() 0 13 2
B change() 0 22 4
1
<?php
2
3
/**
4
 * Provides XML file handling for database schemas
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   XML
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\xml;
17
18
/**
19
 * Provides XML file handling for access schemas
20
 *
21
 * @category  Core
22
 * @package   XML
23
 * @author    Daniel Schalla <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
class Driver_Access extends Base
30
{
31
    /**
32
     * Determine the driver specific source file
33
     *
34
     * @param string $type Type of target, e.g. plugin
35
     * @param string $name Directory name of the target
36
     * @param string $lang Language if more than one is possible
37
     *
38
     * @return string
39
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
40
41
    protected function file($type, $name, $lang)
42
    {
43
        unset($lang);
44
45
        $file = '';
46
47
        if ($type == 'plugin') {
48
49
            $file = 'csphere/plugins/' . $name . '/access.xml';
50
        }
51
52
        return $file;
53
    }
54
55
56
    /**
57
     * Change data array for easier usage
58
     *
59
     * @param array $array Formated array generated earlier
60
     *
61
     * @throws \ErrorException if the access file is malformed
62
     * @return array
63
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
64
65
    protected function change(array $array)
66
    {
67
        $ret = [];
68
69
        foreach ($array['permission'] as $permission) {
70
71
            if (!isset($permission['attr'][0]['name'])
72
                || !isset($permission['type'][0]['value'])
73
            ) {
74
                throw new \ErrorException(
75
                    "Malformed Access File of Plugin: " . $this->path
76
                );
77
            }
78
79
            $tmp = [];
80
            $tmp['type'] = $permission['type'][0]['value'];
81
82
            $ret[$permission['attr'][0]['name']] = $tmp;
83
        }
84
85
        return $ret;
86
    }
87
88
}
89