Skip to content

Commit 76858f3

Browse files
committed
Run PSR2 fixer
1 parent f6865ba commit 76858f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+481
-627
lines changed

src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use MongoDB\BSON\UTCDateTime;
44

5-
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository {
5+
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository
6+
{
67

78
/**
89
* Build the record payload for the table.
@@ -25,18 +26,14 @@ protected function getPayload($email, $token)
2526
protected function tokenExpired($token)
2627
{
2728
// Convert UTCDateTime to a date string.
28-
if ($token['created_at'] instanceof UTCDateTime)
29-
{
29+
if ($token['created_at'] instanceof UTCDateTime) {
3030
$date = $token['created_at']->toDateTime();
3131

3232
$token['created_at'] = $date->format('Y-m-d H:i:s');
33-
}
34-
elseif (is_array($token['created_at']) and isset($token['created_at']['date']))
35-
{
36-
$token['created_at'] = $token['created_at']['date'];
33+
} elseif (is_array($token['created_at']) and isset($token['created_at']['date'])) {
34+
$token['created_at'] = $token['created_at']['date'];
3735
}
3836

3937
return parent::tokenExpired($token);
4038
}
41-
4239
}

src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use Jenssegers\Mongodb\Auth\DatabaseTokenRepository as DbRepository;
44

5-
class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordResetServiceProvider {
5+
class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordResetServiceProvider
6+
{
67

78
/**
89
* Register the token repository implementation.
@@ -11,8 +12,7 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe
1112
*/
1213
protected function registerTokenRepository()
1314
{
14-
$this->app->singleton('auth.password.tokens', function ($app)
15-
{
15+
$this->app->singleton('auth.password.tokens', function ($app) {
1616
$connection = $app['db']->connection();
1717

1818
// The database token repository is an implementation of the token repository
@@ -27,5 +27,4 @@ protected function registerTokenRepository()
2727
return new DbRepository($connection, $table, $key, $expire);
2828
});
2929
}
30-
3130
}

src/Jenssegers/Mongodb/Collection.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use Exception;
44
use MongoDB\Collection as MongoCollection;
55

6-
class Collection {
6+
class Collection
7+
{
78

89
/**
910
* The connection instance.
@@ -40,8 +41,7 @@ public function __call($method, $parameters)
4041
$start = microtime(true);
4142
$result = call_user_func_array([$this->collection, $method], $parameters);
4243

43-
if ($this->connection->logging())
44-
{
44+
if ($this->connection->logging()) {
4545
// Once we have run the query we will calculate the time that it took to run and
4646
// then log the query, bindings, and execution time so we will report them on
4747
// the event that the developer needs them. We'll log time in milliseconds.
@@ -50,14 +50,10 @@ public function __call($method, $parameters)
5050
$query = [];
5151

5252
// Convert the query paramters to a json string.
53-
foreach ($parameters as $parameter)
54-
{
55-
try
56-
{
53+
foreach ($parameters as $parameter) {
54+
try {
5755
$query[] = json_encode($parameter);
58-
}
59-
catch (Exception $e)
60-
{
56+
} catch (Exception $e) {
6157
$query[] = '{...}';
6258
}
6359
}
@@ -69,5 +65,4 @@ public function __call($method, $parameters)
6965

7066
return $result;
7167
}
72-
7368
}

src/Jenssegers/Mongodb/Connection.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use MongoDB\Client;
44

5-
class Connection extends \Illuminate\Database\Connection {
5+
class Connection extends \Illuminate\Database\Connection
6+
{
67

78
/**
89
* The MongoDB database handler.
@@ -132,8 +133,7 @@ protected function createConnection($dsn, array $config, array $options)
132133
// By default driver options is an empty array.
133134
$driverOptions = [];
134135

135-
if (isset($config['driver_options']) && is_array($config['driver_options']))
136-
{
136+
if (isset($config['driver_options']) && is_array($config['driver_options'])) {
137137
$driverOptions = $config['driver_options'];
138138
}
139139

@@ -162,29 +162,32 @@ protected function getDsn(array $config)
162162
extract($config);
163163

164164
// Check if the user passed a complete dsn to the configuration.
165-
if ( ! empty($dsn))
166-
{
165+
if (! empty($dsn)) {
167166
return $dsn;
168167
}
169168

170169
// Treat host option as array of hosts
171170
$hosts = is_array($host) ? $host : [$host];
172171

173-
foreach ($hosts as &$host)
174-
{
172+
foreach ($hosts as &$host) {
175173
// Check if we need to add a port to the host
176-
if (strpos($host, ':') === false and isset($port))
177-
{
174+
if (strpos($host, ':') === false and isset($port)) {
178175
$host = "{$host}:{$port}";
179176
}
180177
}
181178

182179
// The database name needs to be in the connection string, otherwise it will
183180
// authenticate to the admin database, which may result in permission errors.
184181
$auth = '';
185-
if (! empty($username)) $auth .= $username;
186-
if (! empty($password)) $auth .= ':'.$password;
187-
if ($auth) $auth .= '@';
182+
if (! empty($username)) {
183+
$auth .= $username;
184+
}
185+
if (! empty($password)) {
186+
$auth .= ':'.$password;
187+
}
188+
if ($auth) {
189+
$auth .= '@';
190+
}
188191

189192
return "mongodb://" . $auth . implode(',', $hosts) . "/{$database}";
190193
}
@@ -221,5 +224,4 @@ public function __call($method, $parameters)
221224
{
222225
return call_user_func_array([$this->db, $method], $parameters);
223226
}
224-
225227
}

src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use MongoDB\Driver\Cursor;
66
use MongoDB\Model\BSONDocument;
77

8-
class Builder extends EloquentBuilder {
8+
class Builder extends EloquentBuilder
9+
{
910

1011
/**
1112
* The methods that should be returned from query builder.
@@ -27,8 +28,7 @@ public function update(array $values)
2728
{
2829
// Intercept operations on embedded models and delegate logic
2930
// to the parent relation instance.
30-
if ($relation = $this->model->getParentRelation())
31-
{
31+
if ($relation = $this->model->getParentRelation()) {
3232
$relation->performUpdate($this->model, $values);
3333

3434
return 1;
@@ -47,8 +47,7 @@ public function insert(array $values)
4747
{
4848
// Intercept operations on embedded models and delegate logic
4949
// to the parent relation instance.
50-
if ($relation = $this->model->getParentRelation())
51-
{
50+
if ($relation = $this->model->getParentRelation()) {
5251
$relation->performInsert($this->model, $values);
5352

5453
return true;
@@ -68,8 +67,7 @@ public function insertGetId(array $values, $sequence = null)
6867
{
6968
// Intercept operations on embedded models and delegate logic
7069
// to the parent relation instance.
71-
if ($relation = $this->model->getParentRelation())
72-
{
70+
if ($relation = $this->model->getParentRelation()) {
7371
$relation->performInsert($this->model, $values);
7472

7573
return $this->model->getKey();
@@ -87,8 +85,7 @@ public function delete()
8785
{
8886
// Intercept operations on embedded models and delegate logic
8987
// to the parent relation instance.
90-
if ($relation = $this->model->getParentRelation())
91-
{
88+
if ($relation = $this->model->getParentRelation()) {
9289
$relation->performDelete($this->model);
9390

9491
return $this->model->getKey();
@@ -109,8 +106,7 @@ public function increment($column, $amount = 1, array $extra = [])
109106
{
110107
// Intercept operations on embedded models and delegate logic
111108
// to the parent relation instance.
112-
if ($relation = $this->model->getParentRelation())
113-
{
109+
if ($relation = $this->model->getParentRelation()) {
114110
$value = $this->model->{$column};
115111

116112
// When doing increment and decrements, Eloquent will automatically
@@ -140,8 +136,7 @@ public function decrement($column, $amount = 1, array $extra = [])
140136
{
141137
// Intercept operations on embedded models and delegate logic
142138
// to the parent relation instance.
143-
if ($relation = $this->model->getParentRelation())
144-
{
139+
if ($relation = $this->model->getParentRelation()) {
145140
$value = $this->model->{$column};
146141

147142
// When doing increment and decrements, Eloquent will automatically
@@ -175,13 +170,13 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
175170
$relationCount = array_count_values($query->lists($relation->getHasCompareKey()));
176171

177172
// Remove unwanted related objects based on the operator and count.
178-
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator)
179-
{
173+
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {
180174
// If we are comparing to 0, we always need all results.
181-
if ($count == 0) return true;
175+
if ($count == 0) {
176+
return true;
177+
}
182178

183-
switch ($operator)
184-
{
179+
switch ($operator) {
185180
case '>=':
186181
case '<':
187182
return $counted >= $count;
@@ -198,7 +193,9 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
198193
$not = in_array($operator, ['<', '<=', '!=']);
199194

200195
// If we are comparing to 0, we need an additional $not flip.
201-
if ($count == 0) $not = !$not;
196+
if ($count == 0) {
197+
$not = !$not;
198+
}
202199

203200
// All related ids.
204201
$relatedIds = array_keys($relationCount);
@@ -219,26 +216,22 @@ public function raw($expression = null)
219216
$results = $this->query->raw($expression);
220217

221218
// Convert MongoCursor results to a collection of models.
222-
if ($results instanceof Cursor)
223-
{
219+
if ($results instanceof Cursor) {
224220
$results = iterator_to_array($results, false);
225221
return $this->model->hydrate($results);
226222
}
227223

228224
// Convert Mongo BSONDocument to a single object.
229-
elseif ($results instanceof BSONDocument)
230-
{
225+
elseif ($results instanceof BSONDocument) {
231226
$results = $results->getArrayCopy();
232227
return $this->model->newFromBuilder((array) $results);
233228
}
234229

235230
// The result is a single object.
236-
elseif (is_array($results) and array_key_exists('_id', $results))
237-
{
231+
elseif (is_array($results) and array_key_exists('_id', $results)) {
238232
return $this->model->newFromBuilder((array) $results);
239233
}
240234

241235
return $results;
242236
}
243-
244237
}

src/Jenssegers/Mongodb/Eloquent/Collection.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
44

5-
class Collection extends EloquentCollection {
5+
class Collection extends EloquentCollection
6+
{
67

78
/**
89
* Simulate a get clause on the collection.
@@ -13,8 +14,7 @@ class Collection extends EloquentCollection {
1314
*/
1415
public function get($key = null, $default = null)
1516
{
16-
if (is_null($key) and is_null($default))
17-
{
17+
if (is_null($key) and is_null($default)) {
1818
return $this;
1919
}
2020

@@ -35,17 +35,14 @@ public function where($key, $operator = null, $value = null)
3535
// Here we will make some assumptions about the operator. If only 2 values are
3636
// passed to the method, we will assume that the operator is an equals sign
3737
// and keep going.
38-
if (func_num_args() == 2)
39-
{
38+
if (func_num_args() == 2) {
4039
list($value, $operator) = [$operator, '='];
4140
}
4241

43-
return $this->filter(function ($item) use ($key, $operator, $value)
44-
{
42+
return $this->filter(function ($item) use ($key, $operator, $value) {
4543
$actual = $item->{$key};
4644

47-
switch ($operator)
48-
{
45+
switch ($operator) {
4946
case '<>':
5047
case '!=':
5148
return $actual != $value;
@@ -244,5 +241,4 @@ public function limit($value)
244241
{
245242
return $this->take($value);
246243
}
247-
248244
}

0 commit comments

Comments
 (0)