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 / ArnParser.php
transferito / vendor / aws / aws-sdk-php / src / Arn Last commit date
Exception 11 months ago S3 11 months ago AccessPointArn.php 11 months ago AccessPointArnInterface.php 11 months ago Arn.php 11 months ago ArnInterface.php 11 months ago ArnParser.php 11 months ago ObjectLambdaAccessPointArn.php 11 months ago ResourceTypeAndIdTrait.php 11 months ago
ArnParser.php
70 lines
1 <?php
2 namespace Aws\Arn;
3
4 use Aws\Arn\S3\AccessPointArn as S3AccessPointArn;
5 use Aws\Arn\ObjectLambdaAccessPointArn;
6 use Aws\Arn\S3\MultiRegionAccessPointArn;
7 use Aws\Arn\S3\OutpostsBucketArn;
8 use Aws\Arn\S3\RegionalBucketArn;
9 use Aws\Arn\S3\OutpostsAccessPointArn;
10
11 /**
12 * This class provides functionality to parse ARN strings and return a
13 * corresponding ARN object. ARN-parsing logic may be subject to change in the
14 * future, so this should not be relied upon for external customer usage.
15 *
16 * @internal
17 */
18 class ArnParser
19 {
20 /**
21 * @param $string
22 * @return bool
23 */
24 public static function isArn($string)
25 {
26 return $string !== null && strpos($string, 'arn:') === 0;
27 }
28
29 /**
30 * Parses a string and returns an instance of ArnInterface. Returns a
31 * specific type of Arn object if it has a specific class representation
32 * or a generic Arn object if not.
33 *
34 * @param $string
35 * @return ArnInterface
36 */
37 public static function parse($string)
38 {
39 $data = Arn::parse($string);
40 if ($data['service'] === 's3-object-lambda') {
41 return new ObjectLambdaAccessPointArn($string);
42 }
43 $resource = self::explodeResourceComponent($data['resource']);
44 if ($resource[0] === 'outpost') {
45 if (isset($resource[2]) && $resource[2] === 'bucket') {
46 return new OutpostsBucketArn($string);
47 }
48 if (isset($resource[2]) && $resource[2] === 'accesspoint') {
49 return new OutpostsAccessPointArn($string);
50 }
51 }
52 if (empty($data['region'])) {
53 return new MultiRegionAccessPointArn($string);
54 }
55 if ($resource[0] === 'accesspoint') {
56 if ($data['service'] === 's3') {
57 return new S3AccessPointArn($string);
58 }
59 return new AccessPointArn($string);
60 }
61
62 return new Arn($data);
63 }
64
65 private static function explodeResourceComponent($resource)
66 {
67 return preg_split("/[\/:]/", $resource);
68 }
69 }
70