# media-cloud-sync/1.2.13/includes/sdk/s3/Aws/S3/Parser/GetBucketLocationResultMutator.php

Media Cloud Sync, version 1.2.13. 35 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.2.13/code/includes/sdk/s3/Aws/S3/Parser/GetBucketLocationResultMutator.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.2.13/raw/includes/sdk/s3/Aws/S3/Parser/GetBucketLocationResultMutator.php
- Modified: 2025-08-17T07:09:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.2.13/code/includes/sdk/s3/Aws/S3/Parser/GetBucketLocationResultMutator.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\S3\Parser;

use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
use Dudlewebs\WPMCS\s3\Aws\ResultInterface;
use Dudlewebs\WPMCS\s3\Psr\Http\Message\ResponseInterface;
/**
 * A custom mutator for a GetBucketLocation request, which
 * extract the bucket location value and injects it into the
 * result as the `LocationConstraint` field.
 *
 * @internal
 */
final class GetBucketLocationResultMutator implements S3ResultMutator
{
    /**
     * @inheritDoc
     */
    public function __invoke(ResultInterface $result, CommandInterface $command, ResponseInterface $response) : ResultInterface
    {
        if ($command->getName() !== 'GetBucketLocation') {
            return $result;
        }
        static $location = 'us-east-1';
        static $pattern = '/>(.+?)<\\/LocationConstraint>/';
        if (\preg_match($pattern, $response->getBody(), $matches)) {
            $location = $matches[1] === 'EU' ? 'eu-west-1' : $matches[1];
        }
        $result['LocationConstraint'] = $location;
        $response->getBody()->rewind();
        return $result;
    }
}

```
