| Conditions | 4 |
| Paths | 6 |
| Total Lines | 51 |
| Code Lines | 28 |
| 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 |
||
| 78 | private function connect(array $httpHeader, $fields): array |
||
| 79 | { |
||
| 80 | $curl = curl_init(); |
||
| 81 | |||
| 82 | curl_setopt_array( |
||
| 83 | /** @scrutinizer ignore-type */ |
||
| 84 | $curl, |
||
| 85 | [ |
||
| 86 | CURLOPT_URL => $this->url, |
||
| 87 | CURLOPT_RETURNTRANSFER => true, |
||
| 88 | CURLOPT_ENCODING => "", |
||
| 89 | CURLOPT_MAXREDIRS => 10, |
||
| 90 | CURLOPT_CONNECTTIMEOUT => $this->timeout, |
||
| 91 | CURLOPT_TIMEOUT => $this->timeout, |
||
| 92 | CURLOPT_FOLLOWLOCATION => true, |
||
| 93 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
||
| 94 | CURLOPT_CUSTOMREQUEST => "POST", |
||
| 95 | CURLOPT_POSTFIELDS => $fields, |
||
| 96 | CURLOPT_HTTPHEADER => $httpHeader, |
||
| 97 | CURLOPT_CAINFO => __DIR__ . "/../../ssl/ca-bundle.crt", |
||
| 98 | ] |
||
| 99 | ); |
||
| 100 | if(PHP_VERSION_ID >= 80000){ |
||
| 101 | |||
| 102 | $response = $this->executeCurl($curl); |
||
|
|
|||
| 103 | |||
| 104 | $errorNo = $this->getErrorNo($curl); |
||
| 105 | |||
| 106 | } else { |
||
| 107 | |||
| 108 | $response = $this->executeCurlLegacy($curl); |
||
| 109 | |||
| 110 | $errorNo = $this->getErrorNoLegacy($curl); |
||
| 111 | |||
| 112 | } |
||
| 113 | |||
| 114 | |||
| 115 | if ($response == "[]") { |
||
| 116 | throw new EmptyAutentiqueResponseException(); |
||
| 117 | } |
||
| 118 | |||
| 119 | if ($errorNo) { |
||
| 120 | throw new Exception(curl_error($curl)); |
||
| 121 | } |
||
| 122 | |||
| 123 | curl_close( |
||
| 124 | /** @scrutinizer ignore-type */ |
||
| 125 | $curl |
||
| 126 | ); |
||
| 127 | |||
| 128 | return json_decode($response, true); |
||
| 129 | } |
||
| 203 |