@@ -121,14 +121,14 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function aggregate(array $pipeline, array $op = []) |
| 123 | 123 | { |
| 124 | - if (! TypeConverter::isNumericArray($pipeline)) { |
|
| 124 | + if (!TypeConverter::isNumericArray($pipeline)) { |
|
| 125 | 125 | $pipeline = []; |
| 126 | 126 | $options = []; |
| 127 | 127 | |
| 128 | 128 | $i = 0; |
| 129 | 129 | foreach (func_get_args() as $operator) { |
| 130 | 130 | $i++; |
| 131 | - if (! is_array($operator)) { |
|
| 131 | + if (!is_array($operator)) { |
|
| 132 | 132 | trigger_error("Argument $i is not an array", E_WARNING); |
| 133 | 133 | return; |
| 134 | 134 | } |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | ]; |
| 165 | 165 | |
| 166 | 166 | // Convert cursor option |
| 167 | - if (! isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) { |
|
| 167 | + if (!isset($options['cursor']) || $options['cursor'] === true || $options['cursor'] === []) { |
|
| 168 | 168 | // Cursor option needs to be an object convert bools and empty arrays since those won't be handled by TypeConverter |
| 169 | 169 | $options['cursor'] = new \stdClass; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $command += $options; |
| 173 | 173 | |
| 174 | - $cursor = new MongoCommandCursor($this->db->getConnection(), (string)$this, $command); |
|
| 174 | + $cursor = new MongoCommandCursor($this->db->getConnection(), (string) $this, $command); |
|
| 175 | 175 | $cursor->setReadPreference($this->getReadPreference()); |
| 176 | 176 | |
| 177 | 177 | return $cursor; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @throws MongoCursorException |
| 322 | 322 | * @return boolean |
| 323 | 323 | */ |
| 324 | - public function update(array $criteria , array $newobj, array $options = array()) |
|
| 324 | + public function update(array $criteria, array $newobj, array $options = array()) |
|
| 325 | 325 | { |
| 326 | 326 | $multiple = ($options['multiple']) ? $options['multiple'] : false; |
| 327 | 327 | // $multiple = $options['multiple'] ?? false; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | public function find(array $query = array(), array $fields = array()) |
| 391 | 391 | { |
| 392 | - $cursor = new MongoCursor($this->db->getConnection(), (string)$this, $query, $fields); |
|
| 392 | + $cursor = new MongoCursor($this->db->getConnection(), (string) $this, $query, $fields); |
|
| 393 | 393 | $cursor->setReadPreference($this->getReadPreference()); |
| 394 | 394 | |
| 395 | 395 | return $cursor; |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | public function save($a, array $options = array()) |
| 566 | 566 | { |
| 567 | 567 | if (is_object($a)) { |
| 568 | - $a = (array)$a; |
|
| 568 | + $a = (array) $a; |
|
| 569 | 569 | } |
| 570 | - if ( ! array_key_exists('_id', $a)) { |
|
| 570 | + if (!array_key_exists('_id', $a)) { |
|
| 571 | 571 | $id = new \MongoId(); |
| 572 | 572 | } else { |
| 573 | 573 | $id = $a['_id']; |
@@ -629,20 +629,20 @@ discard block |
||
| 629 | 629 | if (is_string($reduce)) { |
| 630 | 630 | $reduce = new MongoCode($reduce); |
| 631 | 631 | } |
| 632 | - if ( ! $reduce instanceof MongoCode) { |
|
| 632 | + if (!$reduce instanceof MongoCode) { |
|
| 633 | 633 | throw new \InvalidArgumentExcption('reduce parameter should be a string or MongoCode instance.'); |
| 634 | 634 | } |
| 635 | 635 | $command = [ |
| 636 | 636 | 'group' => [ |
| 637 | 637 | 'ns' => $this->name, |
| 638 | - '$reduce' => (string)$reduce, |
|
| 638 | + '$reduce' => (string) $reduce, |
|
| 639 | 639 | 'initial' => $initial, |
| 640 | 640 | 'cond' => $condition, |
| 641 | 641 | ], |
| 642 | 642 | ]; |
| 643 | 643 | |
| 644 | 644 | if ($keys instanceof MongoCode) { |
| 645 | - $command['group']['$keyf'] = (string)$keys; |
|
| 645 | + $command['group']['$keyf'] = (string) $keys; |
|
| 646 | 646 | } else { |
| 647 | 647 | $command['group']['key'] = $keys; |
| 648 | 648 | } |
@@ -651,14 +651,14 @@ discard block |
||
| 651 | 651 | } |
| 652 | 652 | if (array_key_exists('finalize', $condition)) { |
| 653 | 653 | if ($condition['finalize'] instanceof MongoCode) { |
| 654 | - $condition['finalize'] = (string)$condition['finalize']; |
|
| 654 | + $condition['finalize'] = (string) $condition['finalize']; |
|
| 655 | 655 | } |
| 656 | 656 | $command['group']['finalize'] = $condition['finalize']; |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | $result = $this->db->command($command, [], $hash); |
| 660 | 660 | unset($result['waitedMS']); |
| 661 | - $result['ok'] = (int)$result['ok']; |
|
| 661 | + $result['ok'] = (int) $result['ok']; |
|
| 662 | 662 | if (count($result['retval'])) { |
| 663 | 663 | $result['retval'] = current($result['retval']); |
| 664 | 664 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $collections = $this->db->listCollections($options); |
| 131 | 131 | |
| 132 | - $getCollectionName = function (CollectionInfo $collectionInfo) { |
|
| 132 | + $getCollectionName = function(CollectionInfo $collectionInfo) { |
|
| 133 | 133 | return $collectionInfo->getName(); |
| 134 | 134 | }; |
| 135 | 135 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $id = isset($document_or_id->_id) ? $document_or_id->_id : null; |
| 316 | 316 | // $id = $document_or_id->_id ?? null; |
| 317 | 317 | } elseif (is_array($document_or_id)) { |
| 318 | - if (! isset($document_or_id['_id'])) { |
|
| 318 | + if (!isset($document_or_id['_id'])) { |
|
| 319 | 319 | return null; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -91,7 +91,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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]); |