@@ -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 | ); |
@@ -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); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ->scalarNode('base_url') |
80 | 80 | ->defaultValue(null) |
81 | 81 | ->validate() |
82 | - ->ifTrue(function ($v) { |
|
82 | + ->ifTrue(function($v) { |
|
83 | 83 | return !is_string($v); |
84 | 84 | }) |
85 | 85 | ->thenInvalid('base_url can be: string') |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ->booleanNode('lazy')->defaultValue(false)->end() |
89 | 89 | ->arrayNode('options') |
90 | 90 | ->validate() |
91 | - ->ifTrue(function ($options) { |
|
91 | + ->ifTrue(function($options) { |
|
92 | 92 | return count($options['form_params']) && count($options['multipart']); |
93 | 93 | }) |
94 | 94 | ->thenInvalid('You cannot use form_params and multipart at the same time.') |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | ->end() |
102 | 102 | ->variableNode('allow_redirects') |
103 | 103 | ->validate() |
104 | - ->ifTrue(function ($v) { |
|
104 | + ->ifTrue(function($v) { |
|
105 | 105 | return !is_array($v) && !is_bool($v); |
106 | 106 | }) |
107 | 107 | ->thenInvalid('allow_redirects can be: bool or array') |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ->end() |
110 | 110 | ->variableNode('auth') |
111 | 111 | ->validate() |
112 | - ->ifTrue(function ($v) { |
|
112 | + ->ifTrue(function($v) { |
|
113 | 113 | return !is_array($v) && !is_string($v); |
114 | 114 | }) |
115 | 115 | ->thenInvalid('auth can be: string or array') |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ->end() |
118 | 118 | ->variableNode('query') |
119 | 119 | ->validate() |
120 | - ->ifTrue(function ($v) { |
|
120 | + ->ifTrue(function($v) { |
|
121 | 121 | return !is_string($v) && !is_array($v); |
122 | 122 | }) |
123 | 123 | ->thenInvalid('query can be: string or array') |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | ->arrayNode('curl') |
127 | 127 | ->beforeNormalization() |
128 | 128 | ->ifArray() |
129 | - ->then(function (array $curlOptions) { |
|
129 | + ->then(function(array $curlOptions) { |
|
130 | 130 | $result = []; |
131 | 131 | |
132 | 132 | foreach ($curlOptions as $key => $value) { |
133 | - $optionName = 'CURLOPT_' . strtoupper($key); |
|
133 | + $optionName = 'CURLOPT_'.strtoupper($key); |
|
134 | 134 | |
135 | 135 | if (!defined($optionName)) { |
136 | 136 | throw new InvalidConfigurationException(sprintf( |
137 | - 'Invalid curl option in eight_points_guzzle: %s. ' . |
|
138 | - 'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL . |
|
137 | + 'Invalid curl option in eight_points_guzzle: %s. '. |
|
138 | + 'Ex: use sslversion for CURLOPT_SSLVERSION option. '.PHP_EOL. |
|
139 | 139 | 'See all available options: http://php.net/manual/en/function.curl-setopt.php', |
140 | 140 | $key |
141 | 141 | )); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ->end() |
153 | 153 | ->variableNode('cert') |
154 | 154 | ->validate() |
155 | - ->ifTrue(function ($v) { |
|
155 | + ->ifTrue(function($v) { |
|
156 | 156 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
157 | 157 | }) |
158 | 158 | ->thenInvalid('cert can be: string or array with two entries (path and password)') |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | ->end() |
161 | 161 | ->scalarNode('connect_timeout') |
162 | 162 | ->beforeNormalization() |
163 | - ->always(function ($v) { |
|
163 | + ->always(function($v) { |
|
164 | 164 | return is_numeric($v) ? (float) $v : $v; |
165 | 165 | }) |
166 | 166 | ->end() |
167 | 167 | ->validate() |
168 | - ->ifTrue(function ($v) { |
|
168 | + ->ifTrue(function($v) { |
|
169 | 169 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
170 | 170 | }) |
171 | 171 | ->thenInvalid('connect_timeout can be: float') |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ->booleanNode('debug')->end() |
175 | 175 | ->variableNode('decode_content') |
176 | 176 | ->validate() |
177 | - ->ifTrue(function ($v) { |
|
177 | + ->ifTrue(function($v) { |
|
178 | 178 | return !is_string($v) && !is_bool($v); |
179 | 179 | }) |
180 | 180 | ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)') |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ->end() |
192 | 192 | ->scalarNode('sink') |
193 | 193 | ->validate() |
194 | - ->ifTrue(function ($v) { |
|
194 | + ->ifTrue(function($v) { |
|
195 | 195 | return !is_string($v); |
196 | 196 | }) |
197 | 197 | ->thenInvalid('sink can be: string') |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ->booleanNode('http_errors')->end() |
201 | 201 | ->variableNode('expect') |
202 | 202 | ->validate() |
203 | - ->ifTrue(function ($v) { |
|
203 | + ->ifTrue(function($v) { |
|
204 | 204 | return !is_bool($v) && !is_int($v); |
205 | 205 | }) |
206 | 206 | ->thenInvalid('expect can be: bool or int') |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ->end() |
209 | 209 | ->variableNode('ssl_key') |
210 | 210 | ->validate() |
211 | - ->ifTrue(function ($v) { |
|
211 | + ->ifTrue(function($v) { |
|
212 | 212 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
213 | 213 | }) |
214 | 214 | ->thenInvalid('ssl_key can be: string or array with two entries (path and password)') |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | ->booleanNode('synchronous')->end() |
219 | 219 | ->scalarNode('read_timeout') |
220 | 220 | ->beforeNormalization() |
221 | - ->always(function ($v) { |
|
221 | + ->always(function($v) { |
|
222 | 222 | return is_numeric($v) ? (float) $v : $v; |
223 | 223 | }) |
224 | 224 | ->end() |
225 | 225 | ->validate() |
226 | - ->ifTrue(function ($v) { |
|
226 | + ->ifTrue(function($v) { |
|
227 | 227 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
228 | 228 | }) |
229 | 229 | ->thenInvalid('read_timeout can be: float') |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | ->end() |
232 | 232 | ->scalarNode('timeout') |
233 | 233 | ->beforeNormalization() |
234 | - ->always(function ($v) { |
|
234 | + ->always(function($v) { |
|
235 | 235 | return is_numeric($v) ? (float) $v : $v; |
236 | 236 | }) |
237 | 237 | ->end() |
238 | 238 | ->validate() |
239 | - ->ifTrue(function ($v) { |
|
239 | + ->ifTrue(function($v) { |
|
240 | 240 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
241 | 241 | }) |
242 | 242 | ->thenInvalid('timeout can be: float') |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | ->end() |
245 | 245 | ->variableNode('verify') |
246 | 246 | ->validate() |
247 | - ->ifTrue(function ($v) { |
|
247 | + ->ifTrue(function($v) { |
|
248 | 248 | return !is_bool($v) && !is_string($v); |
249 | 249 | }) |
250 | 250 | ->thenInvalid('verify can be: bool or string') |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | ->end() |
275 | 275 | ->scalarNode('version') |
276 | 276 | ->validate() |
277 | - ->ifTrue(function ($v) { |
|
277 | + ->ifTrue(function($v) { |
|
278 | 278 | return !is_string($v) && !is_float($v); |
279 | 279 | }) |
280 | 280 | ->thenInvalid('version can be: string or float') |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | ->scalarNode('handler') |
284 | 284 | ->defaultValue(null) |
285 | 285 | ->validate() |
286 | - ->ifTrue(function ($v) { |
|
286 | + ->ifTrue(function($v) { |
|
287 | 287 | return $v !== null && (!is_string($v) || !class_exists($v)); |
288 | 288 | }) |
289 | 289 | ->thenInvalid('handler must be a valid FQCN for a loaded class') |