PluginProbe ʕ •ᴥ•ʔ
Transferito: WP Migration / trunk
Transferito: WP Migration vtrunk
trunk 11.4.0 12.0.0 13.1.0 14.0.0 14.0.11 14.0.7 14.1.0 14.1.1 14.1.2 14.1.3 14.1.4
transferito / vendor / aws / aws-sdk-php / src / S3 / Crypto / CryptoParamsTrait.php
transferito / vendor / aws / aws-sdk-php / src / S3 / Crypto Last commit date
CryptoParamsTrait.php 11 months ago CryptoParamsTraitV2.php 11 months ago HeadersMetadataStrategy.php 11 months ago InstructionFileMetadataStrategy.php 11 months ago S3EncryptionClient.php 11 months ago S3EncryptionClientV2.php 11 months ago S3EncryptionMultipartUploader.php 11 months ago S3EncryptionMultipartUploaderV2.php 11 months ago UserAgentTrait.php 11 months ago
CryptoParamsTrait.php
76 lines
1 <?php
2 namespace Aws\S3\Crypto;
3
4 use Aws\Crypto\MaterialsProvider;
5 use Aws\Crypto\MetadataEnvelope;
6 use Aws\Crypto\MetadataStrategyInterface;
7
8 trait CryptoParamsTrait
9 {
10 protected function getMaterialsProvider(array $args)
11 {
12 if ($args['@MaterialsProvider'] instanceof MaterialsProvider) {
13 return $args['@MaterialsProvider'];
14 }
15
16 throw new \InvalidArgumentException('An instance of MaterialsProvider'
17 . ' must be passed in the "MaterialsProvider" field.');
18 }
19
20 protected function getInstructionFileSuffix(array $args)
21 {
22 return !empty($args['@InstructionFileSuffix'])
23 ? $args['@InstructionFileSuffix']
24 : $this->instructionFileSuffix;
25 }
26
27 protected function determineGetObjectStrategy(
28 $result,
29 $instructionFileSuffix
30 ) {
31 if (isset($result['Metadata'][MetadataEnvelope::CONTENT_KEY_V2_HEADER])) {
32 return new HeadersMetadataStrategy();
33 }
34
35 return new InstructionFileMetadataStrategy(
36 $this->client,
37 $instructionFileSuffix
38 );
39 }
40
41 protected function getMetadataStrategy(array $args, $instructionFileSuffix)
42 {
43 if (!empty($args['@MetadataStrategy'])) {
44 if ($args['@MetadataStrategy'] instanceof MetadataStrategyInterface) {
45 return $args['@MetadataStrategy'];
46 }
47
48 if (is_string($args['@MetadataStrategy'])) {
49 switch ($args['@MetadataStrategy']) {
50 case HeadersMetadataStrategy::class:
51 return new HeadersMetadataStrategy();
52 case InstructionFileMetadataStrategy::class:
53 return new InstructionFileMetadataStrategy(
54 $this->client,
55 $instructionFileSuffix
56 );
57 default:
58 throw new \InvalidArgumentException('Could not match the'
59 . ' specified string in "MetadataStrategy" to a'
60 . ' predefined strategy.');
61 }
62 } else {
63 throw new \InvalidArgumentException('The metadata strategy that'
64 . ' was passed to "MetadataStrategy" was unrecognized.');
65 }
66 } elseif ($instructionFileSuffix) {
67 return new InstructionFileMetadataStrategy(
68 $this->client,
69 $instructionFileSuffix
70 );
71 }
72
73 return null;
74 }
75 }
76