Conditions | 9 |
Paths | 313 |
Total Lines | 70 |
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 |
||
46 | public function send( |
||
47 | $operation, |
||
48 | $url, |
||
49 | $action, |
||
50 | $envelope, |
||
51 | $parameters |
||
52 | ) { |
||
53 | $response = ''; |
||
54 | $this->requestHead = implode("\n", $parameters); |
||
55 | $this->requestBody = $envelope; |
||
56 | |||
57 | try { |
||
58 | $this->saveTemporarilyKeyFiles(); |
||
59 | $oCurl = curl_init(); |
||
60 | $this->setCurlProxy($oCurl); |
||
61 | curl_setopt($oCurl, CURLOPT_URL, $url); |
||
62 | curl_setopt($oCurl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
||
63 | curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, $this->soaptimeout); |
||
64 | curl_setopt($oCurl, CURLOPT_TIMEOUT, $this->soaptimeout + 20); |
||
65 | curl_setopt($oCurl, CURLOPT_HEADER, 1); |
||
66 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 0); |
||
67 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 0); |
||
68 | if (!$this->disablesec) { |
||
69 | curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 2); |
||
70 | if (is_file($this->casefaz)) { |
||
71 | curl_setopt($oCurl, CURLOPT_CAINFO, $this->casefaz); |
||
72 | } |
||
73 | } |
||
74 | curl_setopt($oCurl, CURLOPT_SSLVERSION, $this->soapprotocol); |
||
75 | curl_setopt($oCurl, CURLOPT_SSLCERT, $this->tempdir . $this->certfile); |
||
76 | curl_setopt($oCurl, CURLOPT_SSLKEY, $this->tempdir . $this->prifile); |
||
77 | if (!empty($this->temppass)) { |
||
78 | curl_setopt($oCurl, CURLOPT_KEYPASSWD, $this->temppass); |
||
79 | } |
||
80 | curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true); |
||
81 | if (! empty($envelope)) { |
||
82 | curl_setopt($oCurl, CURLOPT_POST, true); |
||
83 | curl_setopt($oCurl, CURLOPT_POSTFIELDS, $envelope); |
||
84 | curl_setopt($oCurl, CURLOPT_HTTPHEADER, $parameters); |
||
85 | } |
||
86 | $response = curl_exec($oCurl); |
||
87 | $this->soaperror = curl_error($oCurl); |
||
88 | $ainfo = curl_getinfo($oCurl); |
||
89 | if (is_array($ainfo)) { |
||
90 | $this->soapinfo = $ainfo; |
||
91 | } |
||
92 | $headsize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE); |
||
93 | $httpcode = curl_getinfo($oCurl, CURLINFO_HTTP_CODE); |
||
94 | curl_close($oCurl); |
||
95 | $this->responseHead = trim(substr($response, 0, $headsize)); |
||
96 | $this->responseBody = trim(substr($response, $headsize)); |
||
97 | $this->saveDebugFiles( |
||
98 | $operation, |
||
99 | $this->requestHead . "\n" . $this->requestBody, |
||
100 | $this->responseHead . "\n" . $this->responseBody |
||
101 | ); |
||
102 | } catch (\Exception $e) { |
||
103 | throw SoapException::unableToLoadCurl($e->getMessage()); |
||
104 | } |
||
105 | if ($this->soaperror != '') { |
||
106 | throw SoapException::soapFault($this->soaperror . " [$url]"); |
||
107 | } |
||
108 | if ($httpcode != 200) { |
||
109 | throw SoapException::soapFault( |
||
110 | " [$url] HTTP Error code: $httpcode - " |
||
111 | . $this->getFaultString($this->responseBody) |
||
112 | ); |
||
113 | } |
||
114 | return $this->responseBody; |
||
115 | } |
||
116 | |||
194 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.