PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / S3 / ExpiresParsingMiddleware.php

ExpiresParsingMiddleware.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/Aws/S3/ExpiresParsingMiddleware.php

47 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\S3;
4
5 use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
6 use Dudlewebs\WPMCS\s3\Aws\ResultInterface;
7 use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
8 /**
9 * Logs a warning when the `expires` header
10 * fails to be parsed.
11 *
12 * @internal
13 */
14 class ExpiresParsingMiddleware
15 {
16 /** @var callable */
17 private $nextHandler;
18 /**
19 * Create a middleware wrapper function.
20 *
21 * @return callable
22 */
23 public static function wrap()
24 {
25 return function (callable $handler) {
26 return new self($handler);
27 };
28 }
29 /**
30 * @param callable $nextHandler Next handler to invoke.
31 */
32 public function __construct(callable $nextHandler)
33 {
34 $this->nextHandler = $nextHandler;
35 }
36 public function __invoke(CommandInterface $command, ?RequestInterface $request = null)
37 {
38 $next = $this->nextHandler;
39 return $next($command, $request)->then(function (ResultInterface $result) {
40 if (empty($result['Expires']) && !empty($result['ExpiresString'])) {
41 \trigger_error("Failed to parse the `expires` header as a timestamp due to " . " an invalid timestamp format.\nPlease refer to `ExpiresString` " . "for the unparsed string format of this header.\n", \E_USER_WARNING);
42 }
43 return $result;
44 });
45 }
46 }
47