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 / Parser / GetBucketLocationResultMutator.php

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

35 lines 1.1 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\Parser;
4
5 use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
6 use Dudlewebs\WPMCS\s3\Aws\ResultInterface;
7 use Dudlewebs\WPMCS\s3\Psr\Http\Message\ResponseInterface;
8 /**
9 * A custom mutator for a GetBucketLocation request, which
10 * extract the bucket location value and injects it into the
11 * result as the `LocationConstraint` field.
12 *
13 * @internal
14 */
15 final class GetBucketLocationResultMutator implements S3ResultMutator
16 {
17 /**
18 * @inheritDoc
19 */
20 public function __invoke(ResultInterface $result, CommandInterface $command, ResponseInterface $response) : ResultInterface
21 {
22 if ($command->getName() !== 'GetBucketLocation') {
23 return $result;
24 }
25 $location = 'us-east-1';
26 static $pattern = '/>(.+?)<\\/LocationConstraint>/';
27 if (\preg_match($pattern, $response->getBody(), $matches)) {
28 $location = $matches[1] === 'EU' ? 'eu-west-1' : $matches[1];
29 }
30 $result['LocationConstraint'] = $location;
31 $response->getBody()->rewind();
32 return $result;
33 }
34 }
35