Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/S3/Crypto/HeadersMetadataStrategy.php

raw symbols SCIP
1 <?php
2 namespace Aws\S3\Crypto;
3
4 use \Aws\Crypto\MetadataStrategyInterface;
5 use \Aws\Crypto\MetadataEnvelope;
6
7 class HeadersMetadataStrategy implements MetadataStrategyInterface
8 {
9 /**
10 * Places the information in the MetadataEnvelope in to the metadata for
11 * the PutObject request of the encrypted object.
12 *
13 * @param MetadataEnvelope $envelope Encryption data to save according to
14 * the strategy.
15 * @param array $args Arguments for PutObject that can be manipulated to
16 * store strategy related information.
17 *
18 * @return array Updated arguments for PutObject.
19 */
20 public function save(MetadataEnvelope $envelope, array $args)
21 {
22 foreach ($envelope as $header=>$value) {
23 $args['Metadata'][$header] = $value;
24 }
25
26 return $args;
27 }
28
29 /**
30 * Generates a MetadataEnvelope according to the metadata headers from the
31 * GetObject result.
32 *
33 * @param array $args Arguments from Command and Result that contains
34 * S3 Object information, relevant headers, and command
35 * configuration.
36 *
37 * @return MetadataEnvelope
38 */
39 public function load(array $args)
40 {
41 $envelope = new MetadataEnvelope();
42 $constantValues = MetadataEnvelope::getConstantValues();
43
44 foreach ($constantValues as $constant) {
45 if (!empty($args['Metadata'][$constant])) {
46 $envelope[$constant] = $args['Metadata'][$constant];
47 }
48 }
49
50 return $envelope;
51 }
52 }