@@ -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 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | ->scalarNode('base_url') |
102 | 102 | ->defaultValue(null) |
103 | 103 | ->validate() |
104 | - ->ifTrue(function ($v) { |
|
104 | + ->ifTrue(function($v) { |
|
105 | 105 | return !is_string($v); |
106 | 106 | }) |
107 | 107 | ->thenInvalid('base_url can be: string') |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ->scalarNode('handler') |
118 | 118 | ->defaultValue(null) |
119 | 119 | ->validate() |
120 | - ->ifTrue(function ($v) { |
|
120 | + ->ifTrue(function($v) { |
|
121 | 121 | return $v !== null && (!is_string($v) || !class_exists($v)); |
122 | 122 | }) |
123 | 123 | ->thenInvalid('handler must be a valid FQCN for a loaded class') |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | ->end() |
126 | 126 | ->arrayNode('options') |
127 | 127 | ->validate() |
128 | - ->ifTrue(function ($options) { |
|
128 | + ->ifTrue(function($options) { |
|
129 | 129 | return count($options['form_params']) && count($options['multipart']); |
130 | 130 | }) |
131 | 131 | ->thenInvalid('You cannot use form_params and multipart at the same time.') |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ->end() |
139 | 139 | ->variableNode('allow_redirects') |
140 | 140 | ->validate() |
141 | - ->ifTrue(function ($v) { |
|
141 | + ->ifTrue(function($v) { |
|
142 | 142 | return !is_array($v) && !is_bool($v); |
143 | 143 | }) |
144 | 144 | ->thenInvalid('allow_redirects can be: bool or array') |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ->end() |
147 | 147 | ->variableNode('auth') |
148 | 148 | ->validate() |
149 | - ->ifTrue(function ($v) { |
|
149 | + ->ifTrue(function($v) { |
|
150 | 150 | return !is_array($v) && !is_string($v); |
151 | 151 | }) |
152 | 152 | ->thenInvalid('auth can be: string or array') |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | ->end() |
155 | 155 | ->variableNode('query') |
156 | 156 | ->validate() |
157 | - ->ifTrue(function ($v) { |
|
157 | + ->ifTrue(function($v) { |
|
158 | 158 | return !is_string($v) && !is_array($v); |
159 | 159 | }) |
160 | 160 | ->thenInvalid('query can be: string or array') |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | ->arrayNode('curl') |
164 | 164 | ->beforeNormalization() |
165 | 165 | ->ifArray() |
166 | - ->then(function (array $curlOptions) { |
|
166 | + ->then(function(array $curlOptions) { |
|
167 | 167 | $result = []; |
168 | 168 | |
169 | 169 | foreach ($curlOptions as $key => $value) { |
170 | - $optionName = 'CURLOPT_' . strtoupper($key); |
|
170 | + $optionName = 'CURLOPT_'.strtoupper($key); |
|
171 | 171 | |
172 | 172 | if (!defined($optionName)) { |
173 | 173 | throw new InvalidConfigurationException(sprintf( |
174 | - 'Invalid curl option in eight_points_guzzle: %s. ' . |
|
175 | - 'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL . |
|
174 | + 'Invalid curl option in eight_points_guzzle: %s. '. |
|
175 | + 'Ex: use sslversion for CURLOPT_SSLVERSION option. '.PHP_EOL. |
|
176 | 176 | 'See all available options: http://php.net/manual/en/function.curl-setopt.php', |
177 | 177 | $key |
178 | 178 | )); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | ->end() |
190 | 190 | ->variableNode('cert') |
191 | 191 | ->validate() |
192 | - ->ifTrue(function ($v) { |
|
192 | + ->ifTrue(function($v) { |
|
193 | 193 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
194 | 194 | }) |
195 | 195 | ->thenInvalid('cert can be: string or array with two entries (path and password)') |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | ->end() |
198 | 198 | ->scalarNode('connect_timeout') |
199 | 199 | ->beforeNormalization() |
200 | - ->always(function ($v) { |
|
200 | + ->always(function($v) { |
|
201 | 201 | return is_numeric($v) ? (float) $v : $v; |
202 | 202 | }) |
203 | 203 | ->end() |
204 | 204 | ->validate() |
205 | - ->ifTrue(function ($v) { |
|
205 | + ->ifTrue(function($v) { |
|
206 | 206 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
207 | 207 | }) |
208 | 208 | ->thenInvalid('connect_timeout can be: float') |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | ->booleanNode('debug')->end() |
212 | 212 | ->variableNode('decode_content') |
213 | 213 | ->validate() |
214 | - ->ifTrue(function ($v) { |
|
214 | + ->ifTrue(function($v) { |
|
215 | 215 | return !is_string($v) && !is_bool($v); |
216 | 216 | }) |
217 | 217 | ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)') |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ->end() |
228 | 228 | ->scalarNode('sink') |
229 | 229 | ->validate() |
230 | - ->ifTrue(function ($v) { |
|
230 | + ->ifTrue(function($v) { |
|
231 | 231 | return !is_string($v); |
232 | 232 | }) |
233 | 233 | ->thenInvalid('sink can be: string') |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | ->booleanNode('http_errors')->end() |
237 | 237 | ->variableNode('expect') |
238 | 238 | ->validate() |
239 | - ->ifTrue(function ($v) { |
|
239 | + ->ifTrue(function($v) { |
|
240 | 240 | return !is_bool($v) && !is_int($v); |
241 | 241 | }) |
242 | 242 | ->thenInvalid('expect can be: bool or int') |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | ->end() |
245 | 245 | ->variableNode('ssl_key') |
246 | 246 | ->validate() |
247 | - ->ifTrue(function ($v) { |
|
247 | + ->ifTrue(function($v) { |
|
248 | 248 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
249 | 249 | }) |
250 | 250 | ->thenInvalid('ssl_key can be: string or array with two entries (path and password)') |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | ->booleanNode('synchronous')->end() |
255 | 255 | ->scalarNode('read_timeout') |
256 | 256 | ->beforeNormalization() |
257 | - ->always(function ($v) { |
|
257 | + ->always(function($v) { |
|
258 | 258 | return is_numeric($v) ? (float) $v : $v; |
259 | 259 | }) |
260 | 260 | ->end() |
261 | 261 | ->validate() |
262 | - ->ifTrue(function ($v) { |
|
262 | + ->ifTrue(function($v) { |
|
263 | 263 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
264 | 264 | }) |
265 | 265 | ->thenInvalid('read_timeout can be: float') |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | ->end() |
268 | 268 | ->scalarNode('timeout') |
269 | 269 | ->beforeNormalization() |
270 | - ->always(function ($v) { |
|
270 | + ->always(function($v) { |
|
271 | 271 | return is_numeric($v) ? (float) $v : $v; |
272 | 272 | }) |
273 | 273 | ->end() |
274 | 274 | ->validate() |
275 | - ->ifTrue(function ($v) { |
|
275 | + ->ifTrue(function($v) { |
|
276 | 276 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
277 | 277 | }) |
278 | 278 | ->thenInvalid('timeout can be: float') |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ->end() |
281 | 281 | ->variableNode('verify') |
282 | 282 | ->validate() |
283 | - ->ifTrue(function ($v) { |
|
283 | + ->ifTrue(function($v) { |
|
284 | 284 | return !is_bool($v) && !is_string($v); |
285 | 285 | }) |
286 | 286 | ->thenInvalid('verify can be: bool or string') |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | ->end() |
311 | 311 | ->scalarNode('version') |
312 | 312 | ->validate() |
313 | - ->ifTrue(function ($v) { |
|
313 | + ->ifTrue(function($v) { |
|
314 | 314 | return !is_string($v) && !is_float($v); |
315 | 315 | }) |
316 | 316 | ->thenInvalid('version can be: string or float') |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | } elseif ($v === 0 || $v === false) { |
340 | 340 | return Logger::LOG_MODE_NONE; |
341 | 341 | } else { |
342 | - return constant(Logger::class .'::LOG_MODE_' . strtoupper($v)); |
|
342 | + return constant(Logger::class.'::LOG_MODE_'.strtoupper($v)); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | $container->setDefinition($serviceName, $client); |
95 | 95 | } |
96 | 96 | |
97 | - $clientsWithLogging = array_filter($config['clients'], function ($options) use ($logging) { |
|
97 | + $clientsWithLogging = array_filter($config['clients'], function($options) use ($logging) { |
|
98 | 98 | return $options['logging'] !== false && $logging !== false; |
99 | 99 | }); |
100 | 100 | |
101 | - if (count($clientsWithLogging)>0) { |
|
101 | + if (count($clientsWithLogging) > 0) { |
|
102 | 102 | $this->defineTwigDebugExtension($container); |
103 | 103 | $this->defineDataCollector($container, $config['slow_response_time'] / 1000); |
104 | 104 | $this->defineFormatter($container); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $container->setDefinition($eventServiceName, $eventService); |
127 | 127 | |
128 | 128 | // Create the event Dispatch Middleware |
129 | - $eventExpression = new Expression(sprintf("service('%s').dispatchEvent()", $eventServiceName)); |
|
129 | + $eventExpression = new Expression(sprintf("service('%s').dispatchEvent()", $eventServiceName)); |
|
130 | 130 | |
131 | 131 | $handler = new Definition(HandlerStack::class); |
132 | 132 | $handler->setFactory([HandlerStack::class, 'create']); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | $dataCollectorDefinition = new Definition('%eight_points_guzzle.data_collector.class%'); |
218 | 218 | |
219 | - $dataCollectorDefinition->addArgument(array_map(function ($loggerId) : Reference { |
|
219 | + $dataCollectorDefinition->addArgument(array_map(function($loggerId) : Reference { |
|
220 | 220 | return new Reference($loggerId); |
221 | 221 | }, array_keys($container->findTaggedServiceIds('eight_points_guzzle.logger')))); |
222 | 222 |
@@ -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 |