Conditions | 16 |
Paths | 224 |
Total Lines | 40 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 1 |
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 |
||
64 | function preflight($s) { |
||
65 | if (isset($_GET['FORCE_DEBUG'])) { |
||
66 | $s->setOption(PhpXmlRpc\Server::OPT_DEBUG, $_GET['FORCE_DEBUG']); |
||
67 | } |
||
68 | if (isset($_GET['RESPONSE_ENCODING'])) { |
||
69 | $s->setOption(PhpXmlRpc\Server::OPT_RESPONSE_CHARSET_ENCODING, $_GET['RESPONSE_ENCODING']); |
||
70 | } |
||
71 | if (isset($_GET['DETECT_ENCODINGS'])) { |
||
72 | PhpXmlRpc\PhpXmlRpc::$xmlrpc_detectencodings = $_GET['DETECT_ENCODINGS']; |
||
73 | } |
||
74 | if (isset($_GET['EXCEPTION_HANDLING'])) { |
||
75 | $s->setOption(PhpXmlRpc\Server::OPT_EXCEPTION_HANDLING, $_GET['EXCEPTION_HANDLING']); |
||
76 | } |
||
77 | if (isset($_GET['FORCE_AUTH'])) { |
||
78 | // We implement both Basic and Digest auth in php to avoid having to set it up in a vhost. |
||
79 | // Code taken from php.net |
||
80 | // NB: we do NOT check for valid credentials! |
||
81 | if ($_GET['FORCE_AUTH'] == 'Basic') { |
||
82 | if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['REMOTE_USER']) && !isset($_SERVER['REDIRECT_REMOTE_USER'])) { |
||
83 | header('HTTP/1.0 401 Unauthorized'); |
||
84 | header('WWW-Authenticate: Basic realm="Phpxmlrpc Basic Realm"'); |
||
85 | die('Text visible if user hits Cancel button'); |
||
86 | } |
||
87 | } elseif ($_GET['FORCE_AUTH'] == 'Digest') { |
||
88 | if (empty($_SERVER['PHP_AUTH_DIGEST'])) { |
||
89 | header('HTTP/1.1 401 Unauthorized'); |
||
90 | header('WWW-Authenticate: Digest realm="Phpxmlrpc Digest Realm",qop="auth",nonce="' . uniqid() . '",opaque="' . md5('Phpxmlrpc Digest Realm') . '"'); |
||
91 | die('Text visible if user hits Cancel button'); |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 | if (isset($_GET['FORCE_REDIRECT'])) { |
||
96 | header('HTTP/1.0 302 Found'); |
||
97 | unset($_GET['FORCE_REDIRECT']); |
||
98 | header('Location: ' . $_SERVER['REQUEST_URI'] . (count($_GET) ? '?' . http_build_query($_GET) : '')); |
||
99 | die(); |
||
100 | } |
||
101 | if (isset($_GET['SLOW_LORIS']) && $_GET['SLOW_LORIS'] > 0) { |
||
102 | slowLoris((int)$_GET['SLOW_LORIS'], $s); |
||
103 | die(); |
||
104 | } |
||
127 |