Completed
Pull Request — master (#15)
by
unknown
18:16 queued 06:23
created
lib/Mongo/MongoGridFSFile.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -126,6 +126,9 @@
 block discarded – undo
126 126
         );
127 127
     }
128 128
 
129
+    /**
130
+     * @param resource $handle
131
+     */
129 132
     private function writeFromRessource($handle)
130 133
     {
131 134
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
     private function writeFromRessource($handle)
130 130
     {
131 131
 
132
-        if (! $handle) {
132
+        if ( ! $handle) {
133 133
             trigger_error(E_ERROR, 'can not open the destination file');
134 134
         }
135 135
         $written = 0;
Please login to merge, or discard this patch.
lib/Mongo/MongoGridFS.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function find(array $query = array(), array $fields = array())
93 93
     {
94
-        $cursor = new MongoGridFSCursor($this, $this->db->getConnection(), (string)$this, $query, $fields);
94
+        $cursor = new MongoGridFSCursor($this, $this->db->getConnection(), (string) $this, $query, $fields);
95 95
         $cursor->setReadPreference($this->getReadPreference());
96 96
 
97 97
         return $cursor;
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
             $shortName = basename($filename);
113 113
             $filename = fopen($filename, 'r');
114 114
         }
115
-        if (! is_resource($filename)) {
115
+        if ( ! is_resource($filename)) {
116 116
             throw new \InvalidArgumentException();
117 117
         }
118 118
         $length = fstat($filename)['size'];
119
-        $extra['chunkSize'] = isset($extra['chunkSize']) ? $extra['chunkSize']: self::DEFAULT_CHUNK_SIZE;
119
+        $extra['chunkSize'] = isset($extra['chunkSize']) ? $extra['chunkSize'] : self::DEFAULT_CHUNK_SIZE;
120 120
         $extra['_id'] = isset($extra['_id']) ?: new MongoId();
121 121
         $extra['length'] = $length;
122 122
         $extra['md5'] = isset($md5) ? $md5 : $this->calculateMD5($filename, $length);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     public function findOne(array $query = array(), array $fields = array())
217 217
     {
218 218
         $file = parent::findOne($query, $fields);
219
-        if (! $file) {
219
+        if ( ! $file) {
220 220
             return;
221 221
         }
222 222
         return new MongoGridFSFile($this, $file);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         if (is_string($id)) {
253 253
             $id = new MongoId($id);
254 254
         }
255
-        if (! $id instanceof MongoId) {
255
+        if ( ! $id instanceof MongoId) {
256 256
             return false;
257 257
         }
258 258
         $this->chunks->remove(['file_id' => $id], ['justOne' => false]);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public function storeUpload($name, array $metadata = [])
270 270
     {
271
-        if (! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) {
271
+        if ( ! isset($_FILES[$name]) || $_FILES[$name]['error'] !== UPLOAD_ERR_OK) {
272 272
             throw new \InvalidArgumentException();
273 273
         }
274 274
         $metadata += ['filename' => $_FILES[$name]['name']];
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         if (is_string($id)) {
287 287
             $id = new MongoId($id);
288 288
         }
289
-        if (! $id instanceof MongoId) {
289
+        if ( ! $id instanceof MongoId) {
290 290
             return false;
291 291
         }
292 292
         return $this->findOne(['_id' => $id]);
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @link http://php.net/manual/en/mongogridfs.construct.php
54 54
      * @param MongoDB $db Database
55 55
      * @param string $prefix [optional] <p>Optional collection name prefix.</p>
56
-     * @param mixed $chunks  [optional]
56
+     * @param string $chunks  [optional]
57 57
      * @return MongoGridFS
58 58
      */
59 59
     public function __construct(MongoDB $db, $prefix = "fs", $chunks = null)
@@ -280,6 +280,9 @@  discard block
 block discarded – undo
280 280
         $this->createIndex(['filename' => 1, 'uploadDate' => 1]);
281 281
     }
282 282
 
283
+    /**
284
+     * @param resource $file
285
+     */
283 286
     private function insertChunksFromFile($file, $fileInfo)
284 287
     {
285 288
         $length = $fileInfo['length'];
@@ -295,6 +298,9 @@  discard block
 block discarded – undo
295 298
         }
296 299
     }
297 300
 
301
+    /**
302
+     * @param resource $file
303
+     */
298 304
     private function calculateMD5($file)
299 305
     {
300 306
         // XXX: this could be really a bad idea with big files...
@@ -303,6 +309,9 @@  discard block
 block discarded – undo
303 309
         return md5($data);
304 310
     }
305 311
 
312
+    /**
313
+     * @param string $bytes
314
+     */
306 315
     private function insertChunksFromBytes($bytes, $fileInfo)
307 316
     {
308 317
         $length = $fileInfo['length'];
@@ -316,6 +325,9 @@  discard block
 block discarded – undo
316 325
         }
317 326
     }
318 327
 
328
+    /**
329
+     * @param integer $chunkNumber
330
+     */
319 331
     private function insertChunk($id, $data, $chunkNumber)
320 332
     {
321 333
         $chunk = [
Please login to merge, or discard this patch.