| Conditions | 11 |
| Paths | 512 |
| Total Lines | 126 |
| Code Lines | 93 |
| Lines | 0 |
| Ratio | 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 |
||
| 135 | function _gather(){ |
||
| 136 | global $conf; |
||
| 137 | /** @var $auth DokuWiki_Auth_Plugin */ |
||
| 138 | global $auth; |
||
| 139 | $data = array(); |
||
| 140 | $phptime = ini_get('max_execution_time'); |
||
| 141 | @set_time_limit(0); |
||
|
1 ignored issue
–
show
|
|||
| 142 | $pluginInfo = $this->getInfo(); |
||
| 143 | |||
| 144 | // version |
||
| 145 | $data['anon_id'] = md5(auth_cookiesalt()); |
||
| 146 | $data['version'] = getVersion(); |
||
| 147 | $data['popversion'] = $pluginInfo['date']; |
||
| 148 | $data['language'] = $conf['lang']; |
||
| 149 | $data['now'] = time(); |
||
| 150 | $data['popauto'] = (int) $this->isAutoSubmitEnabled(); |
||
| 151 | |||
| 152 | // some config values |
||
| 153 | $data['conf_useacl'] = $conf['useacl']; |
||
| 154 | $data['conf_authtype'] = $conf['authtype']; |
||
| 155 | $data['conf_template'] = $conf['template']; |
||
| 156 | |||
| 157 | // number and size of pages |
||
| 158 | $list = array(); |
||
| 159 | search($list,$conf['datadir'],array($this,'_search_count'),array('all'=>false),''); |
||
| 160 | $data['page_count'] = $list['file_count']; |
||
| 161 | $data['page_size'] = $list['file_size']; |
||
| 162 | $data['page_biggest'] = $list['file_max']; |
||
| 163 | $data['page_smallest'] = $list['file_min']; |
||
| 164 | $data['page_nscount'] = $list['dir_count']; |
||
| 165 | $data['page_nsnest'] = $list['dir_nest']; |
||
| 166 | if($list['file_count']) $data['page_avg'] = $list['file_size'] / $list['file_count']; |
||
| 167 | $data['page_oldest'] = $list['file_oldest']; |
||
| 168 | unset($list); |
||
| 169 | |||
| 170 | // number and size of media |
||
| 171 | $list = array(); |
||
| 172 | search($list,$conf['mediadir'],array($this,'_search_count'),array('all'=>true)); |
||
| 173 | $data['media_count'] = $list['file_count']; |
||
| 174 | $data['media_size'] = $list['file_size']; |
||
| 175 | $data['media_biggest'] = $list['file_max']; |
||
| 176 | $data['media_smallest'] = $list['file_min']; |
||
| 177 | $data['media_nscount'] = $list['dir_count']; |
||
| 178 | $data['media_nsnest'] = $list['dir_nest']; |
||
| 179 | if($list['file_count']) $data['media_avg'] = $list['file_size'] / $list['file_count']; |
||
| 180 | unset($list); |
||
| 181 | |||
| 182 | // number and size of cache |
||
| 183 | $list = array(); |
||
| 184 | search($list,$conf['cachedir'],array($this,'_search_count'),array('all'=>true)); |
||
| 185 | $data['cache_count'] = $list['file_count']; |
||
| 186 | $data['cache_size'] = $list['file_size']; |
||
| 187 | $data['cache_biggest'] = $list['file_max']; |
||
| 188 | $data['cache_smallest'] = $list['file_min']; |
||
| 189 | if($list['file_count']) $data['cache_avg'] = $list['file_size'] / $list['file_count']; |
||
| 190 | unset($list); |
||
| 191 | |||
| 192 | // number and size of index |
||
| 193 | $list = array(); |
||
| 194 | search($list,$conf['indexdir'],array($this,'_search_count'),array('all'=>true)); |
||
| 195 | $data['index_count'] = $list['file_count']; |
||
| 196 | $data['index_size'] = $list['file_size']; |
||
| 197 | $data['index_biggest'] = $list['file_max']; |
||
| 198 | $data['index_smallest'] = $list['file_min']; |
||
| 199 | if($list['file_count']) $data['index_avg'] = $list['file_size'] / $list['file_count']; |
||
| 200 | unset($list); |
||
| 201 | |||
| 202 | // number and size of meta |
||
| 203 | $list = array(); |
||
| 204 | search($list,$conf['metadir'],array($this,'_search_count'),array('all'=>true)); |
||
| 205 | $data['meta_count'] = $list['file_count']; |
||
| 206 | $data['meta_size'] = $list['file_size']; |
||
| 207 | $data['meta_biggest'] = $list['file_max']; |
||
| 208 | $data['meta_smallest'] = $list['file_min']; |
||
| 209 | if($list['file_count']) $data['meta_avg'] = $list['file_size'] / $list['file_count']; |
||
| 210 | unset($list); |
||
| 211 | |||
| 212 | // number and size of attic |
||
| 213 | $list = array(); |
||
| 214 | search($list,$conf['olddir'],array($this,'_search_count'),array('all'=>true)); |
||
| 215 | $data['attic_count'] = $list['file_count']; |
||
| 216 | $data['attic_size'] = $list['file_size']; |
||
| 217 | $data['attic_biggest'] = $list['file_max']; |
||
| 218 | $data['attic_smallest'] = $list['file_min']; |
||
| 219 | if($list['file_count']) $data['attic_avg'] = $list['file_size'] / $list['file_count']; |
||
| 220 | $data['attic_oldest'] = $list['file_oldest']; |
||
| 221 | unset($list); |
||
| 222 | |||
| 223 | // user count |
||
| 224 | if($auth && $auth->canDo('getUserCount')){ |
||
| 225 | $data['user_count'] = $auth->getUserCount(); |
||
| 226 | } |
||
| 227 | |||
| 228 | // calculate edits per day |
||
| 229 | $list = @file($conf['metadir'].'/_dokuwiki.changes'); |
||
| 230 | $count = count($list); |
||
| 231 | if($count > 2){ |
||
| 232 | $first = (int) substr(array_shift($list),0,10); |
||
| 233 | $last = (int) substr(array_pop($list),0,10); |
||
| 234 | $dur = ($last - $first)/(60*60*24); // number of days in the changelog |
||
| 235 | $data['edits_per_day'] = $count/$dur; |
||
| 236 | } |
||
| 237 | unset($list); |
||
| 238 | |||
| 239 | // plugins |
||
| 240 | $data['plugin'] = plugin_list(); |
||
| 241 | |||
| 242 | // pcre info |
||
| 243 | if(defined('PCRE_VERSION')) $data['pcre_version'] = PCRE_VERSION; |
||
| 244 | $data['pcre_backtrack'] = ini_get('pcre.backtrack_limit'); |
||
| 245 | $data['pcre_recursion'] = ini_get('pcre.recursion_limit'); |
||
| 246 | |||
| 247 | // php info |
||
| 248 | $data['os'] = PHP_OS; |
||
| 249 | $data['webserver'] = $_SERVER['SERVER_SOFTWARE']; |
||
| 250 | $data['php_version'] = phpversion(); |
||
| 251 | $data['php_sapi'] = php_sapi_name(); |
||
| 252 | $data['php_memory'] = $this->_to_byte(ini_get('memory_limit')); |
||
| 253 | $data['php_exectime'] = $phptime; |
||
| 254 | $data['php_extension'] = get_loaded_extensions(); |
||
| 255 | |||
| 256 | // plugin usage data |
||
| 257 | $this->_add_plugin_usage_data($data); |
||
| 258 | |||
| 259 | return $data; |
||
| 260 | } |
||
| 261 | |||
| 341 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.