-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathamazon.php
67 lines (60 loc) · 1.56 KB
/
amazon.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
<?php
namespace Library;
use \Aws\Common\Aws;
use \Aws\Common\Enum\Region;
use \Guzzle\Service\Builder\ServiceBuilder;
/**
* Wrapper for Amazon Web Services library
*
* @author Aleksey Korzun <[email protected]>
*/
class Amazon
{
/**
* Stores instance of Amazon service builder
*
* @var ServiceBuilder
*/
protected static $instance;
/**
* Class constructor
*
* @param string $key access key
* @param string $secret secret key
* @param string $region optional service region
*/
public function __construct($key, $secret, $region = null)
{
// Amazon Phar library is required at this point
require('amazon/library.phar');
// Construct configuration array
$configuration = array(
'key' => (string)$key,
'secret' => (string)$secret,
'region' => (string)$region
);
// Set region if it's missing
if (!isset($region)) {
$configuration['region'] = Region::US_EAST_1;
}
self::$instance = Aws::factory($configuration);
}
/**
* Pass all method calls directly to instance of Amazon service builder
*
* @param string $name method that was invoked
* @param mixed[] $arguments arguments that were passed to invoked method
*
* @return mixed
*/
public function __call($name, $arguments)
{
return call_user_func_array(
array(
self::$instance,
$name
),
$arguments
);
}
}