PluginProbe
Media Cloud Sync / 1.2.8
Media Cloud Sync v1.2.8
1.4.2 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 All 36 releases
media-cloud-sync / includes / sdk / s3 / Aws / Arn / S3 / OutpostsAccessPointArn.php

OutpostsAccessPointArn.php in Media Cloud Sync 1.2.8, at includes/sdk/s3/Aws/Arn/S3/OutpostsAccessPointArn.php

78 lines 3.4 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\Arn\S3;
4
5 use Dudlewebs\WPMCS\s3\Aws\Arn\AccessPointArn as BaseAccessPointArn;
6 use Dudlewebs\WPMCS\s3\Aws\Arn\AccessPointArnInterface;
7 use Dudlewebs\WPMCS\s3\Aws\Arn\Arn;
8 use Dudlewebs\WPMCS\s3\Aws\Arn\Exception\InvalidArnException;
9 /**
10 * This class represents an S3 Outposts access point ARN, which is in the
11 * following format:
12 *
13 * arn:{partition}:s3-outposts:{region}:{accountId}:outpost:{outpostId}:accesspoint:{accesspointName}
14 *
15 * ':' and '/' can be used interchangeably as delimiters for components after
16 * the account ID.
17 *
18 * @internal
19 */
20 class OutpostsAccessPointArn extends BaseAccessPointArn implements AccessPointArnInterface, OutpostsArnInterface
21 {
22 public static function parse($string)
23 {
24 $data = parent::parse($string);
25 return self::parseOutpostData($data);
26 }
27 public function getOutpostId()
28 {
29 return $this->data['outpost_id'];
30 }
31 public function getAccesspointName()
32 {
33 return $this->data['accesspoint_name'];
34 }
35 private static function parseOutpostData(array $data)
36 {
37 $resourceData = \preg_split("/[\\/:]/", $data['resource_id']);
38 $data['outpost_id'] = isset($resourceData[0]) ? $resourceData[0] : null;
39 $data['accesspoint_type'] = isset($resourceData[1]) ? $resourceData[1] : null;
40 $data['accesspoint_name'] = isset($resourceData[2]) ? $resourceData[2] : null;
41 if (isset($resourceData[3])) {
42 $data['resource_extra'] = \implode(':', \array_slice($resourceData, 3));
43 }
44 return $data;
45 }
46 /**
47 * Validation specific to OutpostsAccessPointArn. Note this uses the base Arn
48 * class validation instead of the direct parent due to it having slightly
49 * differing requirements from its parent.
50 *
51 * @param array $data
52 */
53 public static function validate(array $data)
54 {
55 Arn::validate($data);
56 if ($data['service'] !== 's3-outposts') {
57 throw new InvalidArnException("The 3rd component of an S3 Outposts" . " access point ARN represents the service and must be" . " 's3-outposts'.");
58 }
59 self::validateRegion($data, 'S3 Outposts access point ARN');
60 self::validateAccountId($data, 'S3 Outposts access point ARN');
61 if ($data['resource_type'] !== 'outpost') {
62 throw new InvalidArnException("The 6th component of an S3 Outposts" . " access point ARN represents the resource type and must be" . " 'outpost'.");
63 }
64 if (!self::isValidHostLabel($data['outpost_id'])) {
65 throw new InvalidArnException("The 7th component of an S3 Outposts" . " access point ARN is required, represents the outpost ID, and" . " must be a valid host label.");
66 }
67 if ($data['accesspoint_type'] !== 'accesspoint') {
68 throw new InvalidArnException("The 8th component of an S3 Outposts" . " access point ARN must be 'accesspoint'");
69 }
70 if (!self::isValidHostLabel($data['accesspoint_name'])) {
71 throw new InvalidArnException("The 9th component of an S3 Outposts" . " access point ARN is required, represents the accesspoint name," . " and must be a valid host label.");
72 }
73 if (!empty($data['resource_extra'])) {
74 throw new InvalidArnException("An S3 Outposts access point ARN" . " should only have 9 components, delimited by the characters" . " ':' and '/'. '{$data['resource_extra']}' was found after the" . " 9th component.");
75 }
76 }
77 }
78