| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 131 | 
| Code Lines | 109 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 211 | private function operationTemplateVarsOfStatistics(array $data = []): array  | 
            ||
| 212 |     { | 
            ||
| 213 |         $ruleList = $this->kernel->driver->getAll('rule'); | 
            ||
| 214 | |||
| 215 | $data['component_ip'] = 0;  | 
            ||
| 216 | $data['component_rdns'] = 0;  | 
            ||
| 217 | $data['component_header'] = 0;  | 
            ||
| 218 | $data['component_useragent'] = 0;  | 
            ||
| 219 | $data['component_trustedbot'] = 0;  | 
            ||
| 220 | |||
| 221 | $data['filter_cookie'] = 0;  | 
            ||
| 222 | $data['filter_referer'] = 0;  | 
            ||
| 223 | $data['filter_session'] = 0;  | 
            ||
| 224 | $data['filter_frequency'] = 0;  | 
            ||
| 225 | |||
| 226 | // Components.  | 
            ||
| 227 | $data['rule_list']['ip'] = [];  | 
            ||
| 228 | $data['rule_list']['rdns'] = [];  | 
            ||
| 229 | $data['rule_list']['header'] = [];  | 
            ||
| 230 | $data['rule_list']['useragent'] = [];  | 
            ||
| 231 | $data['rule_list']['trustedbot'] = [];  | 
            ||
| 232 | |||
| 233 | // Filters.  | 
            ||
| 234 | $data['rule_list']['cookie'] = [];  | 
            ||
| 235 | $data['rule_list']['referer'] = [];  | 
            ||
| 236 | $data['rule_list']['session'] = [];  | 
            ||
| 237 | $data['rule_list']['frequency'] = [];  | 
            ||
| 238 | |||
| 239 | $counter = [];  | 
            ||
| 240 | $info = [];  | 
            ||
| 241 | |||
| 242 | $counter[$this->kernel::REASON_DENY_IP] = 0;  | 
            ||
| 243 | $counter[$this->kernel::REASON_COMPONENT_IP] = 0;  | 
            ||
| 244 | $counter[$this->kernel::REASON_COMPONENT_RDNS] = 0;  | 
            ||
| 245 | $counter[$this->kernel::REASON_COMPONENT_HEADER] = 0;  | 
            ||
| 246 | $counter[$this->kernel::REASON_COMPONENT_USERAGENT] = 0;  | 
            ||
| 247 | $counter[$this->kernel::REASON_COMPONENT_TRUSTED_ROBOT] = 0;  | 
            ||
| 248 | $counter[$this->kernel::REASON_TOO_MANY_ACCESSES] = 0;  | 
            ||
| 249 | $counter[$this->kernel::REASON_REACHED_LIMIT_DAY] = 0;  | 
            ||
| 250 | $counter[$this->kernel::REASON_REACHED_LIMIT_HOUR] = 0;  | 
            ||
| 251 | $counter[$this->kernel::REASON_REACHED_LIMIT_MINUTE] = 0;  | 
            ||
| 252 | $counter[$this->kernel::REASON_REACHED_LIMIT_SECOND] = 0;  | 
            ||
| 253 | $counter[$this->kernel::REASON_EMPTY_REFERER] = 0;  | 
            ||
| 254 | $counter[$this->kernel::REASON_EMPTY_JS_COOKIE] = 0;  | 
            ||
| 255 | $counter[$this->kernel::REASON_TOO_MANY_SESSIONS] = 0;  | 
            ||
| 256 | $info[$this->kernel::REASON_DENY_IP] = [];  | 
            ||
| 257 | $info[$this->kernel::REASON_COMPONENT_IP] = [];  | 
            ||
| 258 | $info[$this->kernel::REASON_COMPONENT_RDNS] = [];  | 
            ||
| 259 | $info[$this->kernel::REASON_COMPONENT_HEADER] = [];  | 
            ||
| 260 | $info[$this->kernel::REASON_COMPONENT_USERAGENT] = [];  | 
            ||
| 261 | $info[$this->kernel::REASON_COMPONENT_TRUSTED_ROBOT] = [];  | 
            ||
| 262 | $info[$this->kernel::REASON_DENY_IP] = [];  | 
            ||
| 263 | $info[$this->kernel::REASON_REACHED_LIMIT_DAY] = [];  | 
            ||
| 264 | $info[$this->kernel::REASON_REACHED_LIMIT_HOUR] = [];  | 
            ||
| 265 | $info[$this->kernel::REASON_REACHED_LIMIT_MINUTE] = [];  | 
            ||
| 266 | $info[$this->kernel::REASON_REACHED_LIMIT_SECOND] = [];  | 
            ||
| 267 | $info[$this->kernel::REASON_EMPTY_REFERER] = [];  | 
            ||
| 268 | $info[$this->kernel::REASON_EMPTY_JS_COOKIE] = [];  | 
            ||
| 269 | $info[$this->kernel::REASON_TOO_MANY_SESSIONS] = [];  | 
            ||
| 270 | |||
| 271 |         foreach ($ruleList as $ruleInfo) { | 
            ||
| 272 | $reason = $ruleInfo['reason'];  | 
            ||
| 273 | $counter[$reason]++;  | 
            ||
| 274 | $info[$reason][] = $ruleInfo;  | 
            ||
| 275 | }  | 
            ||
| 276 | |||
| 277 | $a = $counter[$this->kernel::REASON_DENY_IP];  | 
            ||
| 278 | $b = $counter[$this->kernel::REASON_COMPONENT_IP];  | 
            ||
| 279 | $c = $info[$this->kernel::REASON_DENY_IP];  | 
            ||
| 280 | $d = $info[$this->kernel::REASON_COMPONENT_IP];  | 
            ||
| 281 | $data['component_ip'] = $a + $b;  | 
            ||
| 282 | $data['rule_list']['ip'] = array_merge_recursive($c, $d);  | 
            ||
| 283 | unset($a, $b, $c, $d);  | 
            ||
| 284 | |||
| 285 | $a = $counter[$this->kernel::REASON_COMPONENT_RDNS];  | 
            ||
| 286 | $b = $info[$this->kernel::REASON_COMPONENT_RDNS];  | 
            ||
| 287 | $data['component_rdns'] = $a;  | 
            ||
| 288 | $data['rule_list']['rdns'] = $b;  | 
            ||
| 289 | unset($a, $b);  | 
            ||
| 290 | |||
| 291 | $a = $counter[$this->kernel::REASON_COMPONENT_HEADER];  | 
            ||
| 292 | $b = $info[$this->kernel::REASON_COMPONENT_HEADER];  | 
            ||
| 293 | $data['component_header'] = $a;  | 
            ||
| 294 | $data['rule_list']['header'] = $b;  | 
            ||
| 295 | unset($a, $b);  | 
            ||
| 296 | |||
| 297 | $a = $counter[$this->kernel::REASON_COMPONENT_USERAGENT];  | 
            ||
| 298 | $b = $info[$this->kernel::REASON_COMPONENT_USERAGENT];  | 
            ||
| 299 | $data['component_useragent'] = $a;  | 
            ||
| 300 | $data['rule_list']['useragent'] = $b;  | 
            ||
| 301 | unset($a, $b);  | 
            ||
| 302 | |||
| 303 | $a = $counter[$this->kernel::REASON_COMPONENT_TRUSTED_ROBOT];  | 
            ||
| 304 | $b = $info[$this->kernel::REASON_COMPONENT_TRUSTED_ROBOT];  | 
            ||
| 305 | $data['component_trustedbot'] = $a;  | 
            ||
| 306 | $data['rule_list']['trustedbot'] = $b;  | 
            ||
| 307 | unset($a, $b);  | 
            ||
| 308 | |||
| 309 | $a = $counter[$this->kernel::REASON_TOO_MANY_ACCESSES];  | 
            ||
| 310 | $b = $counter[$this->kernel::REASON_REACHED_LIMIT_DAY];  | 
            ||
| 311 | $c = $counter[$this->kernel::REASON_REACHED_LIMIT_HOUR];  | 
            ||
| 312 | $d = $counter[$this->kernel::REASON_REACHED_LIMIT_MINUTE];  | 
            ||
| 313 | $e = $counter[$this->kernel::REASON_REACHED_LIMIT_SECOND];  | 
            ||
| 314 | $f = $info[$this->kernel::REASON_DENY_IP];  | 
            ||
| 315 | $g = $info[$this->kernel::REASON_REACHED_LIMIT_DAY];  | 
            ||
| 316 | $h = $info[$this->kernel::REASON_REACHED_LIMIT_HOUR];  | 
            ||
| 317 | $i = $info[$this->kernel::REASON_REACHED_LIMIT_MINUTE];  | 
            ||
| 318 | $j = $info[$this->kernel::REASON_REACHED_LIMIT_SECOND];  | 
            ||
| 319 | $data['filter_frequency'] = $a + $b + $c + $d + $e;  | 
            ||
| 320 | $data['rule_list']['frequency'] = array_merge_recursive($f, $g, $h, $i, $j);  | 
            ||
| 321 | unset($a, $b, $c, $d, $e, $f, $g, $h, $i, $j);  | 
            ||
| 322 | |||
| 323 | $a = $counter[$this->kernel::REASON_EMPTY_REFERER];  | 
            ||
| 324 | $b = $info[$this->kernel::REASON_EMPTY_REFERER];  | 
            ||
| 325 | $data['filter_referer'] = $a;  | 
            ||
| 326 | $data['rule_list']['referer'] = $b;  | 
            ||
| 327 | unset($a, $b);  | 
            ||
| 328 | |||
| 329 | $a = $counter[$this->kernel::REASON_EMPTY_JS_COOKIE];  | 
            ||
| 330 | $b = $info[$this->kernel::REASON_EMPTY_JS_COOKIE];  | 
            ||
| 331 | $data['filter_cookie'] = $a;  | 
            ||
| 332 | $data['rule_list']['cookie'] = $b;  | 
            ||
| 333 | unset($a, $b);  | 
            ||
| 334 | |||
| 335 | $a = $counter[$this->kernel::REASON_TOO_MANY_SESSIONS];  | 
            ||
| 336 | $b = $info[$this->kernel::REASON_TOO_MANY_SESSIONS];  | 
            ||
| 337 | $data['filter_session'] = $a;  | 
            ||
| 338 | $data['rule_list']['session'] = $b;  | 
            ||
| 339 | unset($a, $b);  | 
            ||
| 340 | |||
| 341 | return $data;  | 
            ||
| 342 | }  | 
            ||
| 345 |