Completed
Pull Request — master (#6)
by
unknown
05:44
created
examples/simple.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 $stream = new S3BucketStreamZip(
13 13
             // $auth
14 14
             array(
15
-              'key'     => '*********',   // required
15
+              'key'     => '*********', // required
16 16
               'secret'  => '*********'    // required
17 17
             ),
18 18
             // $params
19 19
             array(
20
-              'Bucket'  => 'bucketname',  // required
20
+              'Bucket'  => 'bucketname', // required
21 21
               'Prefix'  => 'subfolder/'   // optional (path to folder to stream)
22 22
             )
23 23
           );
Please login to merge, or discard this patch.
src/S3BucketStreamZip.php 2 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -59,16 +59,19 @@  discard block
 block discarded – undo
59 59
   public function __construct($auth, $params)
60 60
   {
61 61
     // We require the AWS key to be passed in $auth.
62
-    if(!isset($auth['key']))
63
-      throw new InvalidParameterException('$auth parameter to constructor requires a `key` attribute');
62
+    if(!isset($auth['key'])) {
63
+          throw new InvalidParameterException('$auth parameter to constructor requires a `key` attribute');
64
+    }
64 65
 
65 66
     // We require the AWS secret to be passed in $auth.
66
-    if(!isset($auth['secret']))
67
-      throw new InvalidParameterException('$auth parameter to constructor requires a `secret` attribute');
67
+    if(!isset($auth['secret'])) {
68
+          throw new InvalidParameterException('$auth parameter to constructor requires a `secret` attribute');
69
+    }
68 70
 
69 71
     // We require the AWS S3 bucket to be passed in $params.
70
-    if(!isset($params['Bucket']))
71
-      throw new InvalidParameterException('$params parameter to constructor requires a `Bucket` attribute (with a capital B)');
72
+    if(!isset($params['Bucket'])) {
73
+          throw new InvalidParameterException('$params parameter to constructor requires a `Bucket` attribute (with a capital B)');
74
+    }
72 75
 
73 76
     $this->auth   = $auth;
74 77
     $this->params = $params;
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
   public function send($filename, $params = array())
89 92
   {
90 93
     // Set default values for the optional $params argument
91
-    if(!isset($params['expiration']))
92
-      $params['expiration'] = '+10 minutes';
94
+    if(!isset($params['expiration'])) {
95
+          $params['expiration'] = '+10 minutes';
96
+    }
93 97
 
94 98
     // Initialize the ZipStream object and pass in the file name which
95 99
     //  will be what is sent in the content-disposition header.
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
    *   secret: your_aws_secret
30 30
    * }
31 31
    */
32
-  private $auth   = array();
32
+  private $auth = array();
33 33
 
34 34
   /**
35 35
    * @var array
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
   public function __construct($auth, $params)
60 60
   {
61 61
     // We require the AWS key to be passed in $auth.
62
-    if(!isset($auth['key']))
62
+    if (!isset($auth['key']))
63 63
       throw new InvalidParameterException('$auth parameter to constructor requires a `key` attribute');
64 64
 
65 65
     // We require the AWS secret to be passed in $auth.
66
-    if(!isset($auth['secret']))
66
+    if (!isset($auth['secret']))
67 67
       throw new InvalidParameterException('$auth parameter to constructor requires a `secret` attribute');
68 68
 
69 69
     // We require the AWS S3 bucket to be passed in $params.
70
-    if(!isset($params['Bucket']))
70
+    if (!isset($params['Bucket']))
71 71
       throw new InvalidParameterException('$params parameter to constructor requires a `Bucket` attribute (with a capital B)');
72 72
 
73 73
     $this->auth   = $auth;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
   public function send($filename, $params = array())
89 89
   {
90 90
     // Set default values for the optional $params argument
91
-    if(!isset($params['expiration']))
91
+    if (!isset($params['expiration']))
92 92
       $params['expiration'] = '+10 minutes';
93 93
 
94 94
     // Initialize the ZipStream object and pass in the file name which
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     $result = $this->s3Client->getIterator('ListObjects', $this->params);
103 103
 
104 104
     // We loop over each object from the ListObjects call.
105
-    foreach($result as $file)
105
+    foreach ($result as $file)
106 106
     {
107 107
       // We need to use a command to get a request for the S3 object
108 108
       //  and then we can get the presigned URL.
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
       curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
132 132
       curl_exec($ch);
133 133
       curl_close($ch);
134
-      fseek($fp,0);
134
+      fseek($fp, 0);
135 135
       $zip->addFileFromStream($fileName, $fp);
136 136
       fclose($fp);
137 137
     }
Please login to merge, or discard this patch.