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 / Arn / S3 / OutpostsBucketArn.php
transferito / vendor / aws / aws-sdk-php / src / Arn / S3 Last commit date
AccessPointArn.php 11 months ago BucketArnInterface.php 11 months ago MultiRegionAccessPointArn.php 11 months ago OutpostsAccessPointArn.php 11 months ago OutpostsArnInterface.php 11 months ago OutpostsBucketArn.php 11 months ago
OutpostsBucketArn.php
100 lines
1 <?php
2 namespace Aws\Arn\S3;
3
4 use Aws\Arn\Arn;
5 use Aws\Arn\Exception\InvalidArnException;
6 use Aws\Arn\ResourceTypeAndIdTrait;
7
8 /**
9 * This class represents an S3 Outposts bucket ARN, which is in the
10 * following format:
11 *
12 * @internal
13 */
14 class OutpostsBucketArn extends Arn implements
15 BucketArnInterface,
16 OutpostsArnInterface
17 {
18 use ResourceTypeAndIdTrait;
19
20 /**
21 * Parses a string into an associative array of components that represent
22 * a OutpostsBucketArn
23 *
24 * @param $string
25 * @return array
26 */
27 public static function parse($string)
28 {
29 $data = parent::parse($string);
30 $data = self::parseResourceTypeAndId($data);
31 return self::parseOutpostData($data);
32 }
33
34 public function getBucketName()
35 {
36 return $this->data['bucket_name'];
37 }
38
39 public function getOutpostId()
40 {
41 return $this->data['outpost_id'];
42 }
43
44 private static function parseOutpostData(array $data)
45 {
46 $resourceData = preg_split("/[\/:]/", $data['resource_id'], 3);
47
48 $data['outpost_id'] = isset($resourceData[0])
49 ? $resourceData[0]
50 : null;
51 $data['bucket_label'] = isset($resourceData[1])
52 ? $resourceData[1]
53 : null;
54 $data['bucket_name'] = isset($resourceData[2])
55 ? $resourceData[2]
56 : null;
57
58 return $data;
59 }
60
61 /**
62 *
63 * @param array $data
64 */
65 public static function validate(array $data)
66 {
67 Arn::validate($data);
68
69 if (($data['service'] !== 's3-outposts')) {
70 throw new InvalidArnException("The 3rd component of an S3 Outposts"
71 . " bucket ARN represents the service and must be 's3-outposts'.");
72 }
73
74 self::validateRegion($data, 'S3 Outposts bucket ARN');
75 self::validateAccountId($data, 'S3 Outposts bucket ARN');
76
77 if (($data['resource_type'] !== 'outpost')) {
78 throw new InvalidArnException("The 6th component of an S3 Outposts"
79 . " bucket ARN represents the resource type and must be"
80 . " 'outpost'.");
81 }
82
83 if (!self::isValidHostLabel($data['outpost_id'])) {
84 throw new InvalidArnException("The 7th component of an S3 Outposts"
85 . " bucket ARN is required, represents the outpost ID, and"
86 . " must be a valid host label.");
87 }
88
89 if ($data['bucket_label'] !== 'bucket') {
90 throw new InvalidArnException("The 8th component of an S3 Outposts"
91 . " bucket ARN must be 'bucket'");
92 }
93
94 if (empty($data['bucket_name'])) {
95 throw new InvalidArnException("The 9th component of an S3 Outposts"
96 . " bucket ARN represents the bucket name and must not be empty.");
97 }
98 }
99 }
100