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 / Crypto / CryptoParamsTrait.php

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

52 lines 2.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\Crypto;
4
5 use Dudlewebs\WPMCS\s3\Aws\Crypto\MaterialsProvider;
6 use Dudlewebs\WPMCS\s3\Aws\Crypto\MetadataEnvelope;
7 use Dudlewebs\WPMCS\s3\Aws\Crypto\MetadataStrategyInterface;
8 trait CryptoParamsTrait
9 {
10 protected function getMaterialsProvider(array $args)
11 {
12 if ($args['@MaterialsProvider'] instanceof MaterialsProvider) {
13 return $args['@MaterialsProvider'];
14 }
15 throw new \InvalidArgumentException('An instance of MaterialsProvider' . ' must be passed in the "MaterialsProvider" field.');
16 }
17 protected function getInstructionFileSuffix(array $args)
18 {
19 return !empty($args['@InstructionFileSuffix']) ? $args['@InstructionFileSuffix'] : $this->instructionFileSuffix;
20 }
21 protected function determineGetObjectStrategy($result, $instructionFileSuffix)
22 {
23 if (isset($result['Metadata'][MetadataEnvelope::CONTENT_KEY_V2_HEADER])) {
24 return new HeadersMetadataStrategy();
25 }
26 return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
27 }
28 protected function getMetadataStrategy(array $args, $instructionFileSuffix)
29 {
30 if (!empty($args['@MetadataStrategy'])) {
31 if ($args['@MetadataStrategy'] instanceof MetadataStrategyInterface) {
32 return $args['@MetadataStrategy'];
33 }
34 if (\is_string($args['@MetadataStrategy'])) {
35 switch ($args['@MetadataStrategy']) {
36 case HeadersMetadataStrategy::class:
37 return new HeadersMetadataStrategy();
38 case InstructionFileMetadataStrategy::class:
39 return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
40 default:
41 throw new \InvalidArgumentException('Could not match the' . ' specified string in "MetadataStrategy" to a' . ' predefined strategy.');
42 }
43 } else {
44 throw new \InvalidArgumentException('The metadata strategy that' . ' was passed to "MetadataStrategy" was unrecognized.');
45 }
46 } elseif ($instructionFileSuffix) {
47 return new InstructionFileMetadataStrategy($this->client, $instructionFileSuffix);
48 }
49 return null;
50 }
51 }
52