| 1 |
<?php |
| 2 |
namespace Aws\Arn; |
| 3 |
|
| 4 |
use Aws\Arn\Exception\InvalidArnException; |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class AccessPointArn extends Arn implements AccessPointArnInterface |
| 10 |
{ |
| 11 |
use ResourceTypeAndIdTrait; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public function __construct($data) |
| 19 |
{ |
| 20 |
parent::__construct($data); |
| 21 |
static::validate($this->data); |
| 22 |
} |
| 23 |
|
| 24 |
public static function parse($string) |
| 25 |
{ |
| 26 |
$data = parent::parse($string); |
| 27 |
$data = self::parseResourceTypeAndId($data); |
| 28 |
$data['accesspoint_name'] = $data['resource_id']; |
| 29 |
return $data; |
| 30 |
} |
| 31 |
|
| 32 |
public function getAccesspointName() |
| 33 |
{ |
| 34 |
return $this->data['accesspoint_name']; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
protected static function validate(array $data) |
| 43 |
{ |
| 44 |
self::validateRegion($data, 'access point ARN'); |
| 45 |
self::validateAccountId($data, 'access point ARN'); |
| 46 |
|
| 47 |
if ($data['resource_type'] !== 'accesspoint') { |
| 48 |
throw new InvalidArnException("The 6th component of an access point ARN" |
| 49 |
. " represents the resource type and must be 'accesspoint'."); |
| 50 |
} |
| 51 |
|
| 52 |
if (empty($data['resource_id'])) { |
| 53 |
throw new InvalidArnException("The 7th component of an access point ARN" |
| 54 |
. " represents the resource ID and must not be empty."); |
| 55 |
} |
| 56 |
if (strpos($data['resource_id'], ':') !== false) { |
| 57 |
throw new InvalidArnException("The resource ID component of an access" |
| 58 |
. " point ARN must not contain additional components" |
| 59 |
. " (delimited by ':')."); |
| 60 |
} |
| 61 |
if (!self::isValidHostLabel($data['resource_id'])) { |
| 62 |
throw new InvalidArnException("The resource ID in an access point ARN" |
| 63 |
. " must be a valid host label value."); |
| 64 |
} |
| 65 |
} |
| 66 |
} |