# media-cloud-sync/1.0.0/includes/sdk/s3/Aws/S3/Crypto/CryptoParamsTrait.php

Media Cloud Sync, version 1.0.0. 52 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.0.0/code/includes/sdk/s3/Aws/S3/Crypto/CryptoParamsTrait.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.0.0/raw/includes/sdk/s3/Aws/S3/Crypto/CryptoParamsTrait.php
- Modified: 2024-10-27T10:40:38+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.0.0/code/includes/sdk/s3/Aws/S3/Crypto/CryptoParamsTrait.php#L10-L20`.

```php
<?php

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

use Dudlewebs\WPMCS\s3\Aws\Crypto\MaterialsProvider;
use Dudlewebs\WPMCS\s3\Aws\Crypto\MetadataEnvelope;
use Dudlewebs\WPMCS\s3\Aws\Crypto\MetadataStrategyInterface;
trait CryptoParamsTrait
{
    protected function getMaterialsProvider(array $args)
    {
        if ($args['@MaterialsProvider'] instanceof MaterialsProvider) {
            return $args['@MaterialsProvider'];
        }
        throw new \InvalidArgumentException('An instance of MaterialsProvider' . ' must be passed in the "MaterialsProvider" field.');
    }
    protected function getInstructionFileSuffix(array $args)
    {
        return !empty($args['@InstructionFileSuffix']) ? $args['@InstructionFileSuffix'] : $this->instructionFileSuffix;
    }
    protected function determineGetObjectStrategy($result, $instructionFileSuffix)
    {
        if (isset($result['Metadata'][MetadataEnvelope::CONTENT_KEY_V2_HEADER])) {
            return new HeadersMetadataStrategy();
        }
        return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
    }
    protected function getMetadataStrategy(array $args, $instructionFileSuffix)
    {
        if (!empty($args['@MetadataStrategy'])) {
            if ($args['@MetadataStrategy'] instanceof MetadataStrategyInterface) {
                return $args['@MetadataStrategy'];
            }
            if (\is_string($args['@MetadataStrategy'])) {
                switch ($args['@MetadataStrategy']) {
                    case HeadersMetadataStrategy::class:
                        return new HeadersMetadataStrategy();
                    case InstructionFileMetadataStrategy::class:
                        return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
                    default:
                        throw new \InvalidArgumentException('Could not match the' . ' specified string in "MetadataStrategy" to a' . ' predefined strategy.');
                }
            } else {
                throw new \InvalidArgumentException('The metadata strategy that' . ' was passed to "MetadataStrategy" was unrecognized.');
            }
        } elseif ($instructionFileSuffix) {
            return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
        }
        return null;
    }
}

```
