Conditions | 17 |
Paths | 48 |
Total Lines | 86 |
Code Lines | 60 |
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 |
||
16 | function phpxmlrpc_verify_compat($mode = 'client') |
||
17 | { |
||
18 | $tests = array(); |
||
19 | |||
20 | if ($mode == 'server') { |
||
21 | // test for php version |
||
22 | $ver = phpversion(); |
||
23 | $tests['php_version'] = array(); |
||
24 | $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n"; |
||
25 | if (version_compare($ver, '5.3.0') < 0) { |
||
26 | $tests['php_version']['status'] = 0; |
||
27 | $tests['php_version']['description'] .= 'This version of PHP is not compatible with this release of the PHP XMLRPC library. Please upgrade to php 5.1.0 or later'; |
||
28 | } else { |
||
29 | $tests['php_version']['status'] = 2; |
||
30 | $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library'; |
||
31 | } |
||
32 | |||
33 | // test for zlib |
||
34 | $tests['zlib'] = array(); |
||
35 | if (!function_exists('gzinflate')) { |
||
36 | $tests['zlib']['status'] = 0; |
||
37 | $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to receive compressed requests or send compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)"; |
||
38 | } else { |
||
39 | $tests['zlib']['status'] = 2; |
||
40 | $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to receive compressed requests and send compressed responses for the 'HTTP' protocol"; |
||
41 | } |
||
42 | |||
43 | // test for display of php errors in xml response |
||
44 | if (ini_get('display_errors')) { |
||
45 | if (intval(ini_get('error_reporting')) && E_NOTICE) { |
||
46 | $tests['display_errors']['status'] = 1; |
||
47 | $tests['display_errors']['description'] = "Error reporting level includes E_NOTICE errors, and display_errors is set to ON.\n\nAny error, warning or notice raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response"; |
||
48 | } else { |
||
49 | $tests['display_errors']['status'] = 1; |
||
50 | $tests['display_errors']['description'] = "display_errors is set to ON.\n\nAny error raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response"; |
||
51 | } |
||
52 | } |
||
53 | } else { |
||
54 | |||
55 | // test for php version |
||
56 | $ver = phpversion(); |
||
57 | $tests['php_version'] = array(); |
||
58 | $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n"; |
||
59 | if (version_compare($ver, '5.3.0') < 0) { |
||
60 | $tests['php_version']['status'] = 0; |
||
61 | $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later'; |
||
62 | } else { |
||
63 | $tests['php_version']['status'] = 2; |
||
64 | $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library'; |
||
65 | } |
||
66 | |||
67 | // test for zlib |
||
68 | $tests['zlib'] = array(); |
||
69 | if (!function_exists('gzinflate')) { |
||
70 | $tests['zlib']['status'] = 0; |
||
71 | $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to send compressed requests or receive compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)"; |
||
72 | } else { |
||
73 | $tests['zlib']['status'] = 2; |
||
74 | $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to send compressed requests and receive compressed responses for the 'HTTP' protocol"; |
||
75 | } |
||
76 | |||
77 | // test for CURL |
||
78 | $tests['curl'] = array(); |
||
79 | if (!extension_loaded('curl')) { |
||
80 | $tests['curl']['status'] = 0; |
||
81 | $tests['curl']['description'] = "The cURL extension is not enabled.\n\nYou will not be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols"; |
||
82 | } else { |
||
83 | $info = curl_version(); |
||
84 | $tests['curl']['status'] = 2; |
||
85 | $tests['curl']['description'] = "The cURL extension is enabled.\n\nYou will be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols"; |
||
86 | if (version_compare($ver, '4.3.8') < 0) { |
||
87 | $tests['curl']['status'] = 1; |
||
88 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives"; |
||
89 | } |
||
90 | if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) { |
||
|
|||
91 | $tests['curl']['status'] = 1; |
||
92 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages"; |
||
93 | } |
||
94 | if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version']))) { |
||
95 | $tests['curl']['status'] = 1; |
||
96 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections"; |
||
97 | } |
||
98 | } |
||
99 | } |
||
100 | |||
101 | return $tests; |
||
102 | } |
||
190 |