@@ -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); |
@@ -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') |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ->scalarNode('handler') |
| 90 | 90 | ->defaultValue(null) |
| 91 | 91 | ->validate() |
| 92 | - ->ifTrue(function ($v) { |
|
| 92 | + ->ifTrue(function($v) { |
|
| 93 | 93 | return $v !== null && (!is_string($v) || !class_exists($v)); |
| 94 | 94 | }) |
| 95 | 95 | ->thenInvalid('handler must be a valid FQCN for a loaded class') |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | ->end() |
| 98 | 98 | ->arrayNode('options') |
| 99 | 99 | ->validate() |
| 100 | - ->ifTrue(function ($options) { |
|
| 100 | + ->ifTrue(function($options) { |
|
| 101 | 101 | return count($options['form_params']) && count($options['multipart']); |
| 102 | 102 | }) |
| 103 | 103 | ->thenInvalid('You cannot use form_params and multipart at the same time.') |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | ->end() |
| 111 | 111 | ->variableNode('allow_redirects') |
| 112 | 112 | ->validate() |
| 113 | - ->ifTrue(function ($v) { |
|
| 113 | + ->ifTrue(function($v) { |
|
| 114 | 114 | return !is_array($v) && !is_bool($v); |
| 115 | 115 | }) |
| 116 | 116 | ->thenInvalid('allow_redirects can be: bool or array') |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | ->end() |
| 119 | 119 | ->variableNode('auth') |
| 120 | 120 | ->validate() |
| 121 | - ->ifTrue(function ($v) { |
|
| 121 | + ->ifTrue(function($v) { |
|
| 122 | 122 | return !is_array($v) && !is_string($v); |
| 123 | 123 | }) |
| 124 | 124 | ->thenInvalid('auth can be: string or array') |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | ->end() |
| 127 | 127 | ->variableNode('query') |
| 128 | 128 | ->validate() |
| 129 | - ->ifTrue(function ($v) { |
|
| 129 | + ->ifTrue(function($v) { |
|
| 130 | 130 | return !is_string($v) && !is_array($v); |
| 131 | 131 | }) |
| 132 | 132 | ->thenInvalid('query can be: string or array') |
@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | ->arrayNode('curl') |
| 136 | 136 | ->beforeNormalization() |
| 137 | 137 | ->ifArray() |
| 138 | - ->then(function (array $curlOptions) { |
|
| 138 | + ->then(function(array $curlOptions) { |
|
| 139 | 139 | $result = []; |
| 140 | 140 | |
| 141 | 141 | foreach ($curlOptions as $key => $value) { |
| 142 | - $optionName = 'CURLOPT_' . strtoupper($key); |
|
| 142 | + $optionName = 'CURLOPT_'.strtoupper($key); |
|
| 143 | 143 | |
| 144 | 144 | if (!defined($optionName)) { |
| 145 | 145 | throw new InvalidConfigurationException(sprintf( |
| 146 | - 'Invalid curl option in eight_points_guzzle: %s. ' . |
|
| 147 | - 'Ex: use sslversion for CURLOPT_SSLVERSION option. ' . PHP_EOL . |
|
| 146 | + 'Invalid curl option in eight_points_guzzle: %s. '. |
|
| 147 | + 'Ex: use sslversion for CURLOPT_SSLVERSION option. '.PHP_EOL. |
|
| 148 | 148 | 'See all available options: http://php.net/manual/en/function.curl-setopt.php', |
| 149 | 149 | $key |
| 150 | 150 | )); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | ->end() |
| 162 | 162 | ->variableNode('cert') |
| 163 | 163 | ->validate() |
| 164 | - ->ifTrue(function ($v) { |
|
| 164 | + ->ifTrue(function($v) { |
|
| 165 | 165 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
| 166 | 166 | }) |
| 167 | 167 | ->thenInvalid('cert can be: string or array with two entries (path and password)') |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | ->end() |
| 170 | 170 | ->scalarNode('connect_timeout') |
| 171 | 171 | ->beforeNormalization() |
| 172 | - ->always(function ($v) { |
|
| 172 | + ->always(function($v) { |
|
| 173 | 173 | return is_numeric($v) ? (float) $v : $v; |
| 174 | 174 | }) |
| 175 | 175 | ->end() |
| 176 | 176 | ->validate() |
| 177 | - ->ifTrue(function ($v) { |
|
| 177 | + ->ifTrue(function($v) { |
|
| 178 | 178 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
| 179 | 179 | }) |
| 180 | 180 | ->thenInvalid('connect_timeout can be: float') |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | ->booleanNode('debug')->end() |
| 184 | 184 | ->variableNode('decode_content') |
| 185 | 185 | ->validate() |
| 186 | - ->ifTrue(function ($v) { |
|
| 186 | + ->ifTrue(function($v) { |
|
| 187 | 187 | return !is_string($v) && !is_bool($v); |
| 188 | 188 | }) |
| 189 | 189 | ->thenInvalid('decode_content can be: bool or string (gzip, compress, deflate, etc...)') |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | ->end() |
| 201 | 201 | ->scalarNode('sink') |
| 202 | 202 | ->validate() |
| 203 | - ->ifTrue(function ($v) { |
|
| 203 | + ->ifTrue(function($v) { |
|
| 204 | 204 | return !is_string($v); |
| 205 | 205 | }) |
| 206 | 206 | ->thenInvalid('sink can be: string') |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | ->booleanNode('http_errors')->end() |
| 210 | 210 | ->variableNode('expect') |
| 211 | 211 | ->validate() |
| 212 | - ->ifTrue(function ($v) { |
|
| 212 | + ->ifTrue(function($v) { |
|
| 213 | 213 | return !is_bool($v) && !is_int($v); |
| 214 | 214 | }) |
| 215 | 215 | ->thenInvalid('expect can be: bool or int') |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | ->end() |
| 218 | 218 | ->variableNode('ssl_key') |
| 219 | 219 | ->validate() |
| 220 | - ->ifTrue(function ($v) { |
|
| 220 | + ->ifTrue(function($v) { |
|
| 221 | 221 | return !is_string($v) && (!is_array($v) || count($v) !== 2); |
| 222 | 222 | }) |
| 223 | 223 | ->thenInvalid('ssl_key can be: string or array with two entries (path and password)') |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | ->booleanNode('synchronous')->end() |
| 228 | 228 | ->scalarNode('read_timeout') |
| 229 | 229 | ->beforeNormalization() |
| 230 | - ->always(function ($v) { |
|
| 230 | + ->always(function($v) { |
|
| 231 | 231 | return is_numeric($v) ? (float) $v : $v; |
| 232 | 232 | }) |
| 233 | 233 | ->end() |
| 234 | 234 | ->validate() |
| 235 | - ->ifTrue(function ($v) { |
|
| 235 | + ->ifTrue(function($v) { |
|
| 236 | 236 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
| 237 | 237 | }) |
| 238 | 238 | ->thenInvalid('read_timeout can be: float') |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | ->end() |
| 241 | 241 | ->scalarNode('timeout') |
| 242 | 242 | ->beforeNormalization() |
| 243 | - ->always(function ($v) { |
|
| 243 | + ->always(function($v) { |
|
| 244 | 244 | return is_numeric($v) ? (float) $v : $v; |
| 245 | 245 | }) |
| 246 | 246 | ->end() |
| 247 | 247 | ->validate() |
| 248 | - ->ifTrue(function ($v) { |
|
| 248 | + ->ifTrue(function($v) { |
|
| 249 | 249 | return !is_float($v) && !(is_string($v) && strpos($v, 'env_') === 0); |
| 250 | 250 | }) |
| 251 | 251 | ->thenInvalid('timeout can be: float') |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | ->end() |
| 254 | 254 | ->variableNode('verify') |
| 255 | 255 | ->validate() |
| 256 | - ->ifTrue(function ($v) { |
|
| 256 | + ->ifTrue(function($v) { |
|
| 257 | 257 | return !is_bool($v) && !is_string($v); |
| 258 | 258 | }) |
| 259 | 259 | ->thenInvalid('verify can be: bool or string') |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | ->end() |
| 284 | 284 | ->scalarNode('version') |
| 285 | 285 | ->validate() |
| 286 | - ->ifTrue(function ($v) { |
|
| 286 | + ->ifTrue(function($v) { |
|
| 287 | 287 | return !is_string($v) && !is_float($v); |
| 288 | 288 | }) |
| 289 | 289 | ->thenInvalid('version can be: string or float') |
@@ -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 | } |