| Conditions | 6 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 23 |
| 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 |
||
| 22 | private function http(Request $request) : array |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var SWHClient $http |
||
| 26 | */ |
||
| 27 | |||
| 28 | $http = $this->http; |
||
| 29 | |||
| 30 | // -- request init |
||
| 31 | |||
| 32 | $http->setMethod($request->getMethod()); |
||
| 33 | |||
| 34 | // -- net sender |
||
| 35 | |||
| 36 | $executor = function ($fn) use ($http, $request) { |
||
| 37 | $uri = $this->getUriPath($request->getUri()); |
||
| 38 | |||
| 39 | $stream = $request->getBody(); |
||
| 40 | |||
| 41 | if ($stream instanceof Form) { |
||
| 42 | foreach ($stream->files() as $name => $file) { |
||
| 43 | $http->addFile($file->path(), $name); |
||
| 44 | } |
||
| 45 | $http->post($uri, $stream->data(), $fn); |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($stream->getSize() > 0) { |
||
| 50 | $http->setData((string)$stream); |
||
| 51 | } |
||
| 52 | |||
| 53 | $http->execute($uri, $fn); |
||
| 54 | }; |
||
| 55 | |||
| 56 | // -- net receiver |
||
| 57 | |||
| 58 | $receiver = function (SWHClient $c) use ($request) { |
||
| 59 | $code = $c->statusCode; |
||
| 60 | $headers = (array)$c->headers; |
||
| 61 | $response = $c->body; |
||
| 62 | |||
| 63 | // reset cli headers !! |
||
| 64 | foreach (array_keys($c->headers ?? []) as $k) { |
||
| 65 | unset($c->headers[$k]); |
||
| 66 | } |
||
| 67 | |||
| 68 | if ($code > 0) { |
||
| 69 | return new Response($code, $headers, $response); |
||
| 70 | } |
||
| 71 | |||
| 72 | $this->throwing($request, $c); |
||
| 73 | }; |
||
| 74 | |||
| 75 | // -- packing |
||
| 76 | |||
| 77 | return [$executor, $receiver]; |
||
| 78 | } |
||
| 80 |
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