# media-cloud-sync/1.4.2/includes/sdk/s3/Aws/EndpointV2/EndpointV2SerializerTrait.php

Media Cloud Sync, version 1.4.2. 60 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/EndpointV2/EndpointV2SerializerTrait.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/raw/includes/sdk/s3/Aws/EndpointV2/EndpointV2SerializerTrait.php
- Modified: 2025-08-17T07:06:28+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.4.2/code/includes/sdk/s3/Aws/EndpointV2/EndpointV2SerializerTrait.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\EndpointV2;

use Dudlewebs\WPMCS\s3\Aws\Api\Serializer\RestSerializer;
use Dudlewebs\WPMCS\s3\Aws\EndpointV2\Ruleset\RulesetEndpoint;
use Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7\Uri;
/**
 * Set of helper functions used to set endpoints and endpoint
 * properties derived from dynamic endpoint resolution.
 *
 * @internal
 */
trait EndpointV2SerializerTrait
{
    /**
     * Applies a resolved endpoint, headers and any custom HTTP schemes provided
     * in client configuration to options which are applied to the serialized request.
     *
     * @param $endpoint
     * @param $headers
     *
     * @return void
     */
    private function setEndpointV2RequestOptions(RulesetEndpoint $endpoint, array &$headers) : void
    {
        $this->applyHeaders($endpoint, $headers);
        $resolvedUrl = $endpoint->getUrl();
        $this->applyScheme($resolvedUrl);
        $this->endpoint = $this instanceof RestSerializer ? new Uri($resolvedUrl) : $resolvedUrl;
    }
    /**
     * Combines modeled headers and headers resolved from an endpoint object.
     *
     * @param $endpoint
     * @param $headers
     * @return void
     */
    private function applyHeaders(RulesetEndpoint $endpoint, array &$headers) : void
    {
        if (!\is_null($endpoint->getHeaders())) {
            $headers = \array_merge($headers, $endpoint->getHeaders());
        }
    }
    /**
     * Applies custom HTTP schemes provided in client configuration.
     *
     * @param $resolvedUrl
     * @return void
     */
    private function applyScheme(&$resolvedUrl) : void
    {
        $resolvedEndpointScheme = \parse_url($resolvedUrl, \PHP_URL_SCHEME);
        $scheme = $this->endpoint instanceof Uri ? $this->endpoint->getScheme() : \parse_url($this->endpoint, \PHP_URL_SCHEME);
        if (!empty($scheme) && $scheme !== $resolvedEndpointScheme) {
            $resolvedUrl = \str_replace($resolvedEndpointScheme, $scheme, $resolvedUrl);
        }
    }
}

```
