Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e481661

Browse files
committedSep 5, 2017
Style fixes
1 parent 7a85d92 commit e481661

33 files changed

+236
-172
lines changed
 

‎src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Auth;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Auth;
24

35
use DateTime;
46
use DateTimeZone;

‎src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Auth;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Auth;
24

35
use Illuminate\Auth\Passwords\PasswordResetServiceProvider as BasePasswordResetServiceProvider;
46

‎src/Jenssegers/Mongodb/Auth/User.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<?php namespace Jenssegers\Mongodb\Auth;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Auth;
24

35
use Illuminate\Auth\Authenticatable;
4-
use Jenssegers\Mongodb\Eloquent\Model as Model;
56
use Illuminate\Auth\Passwords\CanResetPassword;
6-
use Illuminate\Foundation\Auth\Access\Authorizable;
7-
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
87
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
8+
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
99
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
10+
use Illuminate\Foundation\Auth\Access\Authorizable;
11+
use Jenssegers\Mongodb\Eloquent\Model as Model;
1012

1113
class User extends Model implements
1214
AuthenticatableContract,

‎src/Jenssegers/Mongodb/Collection.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb;
24

35
use Exception;
46
use MongoDB\BSON\ObjectID;
@@ -21,7 +23,7 @@ class Collection
2123
protected $collection;
2224

2325
/**
24-
* @param Connection $connection
26+
* @param Connection $connection
2527
* @param MongoCollection $collection
2628
*/
2729
public function __construct(Connection $connection, MongoCollection $collection)
@@ -34,7 +36,7 @@ public function __construct(Connection $connection, MongoCollection $collection)
3436
* Handle dynamic method calls.
3537
*
3638
* @param string $method
37-
* @param array $parameters
39+
* @param array $parameters
3840
* @return mixed
3941
*/
4042
public function __call($method, $parameters)
@@ -53,7 +55,7 @@ public function __call($method, $parameters)
5355
// Convert the query parameters to a json string.
5456
array_walk_recursive($parameters, function (&$item, $key) {
5557
if ($item instanceof ObjectID) {
56-
$item = (string) $item;
58+
$item = (string)$item;
5759
}
5860
});
5961

@@ -66,7 +68,7 @@ public function __call($method, $parameters)
6668
}
6769
}
6870

69-
$queryString = $this->collection->getCollectionName().'.'.$method.'('.implode(',', $query).')';
71+
$queryString = $this->collection->getCollectionName() . '.' . $method . '(' . implode(',', $query) . ')';
7072

7173
$this->connection->logQuery($queryString, [], $time);
7274
}

‎src/Jenssegers/Mongodb/Connection.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb;
24

35
use Illuminate\Database\Connection as BaseConnection;
46
use MongoDB\Client;
@@ -114,8 +116,8 @@ public function getMongoClient()
114116
* Create a new MongoDB connection.
115117
*
116118
* @param string $dsn
117-
* @param array $config
118-
* @param array $options
119+
* @param array $config
120+
* @param array $options
119121
* @return \MongoDB\Client
120122
*/
121123
protected function createConnection($dsn, array $config, array $options)
@@ -128,10 +130,10 @@ protected function createConnection($dsn, array $config, array $options)
128130
}
129131

130132
// Check if the credentials are not already set in the options
131-
if (! isset($options['username']) && ! empty($config['username'])) {
133+
if (!isset($options['username']) && !empty($config['username'])) {
132134
$options['username'] = $config['username'];
133135
}
134-
if (! isset($options['password']) && ! empty($config['password'])) {
136+
if (!isset($options['password']) && !empty($config['password'])) {
135137
$options['password'] = $config['password'];
136138
}
137139

@@ -155,7 +157,7 @@ public function disconnect()
155157
protected function getDsn(array $config)
156158
{
157159
// Check if the user passed a complete dsn to the configuration.
158-
if (! empty($config['dsn'])) {
160+
if (!empty($config['dsn'])) {
159161
return $config['dsn'];
160162
}
161163

@@ -164,15 +166,15 @@ protected function getDsn(array $config)
164166

165167
foreach ($hosts as &$host) {
166168
// Check if we need to add a port to the host
167-
if (strpos($host, ':') === false && ! empty($config['port'])) {
168-
$host = $host.':'.$config['port'];
169+
if (strpos($host, ':') === false && !empty($config['port'])) {
170+
$host = $host . ':' . $config['port'];
169171
}
170172
}
171173

172174
// Check if we want to authenticate against a specific database.
173-
$auth_database = isset($config['options']) && ! empty($config['options']['database']) ? $config['options']['database'] : null;
175+
$auth_database = isset($config['options']) && !empty($config['options']['database']) ? $config['options']['database'] : null;
174176

175-
return 'mongodb://'.implode(',', $hosts).($auth_database ? '/'.$auth_database : '');
177+
return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : '');
176178
}
177179

178180
/**
@@ -219,7 +221,7 @@ protected function getDefaultSchemaGrammar()
219221
* Dynamically pass methods to the connection.
220222
*
221223
* @param string $method
222-
* @param array $parameters
224+
* @param array $parameters
223225
* @return mixed
224226
*/
225227
public function __call($method, $parameters)

‎src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Eloquent;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Eloquent;
24

35
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
46
use Jenssegers\Mongodb\Helpers\QueriesRelationships;
@@ -8,6 +10,7 @@
810
class Builder extends EloquentBuilder
911
{
1012
use QueriesRelationships;
13+
1114
/**
1215
* The methods that should be returned from query builder.
1316
*
@@ -157,10 +160,10 @@ public function raw($expression = null)
157160
elseif ($results instanceof BSONDocument) {
158161
$results = $results->getArrayCopy();
159162

160-
return $this->model->newFromBuilder((array) $results);
163+
return $this->model->newFromBuilder((array)$results);
161164
} // The result is a single object.
162165
elseif (is_array($results) and array_key_exists('_id', $results)) {
163-
return $this->model->newFromBuilder((array) $results);
166+
return $this->model->newFromBuilder((array)$results);
164167
}
165168

166169
return $results;

‎src/Jenssegers/Mongodb/Eloquent/EmbedsRelations.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Eloquent;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Eloquent;
24

35
use Jenssegers\Mongodb\Relations\EmbedsMany;
46
use Jenssegers\Mongodb\Relations\EmbedsOne;

‎src/Jenssegers/Mongodb/Eloquent/HybridRelations.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Eloquent;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Eloquent;
24

35
use Illuminate\Database\Eloquent\Relations\MorphMany;
46
use Illuminate\Database\Eloquent\Relations\MorphOne;
@@ -23,7 +25,7 @@ trait HybridRelations
2325
public function hasOne($related, $foreignKey = null, $localKey = null)
2426
{
2527
// Check if it is a relation with an original model.
26-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
28+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
2729
return parent::hasOne($related, $foreignKey, $localKey);
2830
}
2931

@@ -49,7 +51,7 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
4951
public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
5052
{
5153
// Check if it is a relation with an original model.
52-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
54+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
5355
return parent::morphOne($related, $name, $type, $id, $localKey);
5456
}
5557

@@ -73,7 +75,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
7375
public function hasMany($related, $foreignKey = null, $localKey = null)
7476
{
7577
// Check if it is a relation with an original model.
76-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
78+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
7779
return parent::hasMany($related, $foreignKey, $localKey);
7880
}
7981

@@ -99,7 +101,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
99101
public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
100102
{
101103
// Check if it is a relation with an original model.
102-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
104+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
103105
return parent::morphMany($related, $name, $type, $id, $localKey);
104106
}
105107

@@ -138,15 +140,15 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
138140
}
139141

140142
// Check if it is a relation with an original model.
141-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
143+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
142144
return parent::belongsTo($related, $foreignKey, $otherKey, $relation);
143145
}
144146

145147
// If no foreign key was supplied, we can use a backtrace to guess the proper
146148
// foreign key name by using the name of the relationship function, which
147149
// when combined with an "_id" should conventionally match the columns.
148150
if (is_null($foreignKey)) {
149-
$foreignKey = Str::snake($relation).'_id';
151+
$foreignKey = Str::snake($relation) . '_id';
150152
}
151153

152154
$instance = new $related;
@@ -225,18 +227,18 @@ public function belongsToMany($related, $collection = null, $foreignKey = null,
225227
}
226228

227229
// Check if it is a relation with an original model.
228-
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
230+
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
229231
return parent::belongsToMany($related, $collection, $foreignKey, $otherKey, $relation);
230232
}
231233

232234
// First, we'll need to determine the foreign key and "other key" for the
233235
// relationship. Once we have determined the keys we'll make the query
234236
// instances as well as the relationship instances we need for this.
235-
$foreignKey = $foreignKey ?: $this->getForeignKey().'s';
237+
$foreignKey = $foreignKey ?: $this->getForeignKey() . 's';
236238

237239
$instance = new $related;
238240

239-
$otherKey = $otherKey ?: $instance->getForeignKey().'s';
241+
$otherKey = $otherKey ?: $instance->getForeignKey() . 's';
240242

241243
// If no table name was provided, we can guess it by concatenating the two
242244
// models using underscores in alphabetical order. The two model names

‎src/Jenssegers/Mongodb/Eloquent/Model.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Eloquent;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Eloquent;
24

35
use Carbon\Carbon;
46
use DateTime;
@@ -44,13 +46,13 @@ public function getIdAttribute($value = null)
4446
{
4547
// If we don't have a value for 'id', we will use the Mongo '_id' value.
4648
// This allows us to work with models in a more sql-like way.
47-
if (! $value and array_key_exists('_id', $this->attributes)) {
49+
if (!$value and array_key_exists('_id', $this->attributes)) {
4850
$value = $this->attributes['_id'];
4951
}
5052

5153
// Convert ObjectID to string.
5254
if ($value instanceof ObjectID) {
53-
return (string) $value;
55+
return (string)$value;
5456
}
5557

5658
return $value;
@@ -75,7 +77,7 @@ public function fromDateTime($value)
7577
}
7678

7779
// Let Eloquent convert the value to a DateTime instance.
78-
if (! $value instanceof DateTime) {
80+
if (!$value instanceof DateTime) {
7981
$value = parent::asDateTime($value);
8082
}
8183

@@ -124,7 +126,7 @@ public function getTable()
124126
*/
125127
public function getAttribute($key)
126128
{
127-
if (! $key) {
129+
if (!$key) {
128130
return;
129131
}
130132

@@ -134,7 +136,7 @@ public function getAttribute($key)
134136
}
135137

136138
// This checks for embedded relation support.
137-
if (method_exists($this, $key) and ! method_exists(self::class, $key)) {
139+
if (method_exists($this, $key) and !method_exists(self::class, $key)) {
138140
return $this->getRelationValue($key);
139141
}
140142

@@ -191,14 +193,14 @@ public function attributesToArray()
191193
// nicely when your models are converted to JSON.
192194
foreach ($attributes as $key => &$value) {
193195
if ($value instanceof ObjectID) {
194-
$value = (string) $value;
196+
$value = (string)$value;
195197
}
196198
}
197199

198200
// Convert dot-notation dates.
199201
foreach ($this->getDates() as $key) {
200202
if (str_contains($key, '.') and array_has($attributes, $key)) {
201-
array_set($attributes, $key, (string) $this->asDateTime(array_get($attributes, $key)));
203+
array_set($attributes, $key, (string)$this->asDateTime(array_get($attributes, $key)));
202204
}
203205
}
204206

@@ -240,7 +242,7 @@ protected function originalIsNumericallyEquivalent($key)
240242
*/
241243
public function drop($columns)
242244
{
243-
if (! is_array($columns)) {
245+
if (!is_array($columns)) {
244246
$columns = [$columns];
245247
}
246248

@@ -268,7 +270,7 @@ public function push()
268270
}
269271

270272
// Do batch push by default.
271-
if (! is_array($values)) {
273+
if (!is_array($values)) {
272274
$values = [$values];
273275
}
274276

@@ -286,13 +288,13 @@ public function push()
286288
* Remove one or more values from an array.
287289
*
288290
* @param string $column
289-
* @param mixed $values
291+
* @param mixed $values
290292
* @return mixed
291293
*/
292294
public function pull($column, $values)
293295
{
294296
// Do batch pull by default.
295-
if (! is_array($values)) {
297+
if (!is_array($values)) {
296298
$values = [$values];
297299
}
298300

@@ -307,8 +309,8 @@ public function pull($column, $values)
307309
* Append one or more values to the underlying attribute value and sync with original.
308310
*
309311
* @param string $column
310-
* @param array $values
311-
* @param bool $unique
312+
* @param array $values
313+
* @param bool $unique
312314
*/
313315
protected function pushAttributeValues($column, array $values, $unique = false)
314316
{
@@ -332,7 +334,7 @@ protected function pushAttributeValues($column, array $values, $unique = false)
332334
* Remove one or more values to the underlying attribute value and sync with original.
333335
*
334336
* @param string $column
335-
* @param array $values
337+
* @param array $values
336338
*/
337339
protected function pullAttributeValues($column, array $values)
338340
{
@@ -356,7 +358,7 @@ protected function pullAttributeValues($column, array $values)
356358
*/
357359
public function getForeignKey()
358360
{
359-
return Str::snake(class_basename($this)).'_'.ltrim($this->primaryKey, '_');
361+
return Str::snake(class_basename($this)) . '_' . ltrim($this->primaryKey, '_');
360362
}
361363

362364
/**

‎src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Eloquent;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Eloquent;
24

35
trait SoftDeletes
46
{

‎src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function addHybridHas($relation, $operator = '>=', $count = 1, $boolean =
8686
$not = in_array($operator, ['<', '<=', '!=']);
8787
// If we are comparing to 0, we need an additional $not flip.
8888
if ($count == 0) {
89-
$not = ! $not;
89+
$not = !$not;
9090
}
9191

9292
$relations = $hasQuery->pluck($this->getHasCompareKey($relation));
@@ -112,7 +112,7 @@ protected function getRelatedConstraintKey($relation)
112112
return $relation->getForeignKey();
113113
}
114114

115-
throw new \Exception(class_basename($relation).' Is Not supported for hybrid query constraints!');
115+
throw new \Exception(class_basename($relation) . ' Is Not supported for hybrid query constraints!');
116116
}
117117

118118
/**
@@ -137,7 +137,7 @@ protected function getHasCompareKey($relation)
137137
protected function getConstrainedRelatedIds($relations, $operator, $count)
138138
{
139139
$relationCount = array_count_values(array_map(function ($id) {
140-
return (string) $id; // Convert Back ObjectIds to Strings
140+
return (string)$id; // Convert Back ObjectIds to Strings
141141
}, is_array($relations) ? $relations : $relations->flatten()->toArray()));
142142
// Remove unwanted related objects based on the operator and count.
143143
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {

‎src/Jenssegers/Mongodb/MongodbQueueServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb;
24

35
use Illuminate\Queue\QueueServiceProvider;
46
use Jenssegers\Mongodb\Queue\Failed\MongoFailedJobProvider;

‎src/Jenssegers/Mongodb/MongodbServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb;
24

35
use Illuminate\Support\ServiceProvider;
46
use Jenssegers\Mongodb\Eloquent\Model;

‎src/Jenssegers/Mongodb/Query/Builder.php

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Query;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Query;
24

35
use Closure;
46
use DateTime;
@@ -237,18 +239,18 @@ public function getFresh($columns = [])
237239
// Add grouping columns to the $group part of the aggregation pipeline.
238240
if ($this->groups) {
239241
foreach ($this->groups as $column) {
240-
$group['_id'][$column] = '$'.$column;
242+
$group['_id'][$column] = '$' . $column;
241243

242244
// When grouping, also add the $last operator to each grouped field,
243245
// this mimics MySQL's behaviour a bit.
244-
$group[$column] = ['$last' => '$'.$column];
246+
$group[$column] = ['$last' => '$' . $column];
245247
}
246248

247249
// Do the same for other columns that are selected.
248250
foreach ($this->columns as $column) {
249251
$key = str_replace('.', '_', $column);
250252

251-
$group[$key] = ['$last' => '$'.$column];
253+
$group[$key] = ['$last' => '$' . $column];
252254
}
253255
}
254256

@@ -270,7 +272,7 @@ public function getFresh($columns = [])
270272
$group['aggregate'] = ['$sum' => 1];
271273
} // Pass other functions directly.
272274
else {
273-
$group['aggregate'] = ['$'.$function => '$'.$column];
275+
$group['aggregate'] = ['$' . $function => '$' . $column];
274276
}
275277
}
276278
}
@@ -296,7 +298,7 @@ public function getFresh($columns = [])
296298

297299
// apply unwinds for subdocument array aggregation
298300
foreach ($unwinds as $unwind) {
299-
$pipeline[] = ['$unwind' => '$'.$unwind];
301+
$pipeline[] = ['$unwind' => '$' . $unwind];
300302
}
301303

302304
if ($group) {
@@ -422,28 +424,28 @@ public function generateCacheKey()
422424
public function aggregate($function, $columns = [])
423425
{
424426
$this->aggregate = compact('function', 'columns');
425-
427+
426428
$previousColumns = $this->columns;
427-
429+
428430
// We will also back up the select bindings since the select clause will be
429431
// removed when performing the aggregate function. Once the query is run
430432
// we will add the bindings back onto this query so they can get used.
431433
$previousSelectBindings = $this->bindings['select'];
432-
434+
433435
$this->bindings['select'] = [];
434-
436+
435437
$results = $this->get($columns);
436-
438+
437439
// Once we have executed the query, we will reset the aggregate property so
438440
// that more select queries can be executed against the database without
439441
// the aggregate value getting in the way when the grammar builds it.
440442
$this->aggregate = null;
441443
$this->columns = $previousColumns;
442444
$this->bindings['select'] = $previousSelectBindings;
443-
445+
444446
if (isset($results[0])) {
445-
$result = (array) $results[0];
446-
447+
$result = (array)$results[0];
448+
447449
return $result['aggregate'];
448450
}
449451
}
@@ -453,7 +455,7 @@ public function aggregate($function, $columns = [])
453455
*/
454456
public function exists()
455457
{
456-
return ! is_null($this->first());
458+
return !is_null($this->first());
457459
}
458460

459461
/**
@@ -522,20 +524,20 @@ public function insert(array $values)
522524
foreach ($values as $value) {
523525
// As soon as we find a value that is not an array we assume the user is
524526
// inserting a single document.
525-
if (! is_array($value)) {
527+
if (!is_array($value)) {
526528
$batch = false;
527529
break;
528530
}
529531
}
530532

531-
if (! $batch) {
533+
if (!$batch) {
532534
$values = [$values];
533535
}
534536

535537
// Batch insert
536538
$result = $this->collection->insertMany($values);
537539

538-
return (1 == (int) $result->isAcknowledged());
540+
return (1 == (int)$result->isAcknowledged());
539541
}
540542

541543
/**
@@ -545,7 +547,7 @@ public function insertGetId(array $values, $sequence = null)
545547
{
546548
$result = $this->collection->insertOne($values);
547549

548-
if (1 == (int) $result->isAcknowledged()) {
550+
if (1 == (int)$result->isAcknowledged()) {
549551
if (is_null($sequence)) {
550552
$sequence = '_id';
551553
}
@@ -561,7 +563,7 @@ public function insertGetId(array $values, $sequence = null)
561563
public function update(array $values, array $options = [])
562564
{
563565
// Use $set as default operator.
564-
if (! starts_with(key($values), '$')) {
566+
if (!starts_with(key($values), '$')) {
565567
$values = ['$set' => $values];
566568
}
567569

@@ -575,7 +577,7 @@ public function increment($column, $amount = 1, array $extra = [], array $option
575577
{
576578
$query = ['$inc' => [$column => $amount]];
577579

578-
if (! empty($extra)) {
580+
if (!empty($extra)) {
579581
$query['$set'] = $extra;
580582
}
581583

@@ -607,7 +609,7 @@ public function pluck($column, $key = null)
607609
// Convert ObjectID's to strings
608610
if ($key == '_id') {
609611
$results = $results->map(function ($item) {
610-
$item['_id'] = (string) $item['_id'];
612+
$item['_id'] = (string)$item['_id'];
611613
return $item;
612614
});
613615
}
@@ -624,13 +626,13 @@ public function delete($id = null)
624626
// If an ID is passed to the method, we will set the where clause to check
625627
// the ID to allow developers to simply and quickly remove a single row
626628
// from their database without manually specifying the where clauses.
627-
if (! is_null($id)) {
629+
if (!is_null($id)) {
628630
$this->where('_id', '=', $id);
629631
}
630632

631633
$wheres = $this->compileWheres();
632634
$result = $this->collection->DeleteMany($wheres);
633-
if (1 == (int) $result->isAcknowledged()) {
635+
if (1 == (int)$result->isAcknowledged()) {
634636
return $result->getDeletedCount();
635637
}
636638

@@ -656,7 +658,7 @@ public function truncate()
656658
{
657659
$result = $this->collection->drop();
658660

659-
return (1 == (int) $result->ok);
661+
return (1 == (int)$result->ok);
660662
}
661663

662664
/**
@@ -681,7 +683,7 @@ public function raw($expression = null)
681683
if ($expression instanceof Closure) {
682684
return call_user_func($expression, $this->collection);
683685
} // Create an expression for the given value
684-
elseif (! is_null($expression)) {
686+
elseif (!is_null($expression)) {
685687
return new Expression($expression);
686688
}
687689

@@ -694,7 +696,7 @@ public function raw($expression = null)
694696
*
695697
* @param mixed $column
696698
* @param mixed $value
697-
* @param bool $unique
699+
* @param bool $unique
698700
* @return int
699701
*/
700702
public function push($column, $value = null, $unique = false)
@@ -748,7 +750,7 @@ public function pull($column, $value = null)
748750
*/
749751
public function drop($columns)
750752
{
751-
if (! is_array($columns)) {
753+
if (!is_array($columns)) {
752754
$columns = [$columns];
753755
}
754756

@@ -781,13 +783,13 @@ public function newQuery()
781783
protected function performUpdate($query, array $options = [])
782784
{
783785
// Update multiple items by default.
784-
if (! array_key_exists('multiple', $options)) {
786+
if (!array_key_exists('multiple', $options)) {
785787
$options['multiple'] = true;
786788
}
787789

788790
$wheres = $this->compileWheres();
789791
$result = $this->collection->UpdateMany($wheres, $query, $options);
790-
if (1 == (int) $result->isAcknowledged()) {
792+
if (1 == (int)$result->isAcknowledged()) {
791793
return $result->getModifiedCount() ? $result->getModifiedCount() : $result->getUpsertedCount();
792794
}
793795

@@ -936,18 +938,18 @@ protected function compileWhereBasic(array $where)
936938
$regex = preg_replace('#(^|[^\\\])%#', '$1.*', preg_quote($value));
937939

938940
// Convert like to regular expression.
939-
if (! starts_with($value, '%')) {
940-
$regex = '^'.$regex;
941+
if (!starts_with($value, '%')) {
942+
$regex = '^' . $regex;
941943
}
942-
if (! ends_with($value, '%')) {
943-
$regex = $regex.'$';
944+
if (!ends_with($value, '%')) {
945+
$regex = $regex . '$';
944946
}
945947

946948
$value = new Regex($regex, 'i');
947949
} // Manipulate regexp operations.
948950
elseif (in_array($operator, ['regexp', 'not regexp', 'regex', 'not regex'])) {
949951
// Automatically convert regular expression strings to Regex objects.
950-
if (! $value instanceof Regex) {
952+
if (!$value instanceof Regex) {
951953
$e = explode('/', $value);
952954
$flag = end($e);
953955
$regstr = substr($value, 1, -(strlen($flag) + 1));
@@ -961,12 +963,12 @@ protected function compileWhereBasic(array $where)
961963
}
962964
}
963965

964-
if (! isset($operator) or $operator == '=') {
966+
if (!isset($operator) or $operator == '=') {
965967
$query = [$column => $value];
966968
} elseif (array_key_exists($operator, $this->conversion)) {
967969
$query = [$column => [$this->conversion[$operator] => $value]];
968970
} else {
969-
$query = [$column => ['$'.$operator => $value]];
971+
$query = [$column => ['$' . $operator => $value]];
970972
}
971973

972974
return $query;

‎src/Jenssegers/Mongodb/Query/Grammar.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Query;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Query;
24

35
use Illuminate\Database\Query\Grammars\Grammar as BaseGrammar;
46

‎src/Jenssegers/Mongodb/Query/Processor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Query;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Query;
24

35
use Illuminate\Database\Query\Processors\Processor as BaseProcessor;
46

‎src/Jenssegers/Mongodb/Queue/Failed/MongoFailedJobProvider.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Queue\Failed;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Queue\Failed;
24

35
use Carbon\Carbon;
46
use Illuminate\Queue\Failed\DatabaseFailedJobProvider;
@@ -31,7 +33,7 @@ public function all()
3133
$all = $this->getTable()->orderBy('_id', 'desc')->get()->all();
3234

3335
$all = array_map(function ($job) {
34-
$job['id'] = (string) $job['_id'];
36+
$job['id'] = (string)$job['_id'];
3537
return $job;
3638
}, $all);
3739

@@ -41,22 +43,22 @@ public function all()
4143
/**
4244
* Get a single failed job.
4345
*
44-
* @param mixed $id
46+
* @param mixed $id
4547
* @return array
4648
*/
4749
public function find($id)
4850
{
4951
$job = $this->getTable()->find($id);
5052

51-
$job['id'] = (string) $job['_id'];
53+
$job['id'] = (string)$job['_id'];
5254

5355
return $job;
5456
}
5557

5658
/**
5759
* Delete a single failed job from storage.
5860
*
59-
* @param mixed $id
61+
* @param mixed $id
6062
* @return bool
6163
*/
6264
public function forget($id)

‎src/Jenssegers/Mongodb/Queue/MongoConnector.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Queue;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Queue;
24

35
use Illuminate\Database\ConnectionResolverInterface;
46
use Illuminate\Queue\Connectors\ConnectorInterface;
@@ -16,8 +18,7 @@ class MongoConnector implements ConnectorInterface
1618
/**
1719
* Create a new connector instance.
1820
*
19-
* @param \Illuminate\Database\ConnectionResolverInterface $connections
20-
* @return void
21+
* @param \Illuminate\Database\ConnectionResolverInterface $connections
2122
*/
2223
public function __construct(ConnectionResolverInterface $connections)
2324
{
@@ -27,7 +28,7 @@ public function __construct(ConnectionResolverInterface $connections)
2728
/**
2829
* Establish a queue connection.
2930
*
30-
* @param array $config
31+
* @param array $config
3132
* @return \Illuminate\Contracts\Queue\Queue
3233
*/
3334
public function connect(array $config)

‎src/Jenssegers/Mongodb/Queue/MongoJob.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Queue;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Queue;
24

35
use Illuminate\Queue\Jobs\DatabaseJob;
46

‎src/Jenssegers/Mongodb/Queue/MongoQueue.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Queue;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Queue;
24

35
use Carbon\Carbon;
46
use Illuminate\Queue\DatabaseQueue;
@@ -37,7 +39,7 @@ public function pop($queue = null)
3739
{
3840
$queue = $this->getQueue($queue);
3941

40-
if (! is_null($this->retryAfter)) {
42+
if (!is_null($this->retryAfter)) {
4143
$this->releaseJobsThatHaveBeenReservedTooLong($queue);
4244
}
4345

@@ -124,7 +126,7 @@ protected function releaseJobsThatHaveBeenReservedTooLong($queue)
124126
* Release the given job ID from reservation.
125127
*
126128
* @param string $id
127-
* @param int $attempts
129+
* @param int $attempts
128130
* @return void
129131
*/
130132
protected function releaseJob($id, $attempts)

‎src/Jenssegers/Mongodb/Relations/BelongsTo.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Builder;
46

‎src/Jenssegers/Mongodb/Relations/BelongsToMany.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Builder;
46
use Illuminate\Database\Eloquent\Collection;
@@ -144,8 +146,8 @@ public function sync($ids, $detaching = true)
144146
if ($detaching and count($detach) > 0) {
145147
$this->detach($detach);
146148

147-
$changes['detached'] = (array) array_map(function ($v) {
148-
return is_numeric($v) ? (int) $v : (string) $v;
149+
$changes['detached'] = (array)array_map(function ($v) {
150+
return is_numeric($v) ? (int)$v : (string)$v;
149151
}, $detach);
150152
}
151153

@@ -190,14 +192,14 @@ public function attach($id, array $attributes = [], $touch = true)
190192

191193
$query = $this->newRelatedQuery();
192194

193-
$query->whereIn($this->related->getKeyName(), (array) $id);
195+
$query->whereIn($this->related->getKeyName(), (array)$id);
194196

195197
// Attach the new parent id to the related model.
196198
$query->push($this->foreignKey, $this->parent->getKey(), true);
197199
}
198200

199201
// Attach the new ids to the parent model.
200-
$this->parent->push($this->getRelatedKey(), (array) $id, true);
202+
$this->parent->push($this->getRelatedKey(), (array)$id, true);
201203

202204
if ($touch) {
203205
$this->touchIfTouching();
@@ -210,15 +212,15 @@ public function attach($id, array $attributes = [], $touch = true)
210212
public function detach($ids = [], $touch = true)
211213
{
212214
if ($ids instanceof Model) {
213-
$ids = (array) $ids->getKey();
215+
$ids = (array)$ids->getKey();
214216
}
215217

216218
$query = $this->newRelatedQuery();
217219

218220
// If associated IDs were passed to the method we will only delete those
219221
// associations, otherwise all of the association ties will be broken.
220222
// We'll return the numbers of affected rows when we do the deletes.
221-
$ids = (array) $ids;
223+
$ids = (array)$ids;
222224

223225
// Detach all ids from the parent model.
224226
$this->parent->pull($this->getRelatedKey(), $ids);
@@ -307,7 +309,7 @@ protected function formatSyncList(array $records)
307309
{
308310
$results = [];
309311
foreach ($records as $id => $attributes) {
310-
if (! is_array($attributes)) {
312+
if (!is_array($attributes)) {
311313
list($id, $attributes) = [$attributes, []];
312314
}
313315
$results[$id] = $attributes;

‎src/Jenssegers/Mongodb/Relations/EmbedsMany.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Collection;
46
use Illuminate\Database\Eloquent\Model;
@@ -37,7 +39,7 @@ public function getResults()
3739
public function performInsert(Model $model)
3840
{
3941
// Generate a new key if needed.
40-
if ($model->getKeyName() == '_id' and ! $model->getKey()) {
42+
if ($model->getKeyName() == '_id' and !$model->getKey()) {
4143
$model->setAttribute('_id', new ObjectID);
4244
}
4345

@@ -77,10 +79,10 @@ public function performUpdate(Model $model)
7779
$foreignKey = $this->getForeignKeyValue($model);
7880

7981
// Use array dot notation for better update behavior.
80-
$values = array_dot($model->getDirty(), $this->localKey.'.$.');
82+
$values = array_dot($model->getDirty(), $this->localKey . '.$.');
8183

8284
// Update document in database.
83-
$result = $this->getBaseQuery()->where($this->localKey.'.'.$model->getKeyName(), $foreignKey)
85+
$result = $this->getBaseQuery()->where($this->localKey . '.' . $model->getKeyName(), $foreignKey)
8486
->update($values);
8587

8688
// Attach the model to its parent.
@@ -126,7 +128,7 @@ public function performDelete(Model $model)
126128
*/
127129
public function associate(Model $model)
128130
{
129-
if (! $this->contains($model)) {
131+
if (!$this->contains($model)) {
130132
return $this->associateNew($model);
131133
} else {
132134
return $this->associateExisting($model);
@@ -235,7 +237,7 @@ public function attach(Model $model)
235237
protected function associateNew($model)
236238
{
237239
// Create a new key if needed.
238-
if (! $model->getAttribute('_id')) {
240+
if (!$model->getAttribute('_id')) {
239241
$model->setAttribute('_id', new ObjectID);
240242
}
241243

@@ -309,7 +311,7 @@ protected function getEmbedded()
309311
*/
310312
protected function setEmbedded($models)
311313
{
312-
if (! is_array($models)) {
314+
if (!is_array($models)) {
313315
$models = [$models];
314316
}
315317

‎src/Jenssegers/Mongodb/Relations/EmbedsOne.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Model;
46
use MongoDB\BSON\ObjectID;
@@ -34,7 +36,7 @@ public function getResults()
3436
public function performInsert(Model $model)
3537
{
3638
// Generate a new key if needed.
37-
if ($model->getKeyName() == '_id' and ! $model->getKey()) {
39+
if ($model->getKeyName() == '_id' and !$model->getKey()) {
3840
$model->setAttribute('_id', new ObjectID);
3941
}
4042

@@ -69,7 +71,7 @@ public function performUpdate(Model $model)
6971
}
7072

7173
// Use array dot notation for better update behavior.
72-
$values = array_dot($model->getDirty(), $this->localKey.'.');
74+
$values = array_dot($model->getDirty(), $this->localKey . '.');
7375

7476
$result = $this->getBaseQuery()->update($values);
7577

‎src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Builder;
46
use Illuminate\Database\Eloquent\Collection;
@@ -32,11 +34,11 @@ abstract class EmbedsOneOrMany extends Relation
3234
* Create a new embeds many relationship instance.
3335
*
3436
* @param Builder $query
35-
* @param Model $parent
36-
* @param Model $related
37-
* @param string $localKey
38-
* @param string $foreignKey
39-
* @param string $relation
37+
* @param Model $parent
38+
* @param Model $related
39+
* @param string $localKey
40+
* @param string $foreignKey
41+
* @param string $relation
4042
*/
4143
public function __construct(Builder $query, Model $parent, Model $related, $localKey, $foreignKey, $relation)
4244
{
@@ -186,7 +188,7 @@ protected function getIdsArrayFrom($ids)
186188
$ids = $ids->all();
187189
}
188190

189-
if (! is_array($ids)) {
191+
if (!is_array($ids)) {
190192
$ids = [$ids];
191193
}
192194

@@ -208,7 +210,7 @@ protected function getEmbedded()
208210
$attributes = $this->parent->getAttributes();
209211

210212
// Get embedded models form parent attributes.
211-
$embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : null;
213+
$embedded = isset($attributes[$this->localKey]) ? (array)$attributes[$this->localKey] : null;
212214

213215
return $embedded;
214216
}
@@ -278,7 +280,7 @@ protected function toModel($attributes = [])
278280
return;
279281
}
280282

281-
$model = $this->related->newFromBuilder((array) $attributes);
283+
$model = $this->related->newFromBuilder((array)$attributes);
282284

283285
$model->setParentRelation($this);
284286

@@ -339,7 +341,7 @@ protected function isNested()
339341
protected function getPathHierarchy($glue = '.')
340342
{
341343
if ($parentRelation = $this->getParentRelation()) {
342-
return $parentRelation->getPathHierarchy($glue).$glue.$this->localKey;
344+
return $parentRelation->getPathHierarchy($glue) . $glue . $this->localKey;
343345
}
344346

345347
return $this->localKey;
@@ -351,7 +353,7 @@ protected function getPathHierarchy($glue = '.')
351353
public function getQualifiedParentKeyName()
352354
{
353355
if ($parentRelation = $this->getParentRelation()) {
354-
return $parentRelation->getPathHierarchy().'.'.$this->parent->getKeyName();
356+
return $parentRelation->getPathHierarchy() . '.' . $this->parent->getKeyName();
355357
}
356358

357359
return $this->parent->getKeyName();

‎src/Jenssegers/Mongodb/Relations/HasMany.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Builder;
46
use Illuminate\Database\Eloquent\Relations\HasMany as EloquentHasMany;
@@ -62,8 +64,8 @@ public function getRelationCountQuery(Builder $query, Builder $parent)
6264
/**
6365
* Add the constraints for a relationship query.
6466
*
65-
* @param Builder $query
66-
* @param Builder $parent
67+
* @param Builder $query
68+
* @param Builder $parent
6769
* @param array|mixed $columns
6870
* @return Builder
6971
*/

‎src/Jenssegers/Mongodb/Relations/HasOne.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Builder;
46
use Illuminate\Database\Eloquent\Relations\HasOne as EloquentHasOne;
@@ -62,8 +64,8 @@ public function getRelationCountQuery(Builder $query, Builder $parent)
6264
/**
6365
* Add the constraints for a relationship query.
6466
*
65-
* @param Builder $query
66-
* @param Builder $parent
67+
* @param Builder $query
68+
* @param Builder $parent
6769
* @param array|mixed $columns
6870
* @return Builder
6971
*/

‎src/Jenssegers/Mongodb/Relations/MorphTo.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Relations;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Relations;
24

35
use Illuminate\Database\Eloquent\Relations\MorphTo as EloquentMorphTo;
46

‎src/Jenssegers/Mongodb/Schema/Blueprint.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Schema;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Schema;
24

35
use Illuminate\Database\Connection;
46

@@ -84,7 +86,7 @@ public function dropIndex($columns = null)
8486
$transform = [];
8587

8688
foreach ($columns as $column) {
87-
$transform[$column] = $column.'_1';
89+
$transform[$column] = $column . '_1';
8890
}
8991

9092
$columns = $transform;
@@ -130,7 +132,7 @@ public function background($columns = null)
130132
* Specify a sparse index for the collection.
131133
*
132134
* @param string|array $columns
133-
* @param array $options
135+
* @param array $options
134136
* @return Blueprint
135137
*/
136138
public function sparse($columns = null, $options = [])
@@ -148,8 +150,8 @@ public function sparse($columns = null, $options = [])
148150
* Specify a geospatial index for the collection.
149151
*
150152
* @param string|array $columns
151-
* @param string $index
152-
* @param array $options
153+
* @param string $index
154+
* @param array $options
153155
* @return Blueprint
154156
*/
155157
public function geospatial($columns = null, $index = '2d', $options = [])
@@ -174,7 +176,7 @@ public function geospatial($columns = null, $index = '2d', $options = [])
174176
* on the given single-field index containing a date.
175177
*
176178
* @param string|array $columns
177-
* @param int $seconds
179+
* @param int $seconds
178180
* @return Blueprint
179181
*/
180182
public function expire($columns, $seconds)
@@ -221,7 +223,7 @@ public function addColumn($type, $name, array $parameters = [])
221223
* Specify a sparse and unique index for the collection.
222224
*
223225
* @param string|array $columns
224-
* @param array $options
226+
* @param array $options
225227
* @return Blueprint
226228
*/
227229
public function sparse_and_unique($columns = null, $options = [])

‎src/Jenssegers/Mongodb/Schema/Builder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Schema;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Schema;
24

35
use Closure;
46
use Jenssegers\Mongodb\Connection;
@@ -59,7 +61,7 @@ public function hasTable($collection)
5961
/**
6062
* Modify a collection on the schema.
6163
*
62-
* @param string $collection
64+
* @param string $collection
6365
* @param Closure $callback
6466
* @return bool
6567
*/

‎src/Jenssegers/Mongodb/Schema/Grammar.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Schema;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Schema;
24

35
use Illuminate\Database\Schema\Grammars\Grammar as BaseGrammar;
46

‎src/Jenssegers/Mongodb/Validation/DatabasePresenceVerifier.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
<?php namespace Jenssegers\Mongodb\Validation;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Validation;
24

35
class DatabasePresenceVerifier extends \Illuminate\Validation\DatabasePresenceVerifier
46
{
57
/**
68
* Count the number of objects in a collection having the given value.
79
*
8-
* @param string $collection
9-
* @param string $column
10-
* @param string $value
11-
* @param int $excludeId
12-
* @param string $idColumn
13-
* @param array $extra
10+
* @param string $collection
11+
* @param string $column
12+
* @param string $value
13+
* @param int $excludeId
14+
* @param string $idColumn
15+
* @param array $extra
1416
* @return int
1517
*/
1618
public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = [])
1719
{
1820
$query = $this->table($collection)->where($column, 'regex', "/$value/i");
1921

20-
if (! is_null($excludeId) && $excludeId != 'NULL') {
22+
if (!is_null($excludeId) && $excludeId != 'NULL') {
2123
$query->where($idColumn ?: 'id', '<>', $excludeId);
2224
}
2325

@@ -31,17 +33,17 @@ public function getCount($collection, $column, $value, $excludeId = null, $idCol
3133
/**
3234
* Count the number of objects in a collection with the given values.
3335
*
34-
* @param string $collection
35-
* @param string $column
36-
* @param array $values
37-
* @param array $extra
36+
* @param string $collection
37+
* @param string $column
38+
* @param array $values
39+
* @param array $extra
3840
* @return int
3941
*/
4042
public function getMultiCount($collection, $column, array $values, array $extra = [])
4143
{
4244
// Generates a regex like '/(a|b|c)/i' which can query multiple values
43-
$regex = '/('.implode('|', $values).')/i';
44-
45+
$regex = '/(' . implode('|', $values) . ')/i';
46+
4547
$query = $this->table($collection)->where($column, 'regex', $regex);
4648

4749
foreach ($extra as $key => $extraValue) {

‎src/Jenssegers/Mongodb/Validation/ValidationServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Jenssegers\Mongodb\Validation;
1+
<?php
2+
3+
namespace Jenssegers\Mongodb\Validation;
24

35
use Illuminate\Validation\ValidationServiceProvider as BaseProvider;
46

0 commit comments

Comments
 (0)
Please sign in to comment.