Conditions | 10 |
Paths | 12 |
Total Lines | 37 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
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 |
||
27 | protected function doRequest($url, array $data = null) |
||
28 | { |
||
29 | $options = []; |
||
30 | if ($data) { |
||
31 | $method = 'POST'; |
||
32 | |||
33 | $data = array_filter($data); |
||
34 | foreach ($data as &$value) { |
||
35 | if ($value instanceof \CURLFile) { |
||
36 | $value = DataPart::fromPath($value->getFilename()); |
||
37 | } elseif (!\is_string($value) && !\is_array($value)) { |
||
38 | $value = (string) $value; |
||
39 | } |
||
40 | } |
||
41 | $formData = new FormDataPart($data); |
||
42 | |||
43 | $options['headers'] = $formData->getPreparedHeaders()->toArray(); |
||
44 | $options['body'] = $formData->toIterable(); |
||
45 | } else { |
||
46 | $method = 'GET'; |
||
47 | } |
||
48 | |||
49 | $response = $this->http->request($method, $url, $options); |
||
50 | |||
51 | try { |
||
52 | return $response->toArray(); |
||
53 | } catch (ExceptionInterface $exception) { |
||
54 | if ($exception instanceof HttpExceptionInterface) { |
||
55 | $response = $exception->getResponse()->toArray(false); |
||
56 | $message = array_key_exists('description', $response) ? $response['description'] : $exception->getMessage(); |
||
57 | $parameters = array_key_exists('parameters', $response) ? $response['parameters'] : []; |
||
58 | } else { |
||
59 | $message = $exception->getMessage(); |
||
60 | $parameters = []; |
||
61 | } |
||
62 | |||
63 | throw new HttpException($message, $exception->getCode(), $exception, $parameters); |
||
64 | } |
||
79 |
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