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 |
||
15 | function phpxmlrpc_verify_compat($mode = 'client') |
||
16 | { |
||
17 | $tests = array(); |
||
18 | |||
19 | if ($mode == 'server') { |
||
20 | // test for php version |
||
21 | $ver = phpversion(); |
||
22 | $tests['php_version'] = array(); |
||
23 | $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n"; |
||
24 | if (version_compare($ver, '5.3.0') < 0) { |
||
25 | $tests['php_version']['status'] = 0; |
||
26 | $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'; |
||
27 | } else { |
||
28 | $tests['php_version']['status'] = 2; |
||
29 | $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library'; |
||
30 | } |
||
31 | |||
32 | // test for zlib |
||
33 | $tests['zlib'] = array(); |
||
34 | if (!function_exists('gzinflate')) { |
||
35 | $tests['zlib']['status'] = 0; |
||
36 | $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)"; |
||
37 | } else { |
||
38 | $tests['zlib']['status'] = 2; |
||
39 | $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"; |
||
40 | } |
||
41 | |||
42 | // test for display of php errors in xml response |
||
43 | if (ini_get('display_errors')) { |
||
44 | if (intval(ini_get('error_reporting')) && E_NOTICE) { |
||
45 | $tests['display_errors']['status'] = 1; |
||
46 | $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"; |
||
47 | } else { |
||
48 | $tests['display_errors']['status'] = 1; |
||
49 | $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"; |
||
50 | } |
||
51 | } |
||
52 | } else { |
||
53 | |||
54 | // test for php version |
||
55 | $ver = phpversion(); |
||
56 | $tests['php_version'] = array(); |
||
57 | $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n"; |
||
58 | if (version_compare($ver, '5.3.0') < 0) { |
||
59 | $tests['php_version']['status'] = 0; |
||
60 | $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later'; |
||
61 | } else { |
||
62 | $tests['php_version']['status'] = 2; |
||
63 | $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library'; |
||
64 | } |
||
65 | |||
66 | // test for zlib |
||
67 | $tests['zlib'] = array(); |
||
68 | if (!function_exists('gzinflate')) { |
||
69 | $tests['zlib']['status'] = 0; |
||
70 | $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)"; |
||
71 | } else { |
||
72 | $tests['zlib']['status'] = 2; |
||
73 | $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"; |
||
74 | } |
||
75 | |||
76 | // test for CURL |
||
77 | $tests['curl'] = array(); |
||
78 | if (!extension_loaded('curl')) { |
||
79 | $tests['curl']['status'] = 0; |
||
80 | $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"; |
||
81 | } else { |
||
82 | $info = curl_version(); |
||
83 | $tests['curl']['status'] = 2; |
||
84 | $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"; |
||
85 | if (version_compare($ver, '4.3.8') < 0) { |
||
86 | $tests['curl']['status'] = 1; |
||
87 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives"; |
||
88 | } |
||
89 | if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) { |
||
|
|||
90 | $tests['curl']['status'] = 1; |
||
91 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages"; |
||
92 | } |
||
93 | if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version']))) { |
||
94 | $tests['curl']['status'] = 1; |
||
95 | $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections"; |
||
96 | } |
||
97 | } |
||
98 | } |
||
99 | |||
100 | return $tests; |
||
101 | } |
||
189 |