mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-30 19:40:33 -07:00
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
41 lines
927 B
PHP
41 lines
927 B
PHP
<?php
|
|
namespace Aws\Arn;
|
|
|
|
use Aws\Arn\S3\AccessPointArn as S3AccessPointArn;
|
|
use Aws\Arn\S3\BucketArn;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class ArnParser
|
|
{
|
|
/**
|
|
* @param $string
|
|
* @return bool
|
|
*/
|
|
public static function isArn($string)
|
|
{
|
|
return strpos($string, 'arn:') === 0;
|
|
}
|
|
|
|
/**
|
|
* Parses a string and returns an instance of ArnInterface. Returns a
|
|
* specific type of Arn object if it has a specific class representation
|
|
* or a generic Arn object if not.
|
|
*
|
|
* @param $string
|
|
* @return ArnInterface
|
|
*/
|
|
public static function parse($string)
|
|
{
|
|
$data = Arn::parse($string);
|
|
if (substr($data['resource'], 0, 11) === 'accesspoint') {
|
|
if ($data['service'] === 's3') {
|
|
return new S3AccessPointArn($string);
|
|
}
|
|
return new AccessPointArn($string);
|
|
}
|
|
|
|
return new Arn($data);
|
|
}
|
|
}
|