@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function dispatchEvent() : \Closure |
41 | 41 | { |
42 | - return function (callable $handler) { |
|
42 | + return function(callable $handler) { |
|
43 | 43 | |
44 | - return function ( |
|
44 | + return function( |
|
45 | 45 | RequestInterface $request, |
46 | 46 | array $options |
47 | 47 | ) use ($handler) { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | // Handle the response form the server. |
58 | 58 | return $promise->then( |
59 | - function (ResponseInterface $response) { |
|
59 | + function(ResponseInterface $response) { |
|
60 | 60 | // Create the Post Transaction event. |
61 | 61 | $postTransactionEvent = new PostTransactionEvent($response, $this->serviceName); |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // Continue down the chain. |
67 | 67 | return $postTransactionEvent->getTransaction(); |
68 | 68 | }, |
69 | - function (Exception $reason) { |
|
69 | + function(Exception $reason) { |
|
70 | 70 | // Get the response. The response in a RequestException can be null too. |
71 | 71 | $response = $reason instanceof RequestException ? $reason->getResponse() : null; |
72 | 72 |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | $logger = $this->logger; |
35 | 35 | $formatter = $this->formatter; |
36 | 36 | |
37 | - return function ($request, array $options) use ($handler, $logger, $formatter) { |
|
37 | + return function($request, array $options) use ($handler, $logger, $formatter) { |
|
38 | 38 | |
39 | 39 | return $handler($request, $options)->then( |
40 | 40 | |
41 | - function ($response) use ($logger, $request, $formatter) { |
|
41 | + function($response) use ($logger, $request, $formatter) { |
|
42 | 42 | $message = $formatter->format($request, $response); |
43 | 43 | |
44 | 44 | $logger->info($message); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return $response; |
47 | 47 | }, |
48 | 48 | |
49 | - function ($reason) use ($logger, $request, $formatter) { |
|
49 | + function($reason) use ($logger, $request, $formatter) { |
|
50 | 50 | $response = $reason instanceof RequestException ? $reason->getResponse() : null; |
51 | 51 | $message = $formatter->format($request, $response, $reason); |
52 | 52 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $logger = $this->logger; |
35 | 35 | $formatter = $this->formatter; |
36 | 36 | |
37 | - return function (callable $handler) use ($logger, $formatter) { |
|
37 | + return function(callable $handler) use ($logger, $formatter) { |
|
38 | 38 | |
39 | - return function ($request, array $options) use ($handler, $logger, $formatter) { |
|
39 | + return function($request, array $options) use ($handler, $logger, $formatter) { |
|
40 | 40 | // generate id that will be used to supplement the log with information |
41 | 41 | $requestId = uniqid('eight_points_guzzle_'); |
42 | 42 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | return $handler($request, $options)->then( |
50 | 50 | |
51 | - function ($response) use ($logger, $request, $formatter, $requestId) { |
|
51 | + function($response) use ($logger, $request, $formatter, $requestId) { |
|
52 | 52 | |
53 | 53 | $message = $formatter->format($request, $response); |
54 | 54 | $context = compact('request', 'response', 'requestId'); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | return $response; |
59 | 59 | }, |
60 | 60 | |
61 | - function ($reason) use ($logger, $request, $formatter, $requestId) { |
|
61 | + function($reason) use ($logger, $request, $formatter, $requestId) { |
|
62 | 62 | |
63 | 63 | $response = $reason instanceof RequestException ? $reason->getResponse() : null; |
64 | 64 | $message = $formatter->format($request, $response, $reason); |
@@ -124,7 +124,7 @@ |
||
124 | 124 | { |
125 | 125 | return array_filter( |
126 | 126 | $this->getMessages(), |
127 | - function (LogMessage $message) use ($type) { |
|
127 | + function(LogMessage $message) use ($type) { |
|
128 | 128 | return $message->getLevel() === $type; |
129 | 129 | } |
130 | 130 | ); |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | { |
30 | 30 | $stopwatch = $this->stopwatch; |
31 | 31 | |
32 | - return function (callable $handler) use ($stopwatch) { |
|
32 | + return function(callable $handler) use ($stopwatch) { |
|
33 | 33 | |
34 | - return function ($request, array $options) use ($handler, $stopwatch) { |
|
34 | + return function($request, array $options) use ($handler, $stopwatch) { |
|
35 | 35 | $event = $stopwatch->start( |
36 | 36 | sprintf('%s %s', $request->getMethod(), $request->getUri()), |
37 | 37 | 'eight_points_guzzle' |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | return $handler($request, $options)->then( |
41 | 41 | |
42 | - function ($response) use ($event) { |
|
42 | + function($response) use ($event) { |
|
43 | 43 | $event->stop(); |
44 | 44 | |
45 | 45 | return $response; |
46 | 46 | }, |
47 | 47 | |
48 | - function ($reason) use ($event) { |
|
48 | + function($reason) use ($event) { |
|
49 | 49 | $event->stop(); |
50 | 50 | |
51 | 51 | return \GuzzleHttp\Promise\rejection_for($reason); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __invoke(callable $handler) : \Closure |
35 | 35 | { |
36 | - return function (RequestInterface $request, array $options) use ($handler) { |
|
36 | + return function(RequestInterface $request, array $options) use ($handler) { |
|
37 | 37 | $options['on_stats'] = $this->getOnStatsCallback( |
38 | 38 | isset($options['on_stats']) ? $options['on_stats'] : null, |
39 | 39 | isset($options['request_id']) ? $options['request_id'] : null |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function getOnStatsCallback(?callable $initialOnStats, ?string $requestId) : \Closure |
57 | 57 | { |
58 | - return function (TransferStats $stats) use ($initialOnStats, $requestId) { |
|
58 | + return function(TransferStats $stats) use ($initialOnStats, $requestId) { |
|
59 | 59 | if (is_callable($initialOnStats)) { |
60 | 60 | call_user_func($initialOnStats, $stats); |
61 | 61 | } |
62 | 62 | |
63 | - $this->dataCollector->addTotalTime((float)$stats->getTransferTime()); |
|
63 | + $this->dataCollector->addTotalTime((float) $stats->getTransferTime()); |
|
64 | 64 | |
65 | 65 | if (($this->logger instanceof Logger) && $requestId) { |
66 | - $this->logger->addTransferTimeByRequestId($requestId, (float)$stats->getTransferTime()); |
|
66 | + $this->logger->addTransferTimeByRequestId($requestId, (float) $stats->getTransferTime()); |
|
67 | 67 | } |
68 | 68 | }; |
69 | 69 | } |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $response->getBody()->rewind(); |
60 | 60 | } |
61 | 61 | } else { |
62 | - $this->setBody(EightPointsGuzzleBundle::class . ': [response body log disabled]'); |
|
62 | + $this->setBody(EightPointsGuzzleBundle::class.': [response body log disabled]'); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -178,7 +178,7 @@ |
||
178 | 178 | } elseif ($logMode === false) { |
179 | 179 | return Logger::LOG_MODE_NONE; |
180 | 180 | } else { |
181 | - return $logMode; |
|
181 | + return $logMode; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 |
@@ -96,9 +96,9 @@ |
||
96 | 96 | // Allowed only for Symfony 4.2+ |
97 | 97 | if (method_exists($container, 'registerAliasForArgument')) { |
98 | 98 | if ('%eight_points_guzzle.http_client.class%' !== $options['class']) { |
99 | - $container->registerAliasForArgument($serviceName, $options['class'], $name . 'Client'); |
|
99 | + $container->registerAliasForArgument($serviceName, $options['class'], $name.'Client'); |
|
100 | 100 | } |
101 | - $container->registerAliasForArgument($serviceName, ClientInterface::class, $name . 'Client'); |
|
101 | + $container->registerAliasForArgument($serviceName, ClientInterface::class, $name.'Client'); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ->scalarNode('base_url') |
97 | 97 | ->defaultValue(null) |
98 | 98 | ->validate() |
99 | - ->ifTrue(function ($v) { |
|
99 | + ->ifTrue(function($v) { |
|
100 | 100 | return !is_string($v); |
101 | 101 | }) |
102 | 102 | ->thenInvalid('base_url can be: string') |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | ->integerNode('logging') |
107 | 107 | ->defaultValue(null) |
108 | 108 | ->beforeNormalization() |
109 | - ->always(function ($value): int { |
|
109 | + ->always(function($value): int { |
|
110 | 110 | if ($value === 1 || $value === true) { |
111 | 111 | return Logger::LOG_MODE_REQUEST_AND_RESPONSE; |
112 | 112 | } elseif ($value === 0 || $value === false) { |
113 | 113 | return Logger::LOG_MODE_NONE; |
114 | 114 | } else { |
115 | - return constant(Logger::class .'::LOG_MODE_' . strtoupper($value)); |
|
115 | + return constant(Logger::class.'::LOG_MODE_'.strtoupper($value)); |
|
116 | 116 | } |
117 | 117 | }) |
118 | 118 | ->end() |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ->scalarNode('handler') |
121 | 121 | ->defaultValue(null) |
122 | 122 | ->validate() |
123 | - ->ifTrue(function ($v) { |
|
123 | + ->ifTrue(function($v) { |
|
124 | 124 | return $v !== null && (!is_string($v) || !class_exists($v)); |
125 | 125 | }) |
126 | 126 | ->thenInvalid('handler must be a valid FQCN for a loaded class') |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | ->end() |
129 | 129 | ->arrayNode('options') |
130 | 130 | ->validate() |
131 | - ->ifTrue(function ($options) { |
|
131 | + ->ifTrue(function($options) { |
|
132 | 132 | return count($options['form_params']) && count($options['multipart']); |
133 | 133 | }) |
134 | 134 | ->thenInvalid('You cannot use form_params and multipart at the same time.') |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ->end() |
142 | 142 | ->variableNode('allow_redirects') |
143 | 143 | ->validate() |
144 | - ->ifTrue(function ($v) { |
|
144 | + ->ifTrue(function($v) { |
|
145 | 145 | return !is_array($v) && !is_bool($v); |
146 | 146 | }) |
147 | 147 | ->thenInvalid('allow_redirects can be: bool or array') |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ->end() |
150 | 150 | ->variableNode('auth') |
151 | 151 | ->validate() |
152 | - ->ifTrue(function ($v) { |
|
152 | + ->ifTrue(function($v) { |
|
153 | 153 | return !is_array($v) && !is_string($v); |
154 | 154 | }) |
155 | 155 | ->thenInvalid('auth can be: string or array') |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ->end() |
158 | 158 | ->variableNode('query') |
159 | 159 | ->validate() |
160 | - ->ifTrue(function ($v) { |
|
160 | + ->ifTrue(function($v) { |
|
161 | 161 | return !is_string($v) && !is_array($v); |
162 | 162 | }) |
163 | 163 | ->thenInvalid('query can be: string or array') |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | ->arrayNode('curl') |
167 | 167 | ->beforeNormalization() |
168 | 168 | ->ifArray() |
169 | - ->then(function (array $curlOptions) { |
|
169 | + ->then(function(array $curlOptions) { |
|
170 | 170 | $result = []; |
171 | 171 | |
172 | 172 | foreach ($curlOptions as $key => $value) { |
173 | - $optionName = 'CURLOPT_' . strtoupper($key); |
|
173 | + $optionName = 'CURLOPT_'.strtoupper($key); |
|
174 | 174 | |
175 | 175 | if (!defined($optionName)) { |
176 | 176 | throw new InvalidConfigurationException(sprintf( |
177 | - 'Invalid curl option in eight_points_guzzle: %s. ' . |
|
178 | - 'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL . |
|
177 | + 'Invalid curl option in eight_points_guzzle: %s. '. |
|
178 | + 'Ex: use sslversion for CURLOPT_SSLVERSION option. '.PHP_EOL. |
|
179 | 179 | 'See all available options: http://php.net/manual/en/function.curl-setopt.php', |
180 | 180 | $key |
181 | 181 | )); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ->end() |
193 | 193 | ->variableNode('cert') |
194 | 194 | ->validate() |
195 | - ->ifTrue(function ($v) { |
|
195 | + ->ifTrue(function($v) { |
|
196 | 196 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
197 | 197 | }) |
198 | 198 | ->thenInvalid('cert can be: string or array with two entries (path and password)') |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | ->end() |
201 | 201 | ->scalarNode('connect_timeout') |
202 | 202 | ->beforeNormalization() |
203 | - ->always(function ($v) { |
|
203 | + ->always(function($v) { |
|
204 | 204 | return is_numeric($v) ? (float) $v : $v; |
205 | 205 | }) |
206 | 206 | ->end() |
207 | 207 | ->validate() |
208 | - ->ifTrue(function ($v) { |
|
208 | + ->ifTrue(function($v) { |
|
209 | 209 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
210 | 210 | }) |
211 | 211 | ->thenInvalid('connect_timeout can be: float') |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ->booleanNode('debug')->end() |
215 | 215 | ->variableNode('decode_content') |
216 | 216 | ->validate() |
217 | - ->ifTrue(function ($v) { |
|
217 | + ->ifTrue(function($v) { |
|
218 | 218 | return !is_string($v) && !is_bool($v); |
219 | 219 | }) |
220 | 220 | ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)') |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ->end() |
231 | 231 | ->scalarNode('sink') |
232 | 232 | ->validate() |
233 | - ->ifTrue(function ($v) { |
|
233 | + ->ifTrue(function($v) { |
|
234 | 234 | return !is_string($v); |
235 | 235 | }) |
236 | 236 | ->thenInvalid('sink can be: string') |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | ->booleanNode('http_errors')->end() |
240 | 240 | ->variableNode('expect') |
241 | 241 | ->validate() |
242 | - ->ifTrue(function ($v) { |
|
242 | + ->ifTrue(function($v) { |
|
243 | 243 | return !is_bool($v) && !is_int($v); |
244 | 244 | }) |
245 | 245 | ->thenInvalid('expect can be: bool or int') |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ->end() |
248 | 248 | ->variableNode('ssl_key') |
249 | 249 | ->validate() |
250 | - ->ifTrue(function ($v) { |
|
250 | + ->ifTrue(function($v) { |
|
251 | 251 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
252 | 252 | }) |
253 | 253 | ->thenInvalid('ssl_key can be: string or array with two entries (path and password)') |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | ->booleanNode('synchronous')->end() |
258 | 258 | ->scalarNode('read_timeout') |
259 | 259 | ->beforeNormalization() |
260 | - ->always(function ($v) { |
|
260 | + ->always(function($v) { |
|
261 | 261 | return is_numeric($v) ? (float) $v : $v; |
262 | 262 | }) |
263 | 263 | ->end() |
264 | 264 | ->validate() |
265 | - ->ifTrue(function ($v) { |
|
265 | + ->ifTrue(function($v) { |
|
266 | 266 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
267 | 267 | }) |
268 | 268 | ->thenInvalid('read_timeout can be: float') |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | ->end() |
271 | 271 | ->scalarNode('timeout') |
272 | 272 | ->beforeNormalization() |
273 | - ->always(function ($v) { |
|
273 | + ->always(function($v) { |
|
274 | 274 | return is_numeric($v) ? (float) $v : $v; |
275 | 275 | }) |
276 | 276 | ->end() |
277 | 277 | ->validate() |
278 | - ->ifTrue(function ($v) { |
|
278 | + ->ifTrue(function($v) { |
|
279 | 279 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
280 | 280 | }) |
281 | 281 | ->thenInvalid('timeout can be: float') |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | ->end() |
284 | 284 | ->variableNode('verify') |
285 | 285 | ->validate() |
286 | - ->ifTrue(function ($v) { |
|
286 | + ->ifTrue(function($v) { |
|
287 | 287 | return !is_bool($v) && !is_string($v); |
288 | 288 | }) |
289 | 289 | ->thenInvalid('verify can be: bool or string') |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | ->end() |
314 | 314 | ->scalarNode('version') |
315 | 315 | ->validate() |
316 | - ->ifTrue(function ($v) { |
|
316 | + ->ifTrue(function($v) { |
|
317 | 317 | return !is_string($v) && !is_float($v); |
318 | 318 | }) |
319 | 319 | ->thenInvalid('version can be: string or float') |