Driver_Theme   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 80
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A file() 0 13 2
B change() 0 45 6
1
<?php
2
3
/**
4
 * Provides XML file handling for theme 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 theme schemas
20
 *
21
 * @category  Core
22
 * @package   XML
23
 * @author    Hans-Joachim Piepereit <[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_Theme 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 == 'theme') {
48
49
            $file = 'csphere/themes/' . $name . '/theme.xml';
50
        }
51
52
        return $file;
53
    }
54
55
    /**
56
     * Change data array for easier usage
57
     *
58
     * @param array $array Formated array generated earlier
59
     *
60
     * @return array
61
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
62
63
    protected function change(array $array)
64
    {
65
        // Shorten array depth for common elements
66
        $array = $this->common($array);
67
68
        // Shorten array depth for array elements
69
        $array['contains']  = $array['contains'][0];
70
71
        // Shorten optional content if found
72
        if (!isset($array['environment'][0]['needed'])) {
73
74
            $array['environment'][0]['needed'] = [];
75
76
        } else {
77
78
            $env = [];
79
80
            foreach ($array['environment'][0]['needed'] AS $needed) {
81
82
                if (!isset($needed['version_max'])) {
83
84
                    $needed['version_max'] = '';
85
                }
86
87
                $env[] = $needed;
88
89
                $array['environment'][0]['needed'] = $env;
90
            }
91
        }
92
93
        if (!isset($array['environment'][0]['extend'])) {
94
95
            $array['environment'][0]['extend'] = [];
96
        }
97
98
        if (isset($array['media'])) {
99
100
            $array['media'] = $array['media'][0];
101
        }
102
103
        // Set icon URL
104
        $array['icon']['url'] = '';
105
106
        return $array;
107
    }
108
}
109