| Conditions | 11 | 
| Paths | 36 | 
| Total Lines | 55 | 
| Code Lines | 34 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 43 | protected function doRequest($url, array $data = null)  | 
            ||
| 44 |     { | 
            ||
| 45 |         if ($data) { | 
            ||
| 46 | $method = 'POST';  | 
            ||
| 47 | $data = array_filter($data);  | 
            ||
| 48 |         } else { | 
            ||
| 49 | $method = 'GET';  | 
            ||
| 50 | }  | 
            ||
| 51 | |||
| 52 | $request = $this->requestFactory->createRequest($method, $url);  | 
            ||
| 53 |         if ($method === 'POST') { | 
            ||
| 54 | $multipart = false;  | 
            ||
| 55 | |||
| 56 | /** @var array $data */  | 
            ||
| 57 |             foreach ($data as &$value) { | 
            ||
| 58 |                 if ($value instanceof \CURLFile) { | 
            ||
| 59 | $value = fopen($value->getFilename(), 'r');  | 
            ||
| 60 | $multipart = true;  | 
            ||
| 61 | }  | 
            ||
| 62 | }  | 
            ||
| 63 | unset($value);  | 
            ||
| 64 | |||
| 65 |             if ($multipart) { | 
            ||
| 66 | $builder = new MultipartStreamBuilder($this->streamFactory);  | 
            ||
| 67 |                 foreach ($data as $name => $value) { | 
            ||
| 68 | $builder->addResource($name, $value);  | 
            ||
| 69 | }  | 
            ||
| 70 | $stream = $builder->build();  | 
            ||
| 71 |                 $request = $request->withHeader('Content-Type', "multipart/form-data; boundary={$builder->getBoundary()}"); | 
            ||
| 72 |             } else { | 
            ||
| 73 | $stream = $this->streamFactory->createStream(http_build_query($data));  | 
            ||
| 74 |                 $request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded'); | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | $request = $request->withBody($stream);  | 
            ||
| 78 | }  | 
            ||
| 79 | |||
| 80 |         try { | 
            ||
| 81 | $response = $this->http->sendRequest($request);  | 
            ||
| 82 |         } catch (ClientExceptionInterface $exception) { | 
            ||
| 83 | throw new HttpException($exception->getMessage(), $exception->getCode(), $exception);  | 
            ||
| 84 | }  | 
            ||
| 85 | |||
| 86 | $content = $response->getBody()->getContents();  | 
            ||
| 87 | |||
| 88 | $json = self::jsonValidate($content);  | 
            ||
| 89 | |||
| 90 |         if (!\in_array($response->getStatusCode(), [200, 304])) { | 
            ||
| 91 |             $errorDescription = array_key_exists('description', $json) ? $json['description'] : $response->getReasonPhrase(); | 
            ||
| 92 |             $errorParameters = array_key_exists('parameters', $json) ? $json['parameters'] : []; | 
            ||
| 93 | |||
| 94 | throw new HttpException($errorDescription, $response->getStatusCode(), null, $errorParameters);  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 | return $json;  | 
            ||
| 98 | }  | 
            ||
| 131 | 
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths