| Conditions | 11 |
| Paths | 512 |
| Total Lines | 126 |
| Code Lines | 93 |
| 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 |
||
| 100 | protected function _gather(){ |
||
| 101 | global $conf; |
||
| 102 | /** @var $auth DokuWiki_Auth_Plugin */ |
||
| 103 | global $auth; |
||
| 104 | $data = array(); |
||
| 105 | $phptime = ini_get('max_execution_time'); |
||
| 106 | @set_time_limit(0); |
||
|
1 ignored issue
–
show
|
|||
| 107 | $pluginInfo = $this->getInfo(); |
||
| 108 | |||
| 109 | // version |
||
| 110 | $data['anon_id'] = md5(auth_cookiesalt()); |
||
| 111 | $data['version'] = getVersion(); |
||
| 112 | $data['popversion'] = $pluginInfo['date']; |
||
| 113 | $data['language'] = $conf['lang']; |
||
| 114 | $data['now'] = time(); |
||
| 115 | $data['popauto'] = (int) $this->isAutoSubmitEnabled(); |
||
| 116 | |||
| 117 | // some config values |
||
| 118 | $data['conf_useacl'] = $conf['useacl']; |
||
| 119 | $data['conf_authtype'] = $conf['authtype']; |
||
| 120 | $data['conf_template'] = $conf['template']; |
||
| 121 | |||
| 122 | // number and size of pages |
||
| 123 | $list = array(); |
||
| 124 | search($list,$conf['datadir'],array($this,'_search_count'),array('all'=>false),''); |
||
| 125 | $data['page_count'] = $list['file_count']; |
||
| 126 | $data['page_size'] = $list['file_size']; |
||
| 127 | $data['page_biggest'] = $list['file_max']; |
||
| 128 | $data['page_smallest'] = $list['file_min']; |
||
| 129 | $data['page_nscount'] = $list['dir_count']; |
||
| 130 | $data['page_nsnest'] = $list['dir_nest']; |
||
| 131 | if($list['file_count']) $data['page_avg'] = $list['file_size'] / $list['file_count']; |
||
| 132 | $data['page_oldest'] = $list['file_oldest']; |
||
| 133 | unset($list); |
||
| 134 | |||
| 135 | // number and size of media |
||
| 136 | $list = array(); |
||
| 137 | search($list,$conf['mediadir'],array($this,'_search_count'),array('all'=>true)); |
||
| 138 | $data['media_count'] = $list['file_count']; |
||
| 139 | $data['media_size'] = $list['file_size']; |
||
| 140 | $data['media_biggest'] = $list['file_max']; |
||
| 141 | $data['media_smallest'] = $list['file_min']; |
||
| 142 | $data['media_nscount'] = $list['dir_count']; |
||
| 143 | $data['media_nsnest'] = $list['dir_nest']; |
||
| 144 | if($list['file_count']) $data['media_avg'] = $list['file_size'] / $list['file_count']; |
||
| 145 | unset($list); |
||
| 146 | |||
| 147 | // number and size of cache |
||
| 148 | $list = array(); |
||
| 149 | search($list,$conf['cachedir'],array($this,'_search_count'),array('all'=>true)); |
||
| 150 | $data['cache_count'] = $list['file_count']; |
||
| 151 | $data['cache_size'] = $list['file_size']; |
||
| 152 | $data['cache_biggest'] = $list['file_max']; |
||
| 153 | $data['cache_smallest'] = $list['file_min']; |
||
| 154 | if($list['file_count']) $data['cache_avg'] = $list['file_size'] / $list['file_count']; |
||
| 155 | unset($list); |
||
| 156 | |||
| 157 | // number and size of index |
||
| 158 | $list = array(); |
||
| 159 | search($list,$conf['indexdir'],array($this,'_search_count'),array('all'=>true)); |
||
| 160 | $data['index_count'] = $list['file_count']; |
||
| 161 | $data['index_size'] = $list['file_size']; |
||
| 162 | $data['index_biggest'] = $list['file_max']; |
||
| 163 | $data['index_smallest'] = $list['file_min']; |
||
| 164 | if($list['file_count']) $data['index_avg'] = $list['file_size'] / $list['file_count']; |
||
| 165 | unset($list); |
||
| 166 | |||
| 167 | // number and size of meta |
||
| 168 | $list = array(); |
||
| 169 | search($list,$conf['metadir'],array($this,'_search_count'),array('all'=>true)); |
||
| 170 | $data['meta_count'] = $list['file_count']; |
||
| 171 | $data['meta_size'] = $list['file_size']; |
||
| 172 | $data['meta_biggest'] = $list['file_max']; |
||
| 173 | $data['meta_smallest'] = $list['file_min']; |
||
| 174 | if($list['file_count']) $data['meta_avg'] = $list['file_size'] / $list['file_count']; |
||
| 175 | unset($list); |
||
| 176 | |||
| 177 | // number and size of attic |
||
| 178 | $list = array(); |
||
| 179 | search($list,$conf['olddir'],array($this,'_search_count'),array('all'=>true)); |
||
| 180 | $data['attic_count'] = $list['file_count']; |
||
| 181 | $data['attic_size'] = $list['file_size']; |
||
| 182 | $data['attic_biggest'] = $list['file_max']; |
||
| 183 | $data['attic_smallest'] = $list['file_min']; |
||
| 184 | if($list['file_count']) $data['attic_avg'] = $list['file_size'] / $list['file_count']; |
||
| 185 | $data['attic_oldest'] = $list['file_oldest']; |
||
| 186 | unset($list); |
||
| 187 | |||
| 188 | // user count |
||
| 189 | if($auth && $auth->canDo('getUserCount')){ |
||
| 190 | $data['user_count'] = $auth->getUserCount(); |
||
| 191 | } |
||
| 192 | |||
| 193 | // calculate edits per day |
||
| 194 | $list = @file($conf['metadir'].'/_dokuwiki.changes'); |
||
| 195 | $count = count($list); |
||
| 196 | if($count > 2){ |
||
| 197 | $first = (int) substr(array_shift($list),0,10); |
||
| 198 | $last = (int) substr(array_pop($list),0,10); |
||
| 199 | $dur = ($last - $first)/(60*60*24); // number of days in the changelog |
||
| 200 | $data['edits_per_day'] = $count/$dur; |
||
| 201 | } |
||
| 202 | unset($list); |
||
| 203 | |||
| 204 | // plugins |
||
| 205 | $data['plugin'] = plugin_list(); |
||
| 206 | |||
| 207 | // pcre info |
||
| 208 | if(defined('PCRE_VERSION')) $data['pcre_version'] = PCRE_VERSION; |
||
| 209 | $data['pcre_backtrack'] = ini_get('pcre.backtrack_limit'); |
||
| 210 | $data['pcre_recursion'] = ini_get('pcre.recursion_limit'); |
||
| 211 | |||
| 212 | // php info |
||
| 213 | $data['os'] = PHP_OS; |
||
| 214 | $data['webserver'] = $_SERVER['SERVER_SOFTWARE']; |
||
| 215 | $data['php_version'] = phpversion(); |
||
| 216 | $data['php_sapi'] = php_sapi_name(); |
||
| 217 | $data['php_memory'] = $this->_to_byte(ini_get('memory_limit')); |
||
| 218 | $data['php_exectime'] = $phptime; |
||
| 219 | $data['php_extension'] = get_loaded_extensions(); |
||
| 220 | |||
| 221 | // plugin usage data |
||
| 222 | $this->_add_plugin_usage_data($data); |
||
| 223 | |||
| 224 | return $data; |
||
| 225 | } |
||
| 226 | |||
| 311 |
If you suppress an error, we recommend checking for the error condition explicitly: