Conditions | 11 |
Paths | 288 |
Total Lines | 72 |
Code Lines | 40 |
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 |
||
89 | private function createGuzzleRequest(Psr7Request $psrRequest, array $options) |
||
90 | { |
||
91 | $ringConfig = []; |
||
92 | $statsCallback = isset($options['http_stats_receiver']) |
||
93 | ? $options['http_stats_receiver'] |
||
94 | : null; |
||
95 | unset($options['http_stats_receiver']); |
||
96 | |||
97 | // Remove unsupported options. |
||
98 | foreach (array_keys($options) as $key) { |
||
99 | if (!isset(self::$validOptions[$key])) { |
||
100 | unset($options[$key]); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | // Handle delay option. |
||
105 | if (isset($options['delay'])) { |
||
106 | $ringConfig['delay'] = $options['delay']; |
||
107 | unset($options['delay']); |
||
108 | } |
||
109 | |||
110 | // Prepare sink option. |
||
111 | if (isset($options['sink'])) { |
||
112 | $ringConfig['save_to'] = ($options['sink'] instanceof Psr7StreamInterface) |
||
113 | ? new GuzzleStream($options['sink']) |
||
114 | : $options['sink']; |
||
115 | unset($options['sink']); |
||
116 | } |
||
117 | |||
118 | // Ensure that all requests are async and lazy like Guzzle 6. |
||
119 | $options['future'] = 'lazy'; |
||
120 | |||
121 | // Create the Guzzle 5 request from the provided PSR7 request. |
||
122 | $request = $this->client->createRequest( |
||
123 | $psrRequest->getMethod(), |
||
124 | $psrRequest->getUri(), |
||
125 | $options |
||
126 | ); |
||
127 | |||
128 | if (is_callable($statsCallback)) { |
||
129 | $request->getEmitter()->on( |
||
130 | 'end', |
||
131 | function (EndEvent $event) use ($statsCallback) { |
||
132 | $statsCallback($event->getTransferInfo()); |
||
133 | } |
||
134 | ); |
||
135 | } |
||
136 | |||
137 | // For the request body, adapt the PSR stream to a Guzzle stream. |
||
138 | $body = $psrRequest->getBody(); |
||
139 | if ($body->getSize() === 0) { |
||
140 | $request->setBody(null); |
||
141 | } else { |
||
142 | $request->setBody(new GuzzleStream($body)); |
||
143 | } |
||
144 | |||
145 | $request->setHeaders($psrRequest->getHeaders()); |
||
146 | |||
147 | $request->setHeader( |
||
148 | 'User-Agent', |
||
149 | $request->getHeader('User-Agent') |
||
150 | . ' ' . Client::getDefaultUserAgent() |
||
151 | ); |
||
152 | |||
153 | // Make sure the delay is configured, if provided. |
||
154 | if ($ringConfig) { |
||
155 | foreach ($ringConfig as $k => $v) { |
||
156 | $request->getConfig()->set($k, $v); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | return $request; |
||
161 | } |
||
196 |
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