@@ -120,7 +120,7 @@ |
||
120 | 120 | $container->setDefinition($eventServiceName, $eventService); |
121 | 121 | |
122 | 122 | // Create the event Dispatch Middleware |
123 | - $eventExpression = new Expression(sprintf("service('%s').dispatchEvent()", $eventServiceName)); |
|
123 | + $eventExpression = new Expression(sprintf("service('%s').dispatchEvent()", $eventServiceName)); |
|
124 | 124 | |
125 | 125 | $handler = new Definition(HandlerStack::class); |
126 | 126 | $handler->setFactory([HandlerStack::class, 'create']); |
@@ -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); |
@@ -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($initialOnStats, $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 ($requestId && $this->logger instanceof Logger) { |
66 | - $this->logger->addTransferTimeByRequestId($requestId, (float)$stats->getTransferTime()); |
|
66 | + $this->logger->addTransferTimeByRequestId($requestId, (float) $stats->getTransferTime()); |
|
67 | 67 | } |
68 | 68 | }; |
69 | 69 | } |
@@ -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 | ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ->scalarNode('base_url') |
79 | 79 | ->defaultValue(null) |
80 | 80 | ->validate() |
81 | - ->ifTrue(function ($v) { |
|
81 | + ->ifTrue(function($v) { |
|
82 | 82 | return !is_string($v); |
83 | 83 | }) |
84 | 84 | ->thenInvalid('base_url can be: string') |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ->booleanNode('lazy')->defaultValue(false)->end() |
88 | 88 | ->arrayNode('options') |
89 | 89 | ->validate() |
90 | - ->ifTrue(function ($options) { |
|
90 | + ->ifTrue(function($options) { |
|
91 | 91 | return count($options['form_params']) && count($options['multipart']); |
92 | 92 | }) |
93 | 93 | ->thenInvalid('You cannot use form_params and multipart at the same time.') |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ->end() |
101 | 101 | ->variableNode('allow_redirects') |
102 | 102 | ->validate() |
103 | - ->ifTrue(function ($v) { |
|
103 | + ->ifTrue(function($v) { |
|
104 | 104 | return !is_array($v) && !is_bool($v); |
105 | 105 | }) |
106 | 106 | ->thenInvalid('allow_redirects can be: bool or array') |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ->end() |
109 | 109 | ->variableNode('auth') |
110 | 110 | ->validate() |
111 | - ->ifTrue(function ($v) { |
|
111 | + ->ifTrue(function($v) { |
|
112 | 112 | return !is_array($v) && !is_string($v); |
113 | 113 | }) |
114 | 114 | ->thenInvalid('auth can be: string or array') |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | ->end() |
117 | 117 | ->variableNode('query') |
118 | 118 | ->validate() |
119 | - ->ifTrue(function ($v) { |
|
119 | + ->ifTrue(function($v) { |
|
120 | 120 | return !is_string($v) && !is_array($v); |
121 | 121 | }) |
122 | 122 | ->thenInvalid('query can be: string or array') |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | ->arrayNode('curl') |
126 | 126 | ->beforeNormalization() |
127 | 127 | ->ifArray() |
128 | - ->then(function (array $curlOptions) { |
|
128 | + ->then(function(array $curlOptions) { |
|
129 | 129 | $result = []; |
130 | 130 | |
131 | 131 | foreach ($curlOptions as $key => $value) { |
132 | - $optionName = 'CURLOPT_' . strtoupper($key); |
|
132 | + $optionName = 'CURLOPT_'.strtoupper($key); |
|
133 | 133 | |
134 | 134 | if (!defined($optionName)) { |
135 | 135 | throw new InvalidConfigurationException(sprintf( |
136 | - 'Invalid curl option in eight_points_guzzle: %s. ' . |
|
137 | - 'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL . |
|
136 | + 'Invalid curl option in eight_points_guzzle: %s. '. |
|
137 | + 'Ex: use sslversion for CURLOPT_SSLVERSION option. '.PHP_EOL. |
|
138 | 138 | 'See all available options: http://php.net/manual/en/function.curl-setopt.php', |
139 | 139 | $key |
140 | 140 | )); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ->end() |
152 | 152 | ->variableNode('cert') |
153 | 153 | ->validate() |
154 | - ->ifTrue(function ($v) { |
|
154 | + ->ifTrue(function($v) { |
|
155 | 155 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
156 | 156 | }) |
157 | 157 | ->thenInvalid('cert can be: string or array with two entries (path and password)') |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | ->end() |
160 | 160 | ->scalarNode('connect_timeout') |
161 | 161 | ->beforeNormalization() |
162 | - ->always(function ($v) { |
|
162 | + ->always(function($v) { |
|
163 | 163 | return is_numeric($v) ? (float) $v : $v; |
164 | 164 | }) |
165 | 165 | ->end() |
166 | 166 | ->validate() |
167 | - ->ifTrue(function ($v) { |
|
167 | + ->ifTrue(function($v) { |
|
168 | 168 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
169 | 169 | }) |
170 | 170 | ->thenInvalid('connect_timeout can be: float') |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ->booleanNode('debug')->end() |
174 | 174 | ->variableNode('decode_content') |
175 | 175 | ->validate() |
176 | - ->ifTrue(function ($v) { |
|
176 | + ->ifTrue(function($v) { |
|
177 | 177 | return !is_string($v) && !is_bool($v); |
178 | 178 | }) |
179 | 179 | ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)') |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ->end() |
191 | 191 | ->scalarNode('sink') |
192 | 192 | ->validate() |
193 | - ->ifTrue(function ($v) { |
|
193 | + ->ifTrue(function($v) { |
|
194 | 194 | return !is_string($v); |
195 | 195 | }) |
196 | 196 | ->thenInvalid('sink can be: string') |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ->booleanNode('http_errors')->end() |
200 | 200 | ->variableNode('expect') |
201 | 201 | ->validate() |
202 | - ->ifTrue(function ($v) { |
|
202 | + ->ifTrue(function($v) { |
|
203 | 203 | return !is_bool($v) && !is_int($v); |
204 | 204 | }) |
205 | 205 | ->thenInvalid('expect can be: bool or int') |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ->end() |
208 | 208 | ->variableNode('ssl_key') |
209 | 209 | ->validate() |
210 | - ->ifTrue(function ($v) { |
|
210 | + ->ifTrue(function($v) { |
|
211 | 211 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
212 | 212 | }) |
213 | 213 | ->thenInvalid('ssl_key can be: string or array with two entries (path and password)') |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | ->booleanNode('synchronous')->end() |
218 | 218 | ->scalarNode('read_timeout') |
219 | 219 | ->beforeNormalization() |
220 | - ->always(function ($v) { |
|
220 | + ->always(function($v) { |
|
221 | 221 | return is_numeric($v) ? (float) $v : $v; |
222 | 222 | }) |
223 | 223 | ->end() |
224 | 224 | ->validate() |
225 | - ->ifTrue(function ($v) { |
|
225 | + ->ifTrue(function($v) { |
|
226 | 226 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
227 | 227 | }) |
228 | 228 | ->thenInvalid('read_timeout can be: float') |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | ->end() |
231 | 231 | ->scalarNode('timeout') |
232 | 232 | ->beforeNormalization() |
233 | - ->always(function ($v) { |
|
233 | + ->always(function($v) { |
|
234 | 234 | return is_numeric($v) ? (float) $v : $v; |
235 | 235 | }) |
236 | 236 | ->end() |
237 | 237 | ->validate() |
238 | - ->ifTrue(function ($v) { |
|
238 | + ->ifTrue(function($v) { |
|
239 | 239 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
240 | 240 | }) |
241 | 241 | ->thenInvalid('timeout can be: float') |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | ->end() |
244 | 244 | ->variableNode('verify') |
245 | 245 | ->validate() |
246 | - ->ifTrue(function ($v) { |
|
246 | + ->ifTrue(function($v) { |
|
247 | 247 | return !is_bool($v) && !is_string($v); |
248 | 248 | }) |
249 | 249 | ->thenInvalid('verify can be: bool or string') |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | ->end() |
274 | 274 | ->scalarNode('version') |
275 | 275 | ->validate() |
276 | - ->ifTrue(function ($v) { |
|
276 | + ->ifTrue(function($v) { |
|
277 | 277 | return !is_string($v) && !is_float($v); |
278 | 278 | }) |
279 | 279 | ->thenInvalid('version can be: string or float') |
@@ -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); |