Completed
Push — master ( 31110e...2f70e4 )
by Andreas
03:30
created

ajax.php ➔ ajax_linkwiz()   D

Complexity

Conditions 17
Paths 90

Size

Total Lines 101
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 17
eloc 59
nc 90
nop 0
dl 0
loc 101
rs 4.8361
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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:

1
<?php
2
/**
3
 * DokuWiki AJAX call handler
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     Andreas Gohr <[email protected]>
7
 */
8
9
if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../');
10
require_once(DOKU_INC . 'inc/init.php');
11
12
//close session
13
session_write_close();
14
15
// default header, ajax call may overwrite it later
16
header('Content-Type: text/html; charset=utf-8');
17
18
//call the requested function
19
global $INPUT;
20
if($INPUT->has('call')) {
21
    $call = $INPUT->filter('utf8_stripspecials')->str('call');
22
    new \dokuwiki\Ajax($call);
23
} else {
24
    http_status(404);
25
}
26