Conditions | 12 |
Paths | 13 |
Total Lines | 66 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
60 | public function cssStyleini() |
||
61 | { |
||
62 | static $combined = []; |
||
63 | if (!empty($combined) && !$this->reinit) { |
||
64 | return $combined; |
||
65 | } |
||
66 | |||
67 | global $conf; |
||
68 | global $config_cascade; |
||
69 | $stylesheets = array(); // mode, file => base |
||
70 | |||
71 | // guaranteed placeholder => value |
||
72 | $replacements = $this->defaultReplacements; |
||
73 | |||
74 | // merge all styles from config cascade |
||
75 | if (!is_array($config_cascade['styleini'])) { |
||
76 | trigger_error('Missing config cascade for styleini', E_USER_WARNING); |
||
77 | } |
||
78 | |||
79 | // allow replacement overwrites in preview mode |
||
80 | if ($this->preview) { |
||
81 | $config_cascade['styleini']['local'][] = $conf['cachedir'] . '/preview.ini'; |
||
82 | } |
||
83 | |||
84 | $combined['stylesheets'] = []; |
||
85 | $combined['replacements'] = []; |
||
86 | |||
87 | foreach (array('default', 'local', 'protected') as $config_group) { |
||
88 | if (empty($config_cascade['styleini'][$config_group])) continue; |
||
89 | |||
90 | // set proper server dirs |
||
91 | $webbase = $this->getWebbase($config_group); |
||
92 | |||
93 | foreach ($config_cascade['styleini'][$config_group] as $inifile) { |
||
94 | // replace the placeholder with the name of the current template |
||
95 | $inifile = str_replace('%TEMPLATE%', $this->tpl, $inifile); |
||
96 | |||
97 | $incbase = dirname($inifile) . '/'; |
||
98 | |||
99 | if (file_exists($inifile)) { |
||
100 | $config = parse_ini_file($inifile, true); |
||
101 | |||
102 | if (is_array($config['stylesheets'])) { |
||
103 | foreach ($config['stylesheets'] as $inifile => $mode) { |
||
104 | // validate and include style files |
||
105 | $stylesheets = array_merge( |
||
106 | $stylesheets, |
||
107 | $this->getValidatedStyles($stylesheets, $inifile, $mode, $incbase, $webbase) |
||
108 | ); |
||
109 | $combined['stylesheets'] = array_merge($combined['stylesheets'], $stylesheets); |
||
110 | } |
||
111 | } |
||
112 | |||
113 | if (is_array($config['replacements'])) { |
||
114 | $replacements = array_replace( |
||
115 | $replacements, |
||
116 | $this->cssFixreplacementurls($config['replacements'], $webbase) |
||
117 | ); |
||
118 | $combined['replacements'] = array_merge($combined['replacements'], $replacements); |
||
119 | } |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | |||
124 | return $combined; |
||
125 | } |
||
126 | |||
195 |