Conditions | 7 |
Paths | 21 |
Total Lines | 69 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 2 |
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 |
||
39 | public function execute(Request $request, $params = []) |
||
40 | { |
||
41 | $connection = $this->getConnection(); |
||
42 | |||
43 | $url = $this->connection->getConfig('scheme') . '://' . $connection->getHost() . ':' . $connection->getPort() |
||
44 | . $connection->getPath(); |
||
45 | $endpoint = $request->getPath(); |
||
46 | $url .= $endpoint; |
||
47 | $url = $this->setupURI($url, $request->getQuery()); |
||
48 | $method = $request->getMethod(); |
||
49 | |||
50 | $headers = $connection->getHeaders(); |
||
51 | $headers['Content-Type'] = $request->getContentType(); |
||
52 | $data = $request->getBody(); |
||
53 | if (!empty($data)) { |
||
54 | if (is_array($data)) { |
||
55 | $content = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
||
56 | } else { |
||
57 | $content = $data; |
||
58 | } |
||
59 | } else { |
||
60 | $content = ''; |
||
61 | } |
||
62 | $start = microtime(true); |
||
63 | $message = $this->messageFactory->createRequest($method, $url, $headers, $content); |
||
64 | try { |
||
65 | $responsePSR = $this->client->sendRequest($message); |
||
66 | } catch (\Exception $e) { |
||
67 | throw new ConnectionException($e->getMessage(), $request); |
||
68 | } |
||
69 | $end = microtime(true); |
||
70 | $status = $responsePSR->getStatusCode(); |
||
71 | $responseString = $responsePSR->getBody(); |
||
72 | |||
73 | if (isset($params['responseClass'])) { |
||
74 | $responseClass = $params['responseClass']; |
||
75 | $responseClassParams = isset($params['responseClassParams'])?$params['responseClassParams']:[]; |
||
76 | $response = new $responseClass($responseString, $status, $responseClassParams); |
||
77 | } else { |
||
78 | $response = new Response($responseString, $status); |
||
79 | } |
||
80 | |||
81 | $time = $end-$start; |
||
82 | $response->setTime($time); |
||
83 | $response->setTransportInfo([ |
||
84 | 'url' => $url, |
||
85 | 'headers' => $headers, |
||
86 | 'body' => $request->getBody() |
||
87 | ]); |
||
88 | $this->logger->debug('Request body:', [ |
||
89 | 'connection' => $connection->getConfig(), |
||
90 | 'payload'=> $request->getBody() |
||
91 | ]); |
||
92 | $this->logger->info('Request:', [ |
||
93 | 'url' => $url, |
||
94 | 'status' => $status, |
||
95 | 'time' => $time, |
||
96 | ]); |
||
97 | $this->logger->debug('Response body:', $response->getResponse()); |
||
98 | |||
99 | if ($response->hasError()) { |
||
100 | $this->logger->error('Response:', [ |
||
101 | 'url' => $url, |
||
102 | 'error' => $response->getError(), |
||
103 | 'payload' => $request->getBody(), |
||
104 | ]); |
||
105 | throw new ResponseException($request, $response); |
||
106 | } |
||
107 | return $response; |
||
108 | } |
||
110 |
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