Completed
Branch master (3b2036)
by Andrew
04:31
created
src/AwsHelper/AwsHelper.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -81,6 +81,9 @@
 block discarded – undo
81 81
         return $opts;
82 82
     }
83 83
 
84
+    /**
85
+     * @param string $iam_url
86
+     */
84 87
     private function getAccessData($iam_role, $iam_url)
85 88
     {
86 89
         /* grab the access and secret key from the iam role "aws-opsworks-ec2-role" */
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     private $iam_role;
11 11
     private $iam_url;
12 12
 
13
-    public function __construct($iam_role, $iam_url='http://169.254.169.254/latest/meta-data/iam/security-credentials/')
13
+    public function __construct($iam_role, $iam_url = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/')
14 14
     {
15 15
 
16 16
         if (empty($iam_role))
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         return $this->json;
42 42
     }
43 43
 
44
-    public function getDefaultOptions($aws_key=null, $aws_secret=null)
44
+    public function getDefaultOptions($aws_key = null, $aws_secret = null)
45 45
     {
46 46
         $opts = [
47 47
             'key'    => $aws_key,
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     public function hasAccessExpired($date)
104 104
     {
105 105
         $date = new \DateTime($date);
106
-        if ($date->format('U')-date('U') > 0)
106
+        if ($date->format('U') - date('U') > 0)
107 107
             return false;
108 108
 
109 109
         return true;
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,25 +13,30 @@  discard block
 block discarded – undo
13 13
     public function __construct($iam_role, $iam_url='http://169.254.169.254/latest/meta-data/iam/security-credentials/')
14 14
     {
15 15
 
16
-        if (empty($iam_role))
17
-            throw new \Exception('iam_role is empty');
16
+        if (empty($iam_role)) {
17
+                    throw new \Exception('iam_role is empty');
18
+        }
18 19
 
19
-        if (empty($iam_url))
20
-            throw new \Exception('iam_url is empty');
20
+        if (empty($iam_url)) {
21
+                    throw new \Exception('iam_url is empty');
22
+        }
21 23
 
22 24
         $this->iam_role = $iam_role;
23 25
         $this->iam_url  = $iam_url;
24 26
 
25 27
         $json = $this->getAccessData($iam_role, $iam_url);
26 28
 
27
-        if ($json->Code !== 'Success')
28
-            throw new \Exception('Unsuccessful in returning iam amazon credentials');
29
+        if ($json->Code !== 'Success') {
30
+                    throw new \Exception('Unsuccessful in returning iam amazon credentials');
31
+        }
29 32
 
30
-        if (empty($json->AccessKeyId))
31
-            throw new \Exception('AccessKeyId does not exist.');
33
+        if (empty($json->AccessKeyId)) {
34
+                    throw new \Exception('AccessKeyId does not exist.');
35
+        }
32 36
 
33
-        if (empty($json->SecretAccessKey))
34
-            throw new \Exception('SecretAccessKey does not exist.');
37
+        if (empty($json->SecretAccessKey)) {
38
+                    throw new \Exception('SecretAccessKey does not exist.');
39
+        }
35 40
 
36 41
         $this->json = $json;
37 42
     }
@@ -52,14 +57,17 @@  discard block
 block discarded – undo
52 57
         {
53 58
             $json = $this->getJSON();
54 59
 
55
-            if ($json->Code !== 'Success')
56
-                throw new \Exception('Unsuccessful in returning iam amazon credentials');
60
+            if ($json->Code !== 'Success') {
61
+                            throw new \Exception('Unsuccessful in returning iam amazon credentials');
62
+            }
57 63
 
58
-            if (empty($json->AccessKeyId))
59
-                throw new \Exception('AccessKeyId does not exist. This is possibly a problem with you aws setup.');
64
+            if (empty($json->AccessKeyId)) {
65
+                            throw new \Exception('AccessKeyId does not exist. This is possibly a problem with you aws setup.');
66
+            }
60 67
 
61
-            if (empty($json->SecretAccessKey))
62
-                throw new \Exception('SecretAccessKey does not exist. This is possibly a problem with you aws setup.');
68
+            if (empty($json->SecretAccessKey)) {
69
+                            throw new \Exception('SecretAccessKey does not exist. This is possibly a problem with you aws setup.');
70
+            }
63 71
 
64 72
             if (!empty($json->Token))
65 73
             {
@@ -103,8 +111,9 @@  discard block
 block discarded – undo
103 111
     public function hasAccessExpired($date)
104 112
     {
105 113
         $date = new \DateTime($date);
106
-        if ($date->format('U')-date('U') > 0)
107
-            return false;
114
+        if ($date->format('U')-date('U') > 0) {
115
+                    return false;
116
+        }
108 117
 
109 118
         return true;
110 119
     }
Please login to merge, or discard this patch.
src/AwsHelper/S3Helper.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace AwsHelper;
2 2
 
3 3
 use Aws\S3\S3Client;
4
-use Aws\S3\Exception\S3Exception;
5 4
 
6 5
 class S3Helper
7 6
 {
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,9 @@  discard block
 block discarded – undo
45 45
     */
46 46
     public function saveFile($file_location, $s3_location, $acl = 'private', $params = [])
47 47
     {
48
-        if ($this->s3 == null)
49
-            return false;
48
+        if ($this->s3 == null) {
49
+                    return false;
50
+        }
50 51
 
51 52
         $this->getClient();
52 53
 
@@ -72,8 +73,9 @@  discard block
 block discarded – undo
72 73
     */
73 74
     public function saveFileContent($file_content, $s3_location, $acl = 'private', $params = [])
74 75
     {
75
-        if ($this->s3 == null)
76
-            return false;
76
+        if ($this->s3 == null) {
77
+                    return false;
78
+        }
77 79
 
78 80
         $this->getClient();
79 81
 
@@ -96,8 +98,9 @@  discard block
 block discarded – undo
96 98
     */
97 99
     public function getFile($s3_location)
98 100
     {
99
-        if ($this->s3 == null)
100
-            return false;
101
+        if ($this->s3 == null) {
102
+                    return false;
103
+        }
101 104
 
102 105
         $this->getClient();
103 106
 
@@ -106,8 +109,7 @@  discard block
 block discarded – undo
106 109
                 'Bucket' => $this->bucket_name,
107 110
                 'Key'    => $s3_location,
108 111
             ]);
109
-        }
110
-        catch (\Exception $e)
112
+        } catch (\Exception $e)
111 113
         {
112 114
             return false;
113 115
         }
Please login to merge, or discard this patch.
src/AwsHelper/SqsHelper.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
     /**
97 97
      * Get a list of queue attributes
98
-     * @param  array $attributes An array of queue attribute names
98
+     * @param  string[] $attributes An array of queue attribute names
99 99
      * @return array             An array of specified queue attributes with keys as attribute names
100 100
      */
101 101
     public function getQueueAttributes($attributes)
@@ -135,6 +135,9 @@  discard block
 block discarded – undo
135 135
         return $this->data;
136 136
     }
137 137
 
138
+    /**
139
+     * @param string $key
140
+     */
138 141
     public function get($key)
139 142
     {
140 143
         return $this->data[$key];
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php namespace AwsHelper;
2 2
 
3 3
 use Aws\Sqs\SqsClient;
4
-use Aws\S3\Exception\S3Exception;
5 4
 
6 5
 class SqsHelper
7 6
 {
Please login to merge, or discard this patch.