forked from ThePhalcons/AmazonWebServicesBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmazonWebServicesFactory.php
75 lines (69 loc) · 2.03 KB
/
AmazonWebServicesFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @package AmazonWebServicesBundle
* @author Mark Badolato <mbadolato@cybernox.com>
* @copyright Copyright (c) CyberNox Technologies. All rights reserved.
* @license http://www.opensource.org/licenses/BSD-2-Clause BSD License
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cybernox\AmazonWebServicesBundle;
/**
* AmazonWebServicesBundle Factory providing requested AWS objects
*/
class AmazonWebServicesFactory
{
/**
* @var array $validServiceTypes The names of the Amazon Web Services that may be used
*/
private $validServiceTypes = array(
'AS',
'CloudFormation',
'CloudFront',
'CloudSearch',
'CloudWatch',
'DynamoDB',
'EC2',
'ELB',
'EMR',
'ElastiCache',
'ElasticBeanstalk',
'IAM',
'ImportExport',
'RDS',
'S3',
'SDB',
'SES',
'SNS',
'SQS',
'STS',
'SWF',
);
/**
* Get an Amazon Web Service object
*
* @param AmazonWebServices $aws An AmazonWebServices Service instance
* @param string $serviceType The requested Amazon Web Service type
* @return mixed The requested Amazon Web Service Object
* @throws \RuntimeException
*/
public function get(AmazonWebServices $aws, $serviceType)
{
if (! $this->isValidServiceType($serviceType)) {
throw new \RuntimeException(sprintf('Invalid Amazon Web Service Type requested [%s]', $serviceType));
}
$serviceObject = 'Amazon' . $serviceType;
return new $serviceObject($aws->getParameters());
}
/**
* Determine if a requested Amazon Web Service is valid or not
*
* @param $type string The requested Amazon Web Service type
* @return bool
*/
private function isValidServiceType($type)
{
return (in_array($type, $this->validServiceTypes) ? true : false);
}
}